Cnippet

Toggle Group

Buttons 1

About

A set of toggle buttons that work together as a single control, built on Base UI's ToggleGroup primitive. Supports single or multiple selection, horizontal and vertical orientation, default and outline variants with three sizes, and an optional ToggleGroupSeparator between items. The Toggle and Separator primitives are inlined so the component ships as a single self-contained file.

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

Code

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

Usage.tsx

import { MonitorIcon, MoonIcon, SunIcon } from "lucide-react";
import {
  ToggleGroup,
  ToggleGroupItem,
} from "@/components/ui/cnippet-toggle-group";

export default function ToggleGroupTheme() {
  return (
    <ToggleGroup defaultValue={["light"]} variant="outline">
      <ToggleGroupItem aria-label="Light theme" value="light">
        <SunIcon />
      </ToggleGroupItem>
      <ToggleGroupItem aria-label="Dark theme" value="dark">
        <MoonIcon />
      </ToggleGroupItem>
      <ToggleGroupItem aria-label="System theme" value="system">
        <MonitorIcon />
      </ToggleGroupItem>
    </ToggleGroup>
  );
}

Dependencies

More by Cnippet

View all
  • Team

    Team

    1.4K
  • Davincho Hero-1

    Davincho Hero-1

    716
  • Aero Hero-3

    Aero Hero-3

    633
  • Random Letter Swap Navigation

    Random Letter Swap Navigation

    586
  • Features

    Features

    539
  • Services with Animated Hover Modal

    Services with Animated Hover Modal

    492
  • Blogs

    Blogs

    406
  • Aero Hero-1

    Aero Hero-1

    387

More in Buttons

View all
  • Button

    Button

    20
  • Button

    Button

    3
  • Button Group

    Button Group

    18
  • Button

    Button

    149
  • Icon Label Subtext Button

    Icon Label Subtext Button

    69
  • Button

    Button

    9
  • Button

    Button

    37
  • Texture Button

    Texture Button

    113