Command Palette

Search for a command to run...

Docs
Button Toggle Group

Button Toggle Group

A toggle group component for single or multiple selections.

Installation

Usage

import { useState } from "react";
import ButtonToggleGroup from "@/components/ruixen/button-toggle-group";
import { AlignLeft, AlignCenter, AlignRight } from "lucide-react";
 
const options = [
  { value: "left", icon: <AlignLeft className="size-4" /> },
  { value: "center", icon: <AlignCenter className="size-4" /> },
  { value: "right", icon: <AlignRight className="size-4" /> },
];
 
export default function MyComponent() {
  const [alignment, setAlignment] = useState("left");
 
  return (
    <ButtonToggleGroup
      options={options}
      value={alignment}
      onValueChange={setAlignment}
    />
  );
}

Props

PropTypeDefaultDescription
options{ value: string; label?: string; icon?: ReactNode }[]-Toggle options
valuestring | string[]-Current selected value(s)
onValueChange(value: string | string[]) => void-Callback when selection changes
multiplebooleanfalseAllow multiple selections
classNamestring-Additional CSS classes

Features

  • Single or multiple selection mode
  • Support for icons and/or labels
  • Active state highlighting
  • Grouped button appearance
  • Light and dark mode support