kemiljk

Toggle

Component

About

A two-state push button that toggles between pressed and unpressed, built on a real button with aria-pressed — used for toolbar actions like bold/italic formatting.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Toggle to your project and fits it to your theme.

Code

How Toggle is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

import { Toggle } from "@/components/ui/toggle";

export default function ToggleDemo() {
  return (
    <div className="flex items-center gap-2">
      <Toggle aria-label="Bold" defaultPressed>
        <strong>B</strong>
      </Toggle>
      <Toggle aria-label="Italic">
        <em>I</em>
      </Toggle>
      <Toggle aria-label="Underline">
        <span style={{ textDecoration: "underline" }}>U</span>
      </Toggle>
    </div>
  );
}

More by kemiljk

View all
  • Switch

    Switch

    8
  • Color Picker

    Color Picker

    1
  • Combobox

    Combobox

  • Progress

    Progress

  • Navigation Menu

    Navigation Menu

  • Radio Group

    Radio Group

  • Avatar

    Avatar

  • Checkbox

    Checkbox