Skip to content

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

Small Toggle Group for Svelte

A small outline group of bold, italic and underline, shorter than the default, for a compact toolbar. None start pressed.

UI library: Ark UI

Three small outline icon buttons: bold, italic and underline. They are shorter than the default size. None start pressed, and several can be pressed.

Use the small size in a comment box or a cramped toolbar. A Toggle with a visible word is clearer for one format. Ark UI in Svelte does not shrink the hit area for you.

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 size="sm" 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 small toggle groups?

Use sm when space is tight: a toolbar that floats over selected text, a narrow sidebar, a popover editor or a table header. Keep the default size for the main toolbar of a page.

Why use multiple selection instead of single for toggle groups?

Because the options here combine: text can be bold, italic and underlined at once, so each item stays pressed on its own. Single selection, where pressing one item releases the others, is for options that exclude each other, like alignment.

Why use variant outline for small toggle groups?

At a small size, the border marks each item as a separate button, which helps when the icons are close together. The default variant, with no border, also works and suits a toolbar that already has its own frame.

How does ToggleGroup handle spacing between small items?

The group's spacing sets the gap between items, 2 by default, whatever the size. Lower it for a tighter row, or set it to 0 to join the items into one bar where the outline borders are shared.

Are small toggle groups accessible on mobile touchscreens?

They meet the 24 pixel minimum of WCAG 2.5.8, but they're well under the 44 pixel touch target, so they suit pointer-driven layouts best. On touch screens, use the default size or keep enough spacing between items that a tap can't hit the wrong one.

What happens when small toggle groups exceed screen width?

The group is a single row that doesn't wrap, so too many items overflow their container. Keep the group short, add flex-wrap to the group's class, or set orientation="vertical" to stack the items.

API Reference

Toggle Group

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