Toggle

A two-state button that can be either on or off.

Overview

The Toggle component is a button-like control for two-state actions such as formatting, view options, and compact toolbar settings. It owns the default and outline pressed states, so grouped toggles can reuse the same surface behavior.

Usage

import { Toggle } from "@tilt-legal/cubitt-components/toggle";
<Toggle aria-label="Toggle bold">
  <TextBold />
</Toggle>

Examples

Default

Default toggles behave like ghost buttons until pressed.

Outline

Use the outline variant when the toggle should carry a contextual bordered surface.

With Text

Toggles can include both an icon and a short label.

Sizes

Toggles support sm, md, and lg sizes.

URL State

Use URL state when the pressed value should be shareable or restored on refresh.

API Reference

Toggle

PropTypeDefaultDescription
pressedboolean-Controlled pressed state.
defaultPressedbooleanfalseInitial pressed state for uncontrolled usage.
onPressedChange(pressed: boolean) => void-Called when the pressed state changes.
disabledbooleanfalseDisables the toggle.
variant"default" | "outline""default"Visual style.
size"sm" | "md" | "lg""md"Toggle size.
classNamestring-Additional classes.
childrenReact.ReactNode-Toggle content.

URL State Props

PropTypeDefaultDescription
paramNamestring-Search parameter name used for URL state.
paramValueboolean-Controlled URL-backed value.
onUrlValueChange(pressed: boolean | null) => void-Called when the URL-backed value changes.
paramClearOnDefaultbooleantrueRemoves the URL parameter when value matches the default.
paramThrottlenumber-Throttles URL updates in milliseconds.
paramDebouncenumber-Debounces URL updates in milliseconds.

Notes

  • Use aria-label for icon-only toggles.
  • Use pressed and onPressedChange for controlled state.
  • Use ToggleGroup when related toggles need coordinated keyboard navigation or shared selection state.

On this page