Material Theming refers to the customization of your Material Design app to better reflect your product’s brand.
Our approach to theming relies on the relationships between the following concepts:
Components are expected to provide public APIs for a variety of parameters. An example of a component is MDCButton.
Subsystem schemes represent a set of opinionated properties that are intended to be mapped to component parameters. There is a scheme for each Material Theming subsystem. For example, there is a scheme for the color, shape, and typography subsystems.
The Container scheme represents a single configurable entity that is applicable to all themeable components. A container scheme consists of all of the subsystem schemes.
Theming extensions are component extensions that, when invoked with a default container scheme, will theme a component according to the Material Design guidelines. When provided with subsystem schemes via a container scheme, the extension will map the subsystem scheme's values to the component’s parameters.
By default, components have reasonable defaults for all of their customizable properties, e.g. backgroundColor or titleFont. You can use these defaults as a baseline, but we encourage you to theme your components to match your brand style using theming extensions.
import MaterialComponents.MaterialButtons import MaterialComponentsBeta.MaterialButtons_Theming import MaterialComponentsBeta.MaterialContainerScheme let containerScheme = MDCContainerScheme() let button = MDCButton() button.applyTextTheme(withScheme: containerScheme)
#import <MaterialComponents/MaterialButtons.h> #import <MaterialComponents/MaterialButtons+Theming.h> #import <MaterialComponentsBeta/MaterialContainerScheme.h> MDCContainerScheme *containerScheme = [[MDCContainerScheme alloc] init]; MDCButton *button = [[MDCButton alloc] init]; [button applyTextThemeWithScheme:containerScheme];
import MaterialComponents.MaterialColorScheme import MaterialComponents.MaterialTypographyScheme import MaterialComponents.MaterialShapeScheme import MaterialComponentsBeta.MaterialContainerScheme let containerScheme = MDCContainerScheme() containerScheme.colorScheme = myColorScheme containerScheme.typographyScheme = myTypographyScheme containerScheme.shapeScheme = myShapeScheme
#import <MaterialComponents/MaterialColorScheme.h> #import <MaterialComponents/MaterialShapeScheme.h> #import <MaterialComponents/MaterialTypographyScheme.h> #import <MaterialComponentsBeta/MaterialContainerScheme.h> MDCContainerScheme *containerScheme = [[MDCContainerScheme alloc] init]; containerScheme.colorScheme = self.myColorScheme; containerScheme.shapeScheme = self.myShapeScheme; containerScheme.typographyScheme = self.myTypographyScheme;
import MaterialComponents.MaterialColorScheme let colorScheme = MDCSemanticColorScheme(defaults: .material201804) // Configure custom properties to match your brand colorScheme.backgroundColor = .lightGray
#import <MaterialComponents/MaterialColorScheme.h> MDCSemanticColorScheme *colorScheme = [[MDCSemanticColorScheme alloc] initWithDefaults:MDCColorSchemeDefaultsMaterial201804]; // Configure custom properties to match your brand colorScheme.backgroundColor = UIColor.lightGrayColor
In order to use the theming extensions and container scheme you'll need to follow these instructions since they are currently in beta.
In order to use the components and subsystem schemes you'll need to add the targets to your Podfile:
pod 'MaterialComponents/Buttons' pod 'MaterialComponents/schemes/Color'
Note These will soon be deprecated for theming-extensions outlined above.
Our approach to theming relies on the relationships between the following concepts:
Components are expected to provide public APIs for a variety of parameters. An example of a component is MDCBottomNavigation.
Schemes represent a set of opinionated properties that are intended to be mapped to component parameters. There is a scheme for each Material Theming subsystem. For example, there is a scheme for the color, shape, and typography subsystems.
Themers are objects that, when invoked with a scheme, will theme a component according to the Material Design guidelines.
import MaterialComponents.MaterialBottomNavigation import MaterialComponents.MaterialBottomNavigation_ColorThemer let colorScheme = MDCSemanticColorScheme(defaults: .material201804) let bottomNavBar = MDCBottomNavigationBar() MDCBottomNavigationBarColorThemer.applySemanticColorScheme(colorScheme, toBottomNavigation: bottomNavBar)
#import <MaterialComponents/MaterialBottomNavigation.h> #import <MaterialComponents/MaterialBottomNavigation+ColorThemer.h> MDCSemanticColorScheme *colorScheme = [[MDCSemanticColorScheme alloc] initWithDefaults:MDCColorSchemeDefaultsMaterial201804]; MDCBottomNavigation *bottomNavBar = [[MDCBottomNavigation alloc] init]; [MDCBottomNavigationBarColorThemer applySemanticColorScheme:self.colorScheme toBottomNavigation:_bottomNavBar];
import MaterialComponents.MaterialColorScheme let colorScheme = MDCSemanticColorScheme(defaults: .material201804) // Configure custom properties to match your brand colorScheme.backgroundColor = .lightGray
#import <MaterialComponents/MaterialColorScheme.h> MDCSemanticColorScheme *colorScheme = [[MDCSemanticColorScheme alloc] initWithDefaults:MDCColorSchemeDefaultsMaterial201804]; // Configure custom properties to match your brand colorScheme.backgroundColor = UIColor.lightGrayColor
In order to use the components, themers and subsystem schemes you'll need to add the targets to your Podfile:
pod 'MaterialComponents/BottomNavigation' pod 'MaterialComponents/BottomNavigation+ColorThemer' pod 'MaterialComponents/schemes/Color'