ToggleButton
proToggleButton composes Button while swapping active and inactive content from one boolean state.
Installation
Add this component with the NateUI CLI.
Examples
Icon Content
Mixed Content
Disabled
Disabled Active Style
API
ToggleButton accepts the content slots below and forwards the remaining Button props and native button props to Button.
| Prop | Description | Type | Default |
|---|---|---|---|
active | Selects activeContent and applies Button's active visual state when true. | boolean | false |
disabledActiveStyle | Keeps the active content while preventing active from being passed to Button. | boolean | false |
activeContent | Content rendered while the toggle is active. | ToggleButtonContent | — |
inactiveContent | Content rendered while the toggle is inactive. | ToggleButtonContent | — |
asElement | Root element or component rendered by Button. | ElementType | 'button' |
block | Expands the control to the full width of its container. | boolean | false |
className | Additional classes or a state-aware class callback. | ButtonClassName | — |
clickFeedback | Enables Button's press-down feedback. | boolean | true |
destructive | Applies Button's destructive intent palette. | boolean | false |
disabled | Prevents interaction and applies the disabled state. | boolean | false |
iconAlignment | Places an icon before or after the active/inactive label. | ButtonIconAlignment | 'start' |
loading | Shows Button's loading spinner and prevents repeat activation. | boolean | false |
onClick | Click handler forwarded to Button. | ButtonClickHandler | — |
ref | Ref forwarded to Button's underlying element. | Ref<HTMLButtonElement> | — |
shape | Border radius treatment. | ButtonShape | 'round' |
size | Button control size. | ControlSize | ConfigProvider default |
variant | Button visual style. | ButtonVariant | 'default' |
...nativeProps | Native props forwarded to the rendered element, such as type, aria-pressed, and aria-label. | NativeButtonProps<E> | — |
Types
ToggleButton does not infer an accessibility relationship from active; pass aria-pressed, aria-expanded, and related native props according to what the control operates.