ToggleGroup
Single/multiple pressed-button toolbar with roving arrow navigation.
All components · Theme builder · Implementation source
Live preview
Open live toggle-group preview
Install
netscript ui:add toggle-groupUsage and examples
The preview runs this JSX with the installed components. Import any composed primitives from your UI directory.
import { useState } from 'preact/hooks';
import { ToggleGroup } from '@app/components/ui/toggle-group.tsx';
export function Example() {
const [value, setValue] = useState('standard');
const [open, setOpen] = useState(false);
const [notice, report] = useState('');
return (<><div><ToggleGroup label="Order view" items={[{value:"list",label:"List"},{value:"grid",label:"Grid"}]} /></div><p role="status">{notice}</p></>);
}Props
Generated from native deno doc --json --private over the shipped implementation. Compound component props retain their owning interface; native attributes pass through where declared.
| Owner | Prop | Type | Optional | Description |
|---|---|---|---|---|
ToggleGroupProps | class | string | Yes | |
ToggleGroupProps | label | string | No | |
ToggleGroupProps | items | [object Object] | No | |
ToggleGroupProps | type | "single" | "multiple" | Yes | |
ToggleGroupProps | variant | "default" | "outline" | "segmented" | Yes | |
ToggleGroupProps | orientation | "horizontal" | "vertical" | Yes | |
ToggleGroupProps | size | "sm" | "md" | Yes | |
ToggleGroupProps | value | [object Object] | Yes | |
ToggleGroupProps | defaultValue | [object Object] | Yes | |
ToggleGroupProps | onValueChange | (value: [object Object]) => void | Yes | |
ToggleGroupProps | disabled | boolean | Yes |
ToggleGroupProps extends Omit<JSX.HTMLAttributes<HTMLDivElement>, "class">Keyboard
| Key | Action |
|---|---|
Arrow keys | Move focus between toggles |
Home/End | Focus first/last toggle |
Enter/Space | Toggle focused item |
Tokens
Semantic contract roles: space/inline/gap.
CSS custom properties referenced directly: --ns-component-tabs-selected, --ns-control-gap, --ns-fg, --ns-muted, --ns-radius-control, --ns-space-1, --ns-space-1-5, --ns-studio-signal-marker, --ns-studio-tabs-gap, --ns-studio-tabs-pad, --ns-studio-tabs-radius, --ns-studio-tabs-sel-bg, --ns-studio-tabs-track.
Contract and compatibility
Accessibility pattern: WAI-ARIA guidance
- Native CSS pseudo-classes carry transient focus/hover; data-state also supports deliberate preview renders. Native button semantics preserve form behavior.
Design contract values marked planned are not implementation props. The props above describe what ships today.