Cnippet

Toggle

Buttons

About

A two-state toggle button built on Base UI's Toggle primitive. Ships default and outline variants, three sizes (sm, default, lg), controlled or uncontrolled pressed state via pressed / defaultPressed, disabled styling, and springy pressed feedback. Works as a single button or grouped into a formatting toolbar. Re-exports TogglePrimitive for advanced composition.

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/cnippet-toggle";

export default function ToggleSizes() {
  return (
    <div className="flex flex-wrap items-center justify-center gap-2">
      <Toggle aria-label="Small toggle" size="sm" variant="outline">
        Small
      </Toggle>
      <Toggle aria-label="Default toggle" size="default" variant="outline">
        Default
      </Toggle>
      <Toggle aria-label="Large toggle" size="lg" variant="outline">
        Large
      </Toggle>
    </div>
  );
}

Dependencies

More by Cnippet

View all
  • Team

    Team

    1.3K
  • Davincho Hero-1

    Davincho Hero-1

    692
  • Aero Hero-3

    Aero Hero-3

    590
  • Features

    Features

    519
  • Random Letter Swap Navigation

    Random Letter Swap Navigation

    513
  • Services with Animated Hover Modal

    Services with Animated Hover Modal

    472
  • Blogs

    Blogs

    398
  • Aero Hero-1

    Aero Hero-1

    366

More in Buttons

View all
  • Texture Button

    Texture Button

    101
  • Button

    Button

    5
  • Base Button

    Base Button

    1
  • App Store Button

    App Store Button

    469
  • Eclipse Button

    Eclipse Button

    3
  • Button

    Button

    5
  • Button Group

    Button Group

    15
  • Button

    Button

    53