Customizable button component with multiple variants, sizes, and loading states
HuxButton
is a versatile button component that provides multiple visual variants, sizes, loading states, and automatic WCAG AA contrast compliance. It adapts seamlessly to light and dark themes.
HuxButtonVariant
enum:
HuxButtonWidth
enum:
Property | Type | Default | Description |
---|---|---|---|
onPressed | VoidCallback? | required | Callback triggered when button is pressed |
child | Widget | required | The child widget to display inside the button |
variant | HuxButtonVariant | primary | Visual variant of the button |
size | HuxButtonSize | medium | Size variant of the button |
isLoading | bool | false | Whether to show loading indicator |
isDisabled | bool | false | Whether the button is disabled |
icon | IconData? | null | Optional icon to display before text |
primaryColor | Color? | null | Custom primary color (overrides theme) |
HuxButtonVariant.primary
- Filled background with primary colorHuxButtonVariant.secondary
- Light background with borderHuxButtonVariant.outline
- Transparent with border onlyHuxButtonVariant.ghost
- Transparent without borderHuxButtonSize.small
- 32px height, compact paddingHuxButtonSize.medium
- 40px height, standard paddingHuxButtonSize.large
- 48px height, generous paddingChoose the Right Variant
Size Appropriately
Loading States
Clear Labels