Button API
View componentThe full prop reference for the Button component. A clickable control with six variants and four sizes, complete with spring-press feedback.
Import
import { Button } from '@structyl/styled';Props
Button
Styled button component with variant system, icon slots, and loading state. Extends native HTML button with semantic styling and layout options.
| Prop | Type | Default |
|---|---|---|
| variant# | 'default' | 'destructive' | 'outline' | 'secondary' | 'ghost' | 'link' | 'success' | 'warning' | 'contained' | 'outlined' | 'text'Visual variant; legacy variants (default, destructive, etc.) are self-contained; MUI-style variants (contained, outlined, text) pair with color prop | 'default' |
| color# | 'primary' | 'secondary' | 'error' | 'warning' | 'info' | 'success' | 'default' | 'inherit'Semantic color; used with MUI-style variants (contained, outlined, text) or standalone with inherit | — |
| size# | 'default' | 'sm' | 'lg' | 'xl' | 'icon' | 'icon-sm' | 'icon-lg' | 'icon-xl'Button size; icon-* variants are square (height === width) | 'default' |
| asChild# | booleanReplace button element with Slot child element, merging props and classes | — |
| loading# | booleanShows spinner icon, disables button, replaces children with loadingText if provided | false |
| loadingText# | stringText displayed next to spinner when loading; defaults to children if not provided | — |
| leftIcon# | React.ReactNodeIcon or element rendered before children | — |
| rightIcon# | React.ReactNodeIcon or element rendered after children | — |
| disabled# | booleanDisables button interaction; also set when loading=true | — |
| className# | stringAdditional CSS classes merged with variant styles | — |
| type# | 'button' | 'submit' | 'reset'HTML button type attribute | 'button' |
| children# | React.ReactNodeButton content | — |
ButtonGroup
Container for grouping buttons with shared prop propagation and optional border-collapse styling.
| Prop | Type | Default |
|---|---|---|
| attached# | booleanCollapses shared borders between adjacent buttons and adjusts border-radius | false |
| orientation# | 'horizontal' | 'vertical'Layout direction of grouped buttons | 'horizontal' |
| variant# | 'default' | 'destructive' | 'outline' | 'secondary' | 'ghost' | 'link' | 'success' | 'warning' | 'contained' | 'outlined' | 'text'Variant propagated to all child Button components | — |
| color# | 'primary' | 'secondary' | 'error' | 'warning' | 'info' | 'success' | 'default' | 'inherit'Color propagated to all child Button components | — |
| size# | 'default' | 'sm' | 'lg' | 'xl' | 'icon' | 'icon-sm' | 'icon-lg' | 'icon-xl'Size propagated to all child Button components | — |
| disabled# | booleanDisabled state propagated to all child Button components | — |
| fullWidth# | booleanMakes each child Button full-width; propagated to all children | — |
| className# | stringAdditional CSS classes for the group container | — |
| children# | React.ReactNodeButton components to group | — |
ButtonSpinner
SVG spinner icon used internally during loading state; exported for custom loading UI.
| Prop | Type | Default |
|---|---|---|
| className# | stringAdditional CSS classes (animate-spin is applied by default) | — |
Keyboard interactions
| Key | Description |
|---|---|
| Space | Activates the button. |
| Enter | Activates the button. |
Source code
If you didn't find what you need here, read the component implementation .