Toggle Group
Pressable toggles for formatting bars, single or multiple. Each press pops a filled pill in or out.
- Category: Inputs
- Licence: Free, MIT
- Built with: React 19, Tailwind CSS 4, Motion
- Dependencies: motion, clsx, tailwind-merge
Examples
Toggle Group
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
items | { value: string; label: string; icon?: ReactNode }[] | — | |
type | "single" | "multiple" | "multiple" | |
value / defaultValue | string[] | — | |
iconOnly | boolean | false |
About Toggle Group
Toggle Group is a row of pressable toggles for formatting bars and view options. Each press pops a filled pill in or out, and it works as single choice, like alignment, or multiple, like bold, italic and underline.
Toggle Group is an input component for React 19, styled with Tailwind CSS 4 and animated with Motion. It drops into Next.js, Vite, Remix or Astro through the shadcn CLI as a single file you own.
When to use Toggle Group
- Rich text editor toolbars.
- Text alignment and layout options.
- Filter chips that can combine.
- View options like showing grid lines or labels.
How it works
Each item is a button with aria-pressed, or a radio in single mode, and the filled pill is a spring scale so it feels like pressing a key. Icon-only mode keeps accessible names through each item's label.
It is a real form control: it has an accessible name, works with the keyboard alone, shows a visible focus ring and announces its state to screen readers. With prefers-reduced-motion on, it holds still or settles instantly instead of animating.
Customizing Toggle Group
Every prop is documented in the API reference above with its type and default. The ones you will reach for first are listed here.
The Customize panel next to the preview lets you change iconOnly, type live, and the Code tab updates to match, so the snippet you copy already carries your values.
- items.
- type ("single" | "multiple", default "multiple").
- value / defaultValue (string[]).
- iconOnly (boolean, default false).
Goes well with Toggle Group
These inputs pieces share its tokens and motion language, so they sit together on one page without clashing.
- Range Slider: Six animated React range sliders on one accessible core: inline, tick, fluid, wave, bubble and ruler
- Button: An animated React button with six variants, spring press feedback and a width-stable loading state
- Switch: An animated React toggle switch whose thumb stretches when pressed, like a real switch
- Checkbox: An animated React checkbox: the check draws itself in, the box pops, indeterminate morphs to a dash
- Radio Group: An animated React radio group with roving focus and a highlight that glides between card options
Install Toggle Group
npx shadcn@latest add https://charcoalui.com/r/toggle-group.jsonToggle Group is free and MIT licensed. The command copies toggle-group.tsx into components/ui and installs clsx, tailwind-merge; you can also copy the source from the Code tab by hand.
It pairs well with Gooey, a Pro piece: Liquid UI: pieces that touch melt into one another and stretch apart like goo, while text and icons stay perfectly crisp. An SVG filter plus springs, so it works with any markup.
Frequently asked questions
- How do I install Toggle Group?
- Run npx shadcn@latest add https://charcoalui.com/r/toggle-group.json. The shadcn CLI copies toggle-group.tsx into components/ui and installs motion, clsx, tailwind-merge. You can also copy the source from this page by hand.
- Is Toggle Group free for commercial use?
- Yes. Toggle Group is MIT licensed: use it in any personal or commercial project and change it however you like.
- Does Toggle Group work with Next.js?
- Yes. It is a client component for React 19 styled with Tailwind CSS 4, so it works in the Next.js App Router and Pages Router, Vite, Remix and Astro.
- Can an AI coding agent install Toggle Group?
- Yes. Connect the Charcoal UI MCP server (https://charcoalui.com/mcp) to Claude Code, Cursor or any MCP client; get_component returns Toggle Group's props and source and get_install_command returns the exact command.