ThemeButtonStyle
@MainActor
public struct ThemeButtonStyle : ButtonStyle
A comprehensive button style that applies consistent theming across different button variants, shapes, sizes, and font styles.
ThemeButtonStyle supports:
- Filled, Tonal, Outline, Elevated, and Text button variants
- Destructive role styling (uses error colors)
- Dynamic background and border colors for enabled, disabled, and pressed states
- Adaptive padding, shape, font, and shadow based on theme tokens
Example:
Button("Save") { ... }
.buttonStyle(ThemeButtonStyle(variant: .filled, size: .large))
Use this style in conjunction with applyThemeButtonStyle(), buttonVariant(), etc.
for more declarative usage in your design system.
Parameters
variant
|
The visual variant of the button (e.g., |
size
|
The padding and font size configuration. |
shape
|
The corner style for the button. |
font
|
Optional override for the font style and weight. |
-
Undocumented
Declaration
Swift
@MainActor public init( variant: ButtonVariant = .filled, size: ButtonSize = .medium, shape: ButtonShape = .rounded, font: ThemeFontToken? = nil, backgroundColor: Color? = nil, foregroundColor: Color? = nil ) -
Declaration
Swift
@MainActor public func makeBody(configuration: Configuration) -> some View