Components
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.
npx @21st-dev/cli add cnippet.dev/cnippet-toggleLoading preview...
import { BoldIcon, ItalicIcon } from "lucide-react";
import { Toggle } from "@/components/ui/cnippet-toggle";
export default function ToggleWithText() {
return (
<div className="flex flex-wrap items-center justify-center gap-2">
<Toggle aria-label="Toggle italic" variant="outline">
<ItalicIcon />
Italic
</Toggle>
<Toggle aria-label="Toggle bold" variant="outline">
<BoldIcon />
Bold
</Toggle>
</div>
);
}
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...