Toggle

A two-state button. Icons pop slightly when pressed on.

Playground

Tweak the props, the preview and the code follow.

Props
<Toggle variant="outline">
  <Star /> Star
</Toggle>

Installation

npx @plumsydev/plum-ui add toggle

Usage

import { Toggle } from "@/components/ui/toggle"
<Toggle aria-label="Bold"><Bold /></Toggle>

Examples

Outline

Like & save

Controlled toggles with custom pressed colors.

API Reference

Toggle

Extends Radix Toggle.Root.

PropTypeDefault
variant

Visual style.

"default" | "outline""default"
size

Size.

"sm" | "default" | "lg""default"
pressed / defaultPressed

Controlled or initial state.

boolean—
onPressedChange

Called when toggled.

(pressed: boolean) => void—

Notes

  • Use toggleVariants() to style other elements like a toggle.