Buttons
Buttons trigger actions when clicked. Vetra UI provides five button variants for different levels of emphasis.
Variants
Main action button with solid brand color.
When to use: The most important action on screen (e.g., "Submit", "Continue", "Save").
Visual Hierarchy
Limit to one primary button per section for clear hierarchy.
Secondary actions with accent color.
When to use: Important but not primary actions (e.g., "Add to Cart", "Share").
Tertiary actions with border only.
When to use: Less important actions (e.g., "Cancel", "Back", "Skip").
Minimal button with no background.
When to use: Least important actions or dense UIs (e.g., "Maybe Later", navigation items).
Common Patterns
Button States
- Disable button when conditions aren't met
With Icons
Loading State
VetraButton(
onClick = { startLoading() },
enabled = !isLoading
) {
if (isLoading) {
VetraLoadingIndicator(size = 18.dp, color = VetraTheme.colors.onBrand)
Spacer(Modifier.width(8.dp))
}
Text(if (isLoading) "Loading..." else "Submit")
}
Button Groups
Customization
Full Width
VetraButton(
onClick = { /* */ },
modifier = Modifier.fillMaxWidth()
) {
Text("Full Width Button")
}
Custom Size
VetraButton(
onClick = { /* */ },
modifier = Modifier.size(width = 200.dp, height = 56.dp)
) {
Text("Large Button")
}
Best Practices
Do
- ✅ Use one primary button per section
- ✅ Choose variant based on action importance
- ✅ Provide descriptive button text
- ✅ Disable buttons when actions aren't available
- ✅ Ensure minimum 44×44dp touch targets
Don't
- ❌ Use multiple primary buttons in same context
- ❌ Use vague labels like "Click Here" or "OK"
- ❌ Make buttons too small (< 88dp width)
- ❌ Use danger buttons for non-destructive actions
- ❌ Forget to handle loading states
Accessibility
- Touch Targets: Minimum 44×44dp built-in
- Color Contrast: All variants meet WCAG AA standards
- Focus Indicators: Automatic press indication
- Screen Readers: Semantic
Role.Buttonsupport
Improve Accessibility
API Reference
All Button Variants
All button variants share the same API signature:
| Parameter | Type | Default | Description |
|---|---|---|---|
onClick |
() -> Unit |
Required | Callback when button is clicked |
modifier |
Modifier |
Modifier |
Modifier for customization |
enabled |
Boolean |
true |
Whether button is interactive |
content |
@Composable RowScope.() -> Unit |
Required | Button content (text, icons, etc.) |
Default Dimensions
| Property | Value | Note |
|---|---|---|
| Min Height | 44dp | Meets accessibility standards |
| Min Width | 88dp | Comfortable click target |
| Horizontal Padding | 20dp | Internal spacing |
| Vertical Padding | 12dp | Internal spacing |
| Corner Radius | 8dp | shapes.sm |
Visual Properties by Variant
| Variant | Background | Text Color | Border | Shadow |
|---|---|---|---|---|
| Primary | brand |
onBrand |
None | shadows.sm |
| Secondary | accent |
onAccent |
None | shadows.sm |
| Outlined | Transparent | brand |
border |
None |
| Ghost | Transparent | brand |
None | None |
| Danger | danger |
onDanger |
None | shadows.sm |
See Also:
- Design: Colors - Button color system
- Design: Elevation - Button shadows