Skip to content

shadcn.io is an independent project built on shadcn/ui

Default Size Toggle Group for Svelte

An outline group of three icon buttons for bold, italic and underline, at the default size. None of them start pressed.

UI library: Ark UI

Three outline icon buttons in a group: bold, italic and underline, at the default size. None start pressed. There is no visible word on the buttons.

Start at the default size for a formatting bar. A single Toggle is enough for one format. Ark UI in Svelte does not apply the formatting.

Preview

Preview width

Installation

MCP · Pro
Make your AI a shadcn expert
Your agent installs components, builds pages and restyles your app from one prompt, in Claude Code, Cursor or VS Code.
Part of Pro

Anatomy

Toggle Group anatomy: root, item

Usage

<ToggleGroup aria-label="Text formatting" multiple variant="outline"><ToggleGroupItem aria-label="Toggle bold" value="bold"><BoldIcon aria-hidden="true" /></ToggleGroupItem><ToggleGroupItem aria-label="Toggle italic" value="italic"><ItalicIcon aria-hidden="true" /></ToggleGroupItem><ToggleGroupItem aria-label="Toggle underline" value="underline"><UnderlineIcon aria-hidden="true" /></ToggleGroupItem></ToggleGroup>

FAQ

When should I use default size toggle groups?

Use the default size for most toolbars. It matches the default height of Button and Input, so the group lines up with the controls around it. Go to sm in crowded or inline toolbars, and to lg when there are only a few items and they're the main controls.

Why does default size not need a size prop?

The group's size defaults to md, and every item takes its size from the group, so leaving the prop out gives the default size. Set size on the group only for sm or lg.

Do default toggle groups need size adjustments for mobile?

Usually not, but check the targets. The default size meets the 24 pixel minimum of WCAG 2.5.8, while it's smaller than the 44 pixel touch target in most styles. Keeping the default spacing between items helps on touch screens; use size="lg" where touch is the main input.

Should I use multiple or single selection for formatting controls?

Multiple, as here: bold, italic and underline combine, so each item should stay pressed independently. Use single selection for options that exclude each other, like text alignment in the Single Selection Toggle Group example.

Can I use default variant instead of outline?

Yes. Leave out variant="outline" and the items lose their border, appearing only on hover and when pressed, as in the Default Toggle Group example. Both variants work at every size.

How many items should a default toggle group contain?

Keep a group to a handful of related options, like the three text styles here. When a toolbar needs more, split it into several groups by purpose, such as text style, alignment and lists, rather than one long row.

API Reference

Toggle Group

Sets aria-label="Text formatting", multiple, variant="outline", aria-label="Toggle bold", value="bold" and aria-label="Toggle italic". The rest is on the Toggle Group page.