Skip to content

Latest commit

 

History

History
125 lines (89 loc) · 3.22 KB

File metadata and controls

125 lines (89 loc) · 3.22 KB

Theming

You can theme an MDCButton to match a Material Design button style using theming extensions. Learn more about theming extensions.

How to theme an MDCButton

First, import both Buttons and Buttons Theming and create an instance of MDCButton.

Swift

import MaterialComponents.MaterialButtons
import MaterialComponents.MaterialButtons_Theming

let button = MDCButton()

Objective-C

#import <MaterialComponents/MaterialButtons.h>
#import <MaterialComponentsBeta/MaterialButtons+Theming.h>

MDCButton *button = [[MDCButton alloc] init];

You can then provide a container scheme instance to any of the MDCButton theming extensions. Learn more about container schemes.

Material text button theming:

An animation showing a Material Design text button.

Swift

button.applyTextTheme(withScheme: containerScheme)

Objective-C

[self.button applyTextThemeWithScheme:self.containerScheme];

Material outlined button theming:

An animation showing a Material Design outlined button.

Swift

button.applyOutlinedTheme(withScheme: containerScheme)

Objective-C

[self.button applyOutlinedThemeWithScheme:self.containerScheme];

Material contained button theming:

An animation showing a Material Design contained button.

Swift

button.applyContainedTheme(withScheme: containerScheme)

Objective-C

[self.button applyContainedThemeWithScheme:self.containerScheme];

How to theme an MDCFloatingButton

First, create a button and import the theming extension header for Buttons.

Swift

import MaterialComponents.MaterialButtons
import MaterialComponentsBeta.MaterialButtons_Theming

let floatingButton = MDCFloatingButton()

Objective-C

#import <MaterialComponents/MaterialButtons.h>
#import <MaterialComponentsBeta/MaterialButtons+Theming.h>

MDCFloatingButton *floatingButton = [[MDCFloatingButton alloc] init];

Material floating action button theming:

An animation showing a Material Design floating action button.

Swift

floatingButton.applySecondaryTheme(withScheme: containerScheme)

Objective-C

[self.floatingButton applySecondaryThemeWithScheme: self.containerScheme];