Set
Flush
One alignment. The group is one object.
Selects one option from joined toggles. The active option fills with ink.
Flush
One alignment. The group is one object.
Three ways in. They share one source, so the pixels match whichever you pick.
npm install @noorddev/vlak-react
// once, next to your app's root
import "@noorddev/vlak-react/css";
import { ToggleGroup } from "@noorddev/vlak-react";Precompiled React and one stylesheet. No compiler to configure. Per-component imports work too: @noorddev/vlak-react/components/toggle-group.
npx @noorddev/vlak-cli add toggle-group
The StyleX leaf lands in components/vlak/ with its dependencies, for your own compiler to own. See StyleX.
npx shadcn add https://vlak.dev/r/toggle-group.json
The same registry item, installed by shadcn's CLI.
<link rel="stylesheet" href="node_modules/@noorddev/vlak/css/vlak.css" />
No React. Link vlak.css and use the markup and classes below.
import { useState } from "react";
import { ToggleGroup } from "@noorddev/vlak-react";
const [align, setAlign] = useState("left");
<ToggleGroup
aria-label="Alignment"
options={[
{ value: "left", label: "Left" },
{ value: "center", label: "Center" },
{ value: "right", label: "Right" },
]}
value={align}
onValueChange={setAlign}
/>One pressed at a time.
| Prop | Type | Default | Description |
|---|---|---|---|
optionsrequired | { value: string; label: ReactNode; }[] | ||
value | string | ||
defaultValue | string | ||
onValueChange | (value: string) => void |
Also accepts Omit<HTMLAttributes<HTMLDivElement>, "onChange">.
| Keys | Does |
|---|---|
| Tab | Moves between the options |
| Enter, Space | Selects the focused option |
<div class="rs-toggle-group"><button class="rs-toggle" aria-pressed="true">Left</button><button class="rs-toggle" aria-pressed="false">Center</button><button class="rs-toggle" aria-pressed="false">Right</button></div>