Controlled
Use the value and onValueChange props to control state programmatically.
You selected bold
You selected bold
Orientation
Using the orientation prop to control the layout.
Horizontal
Vertical
Horizontal
Vertical
Direction
Set the text direction (ltr or rtl) using the dir prop.
Anatomy
Here’s an overview of how the ToggleGroup component is structured in code:
import { ToggleGroup } from '@skeletonlabs/skeleton-react';
export default function Anatomy() {
return (
<ToggleGroup>
<ToggleGroup.Item />
</ToggleGroup>
);
}<script lang="ts">
import { ToggleGroup } from '@skeletonlabs/skeleton-svelte';
</script>
<ToggleGroup>
<ToggleGroup.Item />
</ToggleGroup>API Reference
Root
| Prop | Default | Type |
|---|---|---|
ids | — | Partial<{ root: string; item: (value: string) => string; }> | undefined The ids of the elements in the toggle. Useful for composition. |
disabled | — | boolean | undefined Whether the toggle is disabled. |
value | — | string[] | undefined The controlled selected value of the toggle group. |
defaultValue | — | string[] | undefined The initial selected value of the toggle group when rendered. Use when you don't need to control the selected value of the toggle group. |
onValueChange | — | ((details: ValueChangeDetails) => void) | undefined Function to call when the toggle is clicked. |
loopFocus | true | boolean | undefined Whether to loop focus inside the toggle group. |
rovingFocus | true | boolean | undefined Whether to use roving tab index to manage focus. |
orientation | "horizontal" | Orientation | undefined The orientation of the toggle group. |
multiple | — | boolean | undefined Whether to allow multiple toggles to be selected. |
deselectable | true | boolean | undefined Whether the toggle group allows empty selection. **Note:** This is ignored if `multiple` is `true`. |
dir | "ltr" | "ltr" | "rtl" | undefined The document's text/writing direction. |
getRootNode | — | (() => ShadowRoot | Node | Document) | undefined A root node to correctly resolve document in custom environments. E.x.: Iframes, Electron. |
element | — | ((attributes: HTMLAttributes<"div">) => Element) | undefined Render the element yourself |
Provider
| Prop | Default | Type |
|---|---|---|
value | — | ToggleGroupApi<PropTypes> |
element | — | ((attributes: HTMLAttributes<"div">) => Element) | undefined Render the element yourself |
Context
| Prop | Default | Type |
|---|---|---|
children | — | (togglegroup: ToggleGroupApi<PropTypes>) => ReactNode |
Item
| Prop | Default | Type |
|---|---|---|
value | — | string |
disabled | — | boolean | undefined |
element | — | ((attributes: HTMLAttributes<"button">) => Element) | undefined Render the element yourself |
Root
| Prop | Default | Type |
|---|---|---|
ids | — | Partial<{ root: string; item: (value: string) => string; }> | undefined The ids of the elements in the toggle. Useful for composition. |
disabled | — | boolean | undefined Whether the toggle is disabled. |
value | — | string[] | undefined The controlled selected value of the toggle group. |
defaultValue | — | string[] | undefined The initial selected value of the toggle group when rendered. Use when you don't need to control the selected value of the toggle group. |
onValueChange | — | ((details: ValueChangeDetails) => void) | undefined Function to call when the toggle is clicked. |
loopFocus | true | boolean | undefined Whether to loop focus inside the toggle group. |
rovingFocus | true | boolean | undefined Whether to use roving tab index to manage focus. |
orientation | "horizontal" | Orientation | undefined The orientation of the toggle group. |
multiple | — | boolean | undefined Whether to allow multiple toggles to be selected. |
deselectable | true | boolean | undefined Whether the toggle group allows empty selection. **Note:** This is ignored if `multiple` is `true`. |
dir | "ltr" | "ltr" | "rtl" | undefined The document's text/writing direction. |
getRootNode | — | (() => ShadowRoot | Node | Document) | undefined A root node to correctly resolve document in custom environments. E.x.: Iframes, Electron. |
element | — | Snippet<[HTMLAttributes<"div">]> | undefined Render the element yourself |
Provider
| Prop | Default | Type |
|---|---|---|
value | — | () => ToggleGroupApi<PropTypes> |
element | — | Snippet<[HTMLAttributes<"div">]> | undefined Render the element yourself |
Context
| Prop | Default | Type |
|---|---|---|
children | — | Snippet<[() => ToggleGroupApi<PropTypes>]> |
Item
| Prop | Default | Type |
|---|---|---|
value | — | string |
disabled | — | boolean | undefined |
element | — | Snippet<[HTMLAttributes<"button">]> | undefined Render the element yourself |