defineButtonStyle function creates custom button styles that can be applied to buttons using the buttonStyle modifier. Button styles receive a configuration object with the button’s label and optional props to customize the appearance.
Parameters
The function accepts a single object with the following properties:body(required) - The button style’s body function(configuration, props) => Componentmetadata(optional) - Metadata about the button style (title, description, etc.)
Configuration Object
The body function receives a configuration object with:label- The label component to render inside the buttonisPressed- Boolean indicating if the button is currently pressed
Returns
Returns aButtonStyleComponent that can be applied to buttons via the buttonStyle modifier.
Note: Button style components do not support modifiers and are only used for styling buttons.
Basic Example
Advanced Examples
Button with Gradient Background
Button with Border and Custom Padding
Button with Pressed State
Using Button Styles
Once defined, button styles can be applied to buttons using thebuttonStyle modifier:
Passing Props to Button Styles
Button styles can accept custom props to make them configurable:Important Notes
- Button style components do not support modifiers - they are specialized for button styling only
- The
configuration.labelis a component that represents the button’s content - Button styles are applied using the
.buttonStyle()modifier on Button components - Props can be passed to button styles to make them customizable
- The
isPressedstate can be used to create interactive press effects - Button styles are ideal for creating consistent button designs across your application
