Component
Button
A FormaUI button — "Material 3 with better defaults" — one entry point covering all five Material 3 button variants via a single variant parameter, with a default-on press-scale micro-interaction layered on the ripple.
dev.formaui.components.button
filledtonalelevatedoutlinedtext
Preview
This toggle is site chrome only — the preview has its own light/dark switch inside.
Live preview
Live preview — ~37 MB development build
Usage
FormaButton(onClick = { /* submit */ }) {
Text("Confirm")
}
FormaButton(onClick = { }, variant = FormaButtonVariant.Outlined, enabled = false) {
Text("Disabled")
}Supporting API
- FormaButtonVariantenum
- Visual emphasis of a FormaButton, listed highest to lowest: Filled, Tonal, Elevated, Outlined, Text.
- FormaButtonDefaultsobject
- Defaults for FormaButton: MinTouchTargetSize (48dp), shape (FormaTheme.shapes.md), contentPadding (lg horizontal / xs vertical spacing tokens).
- Modifier.formaPressScalemodifier
- Reusable press-scale micro-interaction (dev.formaui.components.interaction): observes an InteractionSource and scales the element to pressedScale while pressed via graphicsLayer, so measured size and the 48dp touch target are unaffected. animationSpec = null disables it.
- FormaPressScaleDefaultsobject
- Defaults for Modifier.formaPressScale: PressedScale (0.97), DownAnimationSpec (a fast 100ms tween for the press dip), and AnimationSpec (a medium-stiffness, low-bouncy spring for the release spring-back).
Accessibility
A minimum 48dp touch target (FormaButtonDefaults.MinTouchTargetSize) is always enforced; Role.Button semantics and disabled state are inherited from the underlying Material 3 button.