ui

Toggle Group

Provides a shared state to a series of toggle buttons. Built with Base UI and Tailwind CSS. Copy-paste ready.

Installation

Usage

Examples

Sizes

Renders sm, default, and lg size variants side by side to demonstrate scale options across layouts.

With Outline Toggles

Uses the outline variant for each toggle, making the group feel more like a segmented button bar against light surfaces.

Vertical

Set orientation="vertical" to stack toggles top-to-bottom — common in side-panel formatting controls.

Multiple selection

With type="multiple", users can activate more than one toggle at a time — suitable for text formatting options like bold + italic.

Text Alignment

Icon-only toggles for left, center, right, and justify alignment — a standard rich-text editor control.

View Mode

A single-select group for switching between list and grid views, driving a layout change in the parent component.

Color Theme

A compact group of color-swatch toggles for picking an accent theme, with a checkmark indicator on the active selection.

Pricing Tier

A billing-period toggle (monthly / annual) that drives pricing display — a common SaaS pricing page pattern.

Language Picker

Selects a programming language from TypeScript, JavaScript, Python, or Rust. The code panel below updates to show the equivalent greet function in the chosen language.

Column Sort Direction

A per-row ascending / descending sort toggle for each table column. Each row shows a toggle group with Up and Down arrow items; clearing the selection resets that column.

Issue Priority Picker

Each issue card has an inline priority group (Low / Medium / High / Critical) with a color-coded dot and label. Selecting a priority updates the badge in the card header live.

Date Range Quick-Select

Five quick-select range options — Today, Week, Month, Quarter, Year — each showing a sublabel date range. Switching updates a three-column stats grid below with the relevant metrics.

Code Viewer Toolbar

Multiple-select toggle group for editor options: Word wrap, Case sensitive, Filter, and Sort. Active options are listed below the viewer panel and update as toggles are pressed.

Zoom Level

A five-step zoom group (50 % – 150 %) that scales a preview card via CSS transform: scale(). The current zoom percentage is displayed below the preview.