HextaUI

Toggle group: Sizes

size on the group sets every item: sm, default or lg.

import { IconBold, IconItalic, IconUnderline } from "@tabler/icons-react"

import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"

export function ToggleGroupSizes() {
  return (
    <div className="flex flex-col items-center gap-4">
      {(["sm", "default", "lg"] as const).map((size) => (
        <ToggleGroup
          key={size}
          multiple
          size={size}
          variant="outline"
          aria-label={`Formatting, ${size}`}
          defaultValue={["bold"]}
        >
          <ToggleGroupItem value="bold" aria-label="Bold">
            <IconBold />
          </ToggleGroupItem>
          <ToggleGroupItem value="italic" aria-label="Italic">
            <IconItalic />
          </ToggleGroupItem>
          <ToggleGroupItem value="underline" aria-label="Underline">
            <IconUnderline />
          </ToggleGroupItem>
        </ToggleGroup>
      ))}
    </div>
  )
}

This adds the example as components/examples/toggle-group/sizes.tsx, together with the Toggle group component and the HextaUI theme tokens it needs.

pnpm dlx shadcn@latest add https://hextaui.com/r/toggle-group-sizes.json

To add only the component, follow the Toggle group installation.

Props in this example

The Toggle group props this example sets, from the API reference.

PropTypeDefault
defaultValue
string[]–
multiple
booleanfalse
variantSets every item's variant.
"default" | "outline""default"
sizeSets every item's size.
"default" | "sm" | "lg""default"
PropTypeDefault
valueIdentifies the item in the group's value.
string–

Every prop is in the Toggle group API reference.

See them all, with keyboard support and accessibility notes, on the Toggle group page.