Toggle Group

Provides a shared state to a series of toggle buttons.

Installation

npx love-ui@latest add toggle-group

Usage

import { Toggle, ToggleGroup } from "@/components/ui/toggle-group"
<ToggleGroup>
  <Toggle>Bold</Toggle>
  <Toggle>Italic</Toggle>
  <Toggle>Underline</Toggle>
</ToggleGroup>

Examples

Small Toggles

Large Toggles

With Outline Toggles

With Outline and Separator

Disabled

With Disabled Toggle

Multiple selection

With Tooltips

Comparing with Radix / shadcn

If you’re already familiar with Radix UI and shadcn/ui, this guide highlights the small differences and similarities so you can get started with loveui quickly.

Prop Mapping

ComponentRadix UI PropBase UI Prop
ToggleGrouptype (enum, "single" or "multiple")multiple (boolean, default: false)

Quick Checklist

  • Replace type="multiple"multiple on ToggleGroup
  • Remove type="single" from ToggleGroup
  • Always use arrays for defaultValue
  • Use Toggle going forward; ToggleGroupItem remains for legacy

Additional Notes

loveui toggle group sizes are more compact compared to shadcn/ui, making them better suited for dense applications:

SizeHeight (shadcn/ui)Height (loveui)
sm32px28px
default36px32px
lg-36px

So, for example, if you were using the default size in shadcn/ui and you want to preserve the original height, you should use the lg size in loveui.

Comparison Examples

shadcn/ui
<ToggleGroup type="multiple" defaultValue={["bold"]}>
  <ToggleGroupItem value="bold">B</ToggleGroupItem>
  <ToggleGroupItem value="italic">I</ToggleGroupItem>
  <ToggleGroupItem value="underline">U</ToggleGroupItem>
</ToggleGroup>
loveui
<ToggleGroup multiple defaultValue={["bold"]}>
  <Toggle value="bold">B</Toggle>
  <Toggle value="italic">I</Toggle>
  <Toggle value="underline">U</Toggle>
</ToggleGroup>