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
| Prop | Type | Default | Description |
|---|---|---|---|
options | { value: string; label?: string; icon?: ReactNode }[] | - | Toggle options |
value | string | string[] | - | Current selected value(s) |
onValueChange | (value: string | string[]) => void | - | Callback when selection changes |
multiple | boolean | false | Allow multiple selections |
className | string | - | 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

