ToggleButton
A pressed or unpressed action, alone or in a group.
- Composed
- Liquid Glass on iOS 26
- New in 0.1
import { ToggleButton, toggleButtonGroupPrimitive, toggleButtonPrimitive } from "nitro-ui-sdk/toggle-button";- HeroUI Native
- ToggleButton (Pro)ToggleButtonGroup (Pro)
- Expo UI
- ToggleButtonToggle

Light 
Dark 
Liquid Glass
On this page
A button that stays pressed: bold, mute, favorite, shuffle. Alone it holds one on/off value; inside ToggleButton.Group the group holds the pressed keys with single or multiple selection, like a formatting toolbar. Use Switch for a setting that takes effect at once in a list, SegmentedControl for picking one of a few views, and Chip for filters in a wrapping list.
Anatomy
import { ToggleButton } from "nitro-ui-sdk/toggle-button";
export function Anatomy() {
return (
<ToggleButton.Group label="Text style" selectionMode="multiple">
<ToggleButton.Root value="bold" label="Bold">
<ToggleButton.Icon symbol="bold" />
<ToggleButton.Label />
</ToggleButton.Root>
</ToggleButton.Group>
);
}
| Part | Description |
|---|---|
ToggleButton.Group |
Optional. A row of items that share one value, the pressed keys. |
ToggleButton.Root |
The native pressable host with the selected state. |
ToggleButton.Icon |
A glyph before the label. Defaults to the root’s icon. |
ToggleButton.Label |
The visible text. Defaults to label. Hidden with iconOnly. |
Usage
import { ToggleButton } from "nitro-ui-sdk/toggle-button";
export function Favorite() {
return <ToggleButton.Root label="Favorite" icon="star.fill" defaultPressed />;
}
A group with multiple selection, as a toolbar:
import { ToggleButton } from "nitro-ui-sdk/toggle-button";
export function Formatting() {
return (
<ToggleButton.Group label="Text style" selectionMode="multiple" defaultValue={["bold"]}>
<ToggleButton.Root value="bold" label="Bold" icon="bold" iconOnly />
<ToggleButton.Root value="italic" label="Italic" icon="italic" iconOnly />
<ToggleButton.Root value="underline" label="Underline" icon="underline" iconOnly />
</ToggleButton.Group>
);
}
Variants and sizes
| Variant | Unpressed | Pressed |
|---|---|---|
default |
Neutral default fill. |
Solid accent fill. |
outline |
Transparent with a border hairline. |
accentSoft fill with an accent border. |
glass |
Liquid Glass. | Accent-tinted Liquid Glass; falls back to accent. |
Sizes sm, md (default) and lg use the button heights (36, 44, 52). With iconOnly the item is a square of that height. Items take the group’s variant and size unless they set their own.
States
- Pressed:
selectedtrait, accent colors. A touch that changes the value plays the selection tick. - Disabled: on an item or the whole group; dims and refuses every change.
- Single selection:
selectionMode="single"(default for groups) keeps at most one item pressed.disallowEmptySelectionpreserves an existing selection. Single selection displays the first supplied key, and multiple selection displays unique keys.
Controlled
import { useState } from "react";
import { ToggleButton } from "nitro-ui-sdk/toggle-button";
export function Filters() {
const [muted, setMuted] = useState(false);
const [kinds, setKinds] = useState<readonly string[]>(["photos"]);
return (
<>
<ToggleButton.Root label="Mute" icon={muted ? "speaker.slash" : "speaker.wave.2"} pressed={muted} onPressedChange={setMuted} />
<ToggleButton.Group label="Kinds" selectionMode="multiple" value={kinds} onValueChange={setKinds} size="sm">
<ToggleButton.Root value="photos" label="Photos" />
<ToggleButton.Root value="videos" label="Videos" />
</ToggleButton.Group>
</>
);
}
The controller returns requested immediately when a controlled owner needs to apply the new value. onPressedChange(pressed, details) and onValueChange(keys, details) receive details.source and can call details.preventDefault() to refuse.
Liquid Glass
variant="glass" draws each item as an interactive MaterialView; a group of glass items sits in a MaterialGroup so nearby glass merges. Pressed items take the accent tint. Without Liquid Glass (glass off, iOS before 26, Reduce Transparency) items draw the default and accent fills and scale on press.
import { ToggleButton } from "nitro-ui-sdk/toggle-button";
export function Playback() {
return (
<ToggleButton.Group label="Playback" selectionMode="multiple" variant="glass">
<ToggleButton.Root value="shuffle" label="Shuffle" icon="shuffle" iconOnly />
<ToggleButton.Root value="repeat" label="Repeat" icon="repeat" iconOnly />
</ToggleButton.Group>
);
}
Props
ToggleButton.Root
| Prop | Type | Default | Description |
|---|---|---|---|
label |
string |
required | The spoken name; the only name with iconOnly. |
value |
string |
— | The item key inside a group. The group owns the pressed state there. |
pressed |
boolean |
— | Pressed state (controlled). Ignored inside a group. |
defaultPressed |
boolean |
false |
Initial state (uncontrolled). |
onPressedChange |
(pressed: boolean, details: ActionDetails) => void |
— | Every accepted change from touch, agent or API. |
variant |
"default" | "outline" | "glass" |
group’s, or "default" |
See Variants. |
size |
"sm" | "md" | "lg" |
group’s, or "md" |
See Sizes. |
icon |
string |
— | SF Symbol before the label. |
iconFallback |
ImageLoader |
— | Image for Android and missing symbols. |
iconOnly |
boolean |
false |
Shows only the icon. |
disabled |
boolean |
false |
Refuses every change. |
hint |
string |
— | Accessibility hint. |
api |
Controller<ToggleButtonActions> |
— | From toggleButtonPrimitive.createApi(). |
agentId |
string |
value |
Stable agent identity. |
styles |
ToggleButtonStyles |
— | Per-part style resolvers. |
layout |
LayoutProps |
— | Layout of the host. |
children |
ReactNode |
— | Custom anatomy. |
ToggleButton.Group
| Prop | Type | Default | Description |
|---|---|---|---|
label |
string |
required | Names the accessibility group and agent entry. |
selectionMode |
"single" | "multiple" |
"single" |
How many items can be pressed. |
value |
readonly string[] |
— | Pressed keys (controlled). |
defaultValue |
readonly string[] |
[] |
Initial keys (uncontrolled). |
onValueChange |
(value: readonly string[], details: ActionDetails) => void |
— | Every accepted change. |
disallowEmptySelection |
boolean |
false |
Keeps at least one item pressed. |
disabled |
boolean |
false |
Disables every item. |
variant |
ToggleButtonVariant |
"default" |
The items’ default variant. |
size |
ToggleButtonSize |
"md" |
The items’ default size. |
api |
Controller<ToggleButtonGroupActions> |
— | From toggleButtonGroupPrimitive.createApi(). |
agentId |
string |
— | Stable agent identity. |
styles |
ToggleButtonGroupStyles |
— | Resolver for the group part. |
layout |
LayoutProps |
— | Positions and sizes the group. Flex direction, wrapping, gaps and alignment apply to the items in every variant. |
children |
ReactNode |
required | Items with a unique value key. |
ToggleButton.Icon
| Prop | Type | Default | Description |
|---|---|---|---|
symbol |
string |
root’s icon |
Decorative SF Symbol. |
fallback |
ImageLoader |
root’s iconFallback |
Image for Android and missing symbols. |
part |
ToggleButtonPart |
"icon" |
Selects the style resolver. |
ToggleButton.Label
| Prop | Type | Default | Description |
|---|---|---|---|
children |
string |
root’s label |
Visible title. |
part |
ToggleButtonPart |
"label" |
Selects the style resolver. |
Controller API
import { useState } from "react";
import { Button } from "nitro-ui-sdk/button";
import { ToggleButton, toggleButtonGroupPrimitive } from "nitro-ui-sdk/toggle-button";
export function Toolbar() {
const [api] = useState(toggleButtonGroupPrimitive.createApi);
return (
<>
<ToggleButton.Group label="Text style" selectionMode="multiple" api={api}>
<ToggleButton.Root value="bold" label="Bold" icon="bold" iconOnly />
<ToggleButton.Root value="italic" label="Italic" icon="italic" iconOnly />
</ToggleButton.Group>
<Button.Root label="Clear" variant="ghost" onPress={() => void api.current?.select([])} />
</>
);
}
| Controller | Action | Signature | Result |
|---|---|---|---|
| item | toggle |
(source?) => ChangeStatus |
accepted, requested (controlled), disabled or refused. |
| item | setPressed |
(pressed: boolean, source?) => ChangeStatus |
Setting the current value is accepted with no change. Releasing the last selected item is refused with disallowEmptySelection, as with toggle. |
| group | toggle |
(key: string, source?) => ChangeStatus |
unavailable for an unknown key, disabled for a disabled item, refused if it would empty a group with disallowEmptySelection. |
| group | select |
(keys: readonly string[], source?) => ChangeStatus |
Replaces the keys. refused for more than one key in single mode, or none with disallowEmptySelection. |
Styles
import { ToggleButton, type ToggleButtonStyles } from "nitro-ui-sdk/toggle-button";
const styles: ToggleButtonStyles = {
root: ({ tokens, state }) => ({
style: { background: state.pressed ? tokens.colors.success : tokens.colors.default },
}),
label: ({ tokens, state }) => ({
text: { color: state.pressed ? tokens.colors.successForeground : tokens.colors.defaultForeground },
}),
};
export function Online() {
return <ToggleButton.Root label="Online" styles={styles} />;
}
Parts: root, icon, label. The resolver receives { tokens, variant, size, state } with state: { disabled: boolean; pressed: boolean; iconOnly: boolean }. The group takes a group resolver with state: { disabled: boolean; value: readonly string[] }.
Accessibility
- Each item is a
buttonelement with theselectedtrait while pressed: “Bold, selected, button”. - Icon-only items keep
labelas their name. - Disabled items add
notEnabled. - A touch that changes the value plays
selectionChanged(); a refused or empty press stays silent.
Agent API
Item (component: "ToggleButton", role: "button", state: { disabled, selected }):
| Action | Arguments | Notes |
|---|---|---|
toggle |
none | Flips the pressed state. |
setPressed |
boolean |
Anything else is invalid-arguments. |
Group (component: "ToggleButtonGroup", role: "group", value: the pressed keys joined with “, “, options: { key, name } per item):
| Action | Arguments | Notes |
|---|---|---|
toggle |
string key |
Follows the selection mode. |
select |
string[] keys |
Replaces the pressed keys. |
The agent waits for the controlled render to settle. It returns accepted when the owner applies the requested value and refused when the owner leaves the request unapplied.
Platform notes
| iOS | Android | |
|---|---|---|
| Host | KitPressable with selected and button traits. |
PressableGroup; isSelected carries the pressed state. |
| Glass | Liquid Glass in a MaterialGroup on iOS 26, opaque fallback otherwise. |
Opaque fallback. |
| Haptics | UISelectionFeedbackGenerator. |
HapticFeedbackConstants. |
| Verification | Unit, type and iOS harness tests. | Kotlin implementation is unbuilt here (no Android NDK). |