import { Toggle, ToggleGroup } from "@replicas/ui";

export default function ToggleGroupDemo() {
  return (
    <>
      <ToggleGroup defaultValue={["list"]} aria-label="Layout">
        <Toggle size="small" value="list">
          List
        </Toggle>
        <Toggle size="small" value="grid">
          Grid
        </Toggle>
        <Toggle size="small" value="calendar">
          Calendar
        </Toggle>
      </ToggleGroup>
      <ToggleGroup multiple defaultValue={["bold"]} aria-label="Formatting">
        <Toggle size="small" value="bold">
          Bold
        </Toggle>
        <Toggle size="small" value="italic">
          Italic
        </Toggle>
        <Toggle size="small" value="underline">
          Underline
        </Toggle>
        <Toggle size="small" value="strikethrough">
          Strikethrough
        </Toggle>
      </ToggleGroup>
    </>
  );
}

Examples

Sizes

<ToggleGroup size="small" defaultValue={["list"]}>
  <Toggle value="list">List</Toggle>
  <Toggle value="board">Board</Toggle>
</ToggleGroup>
<ToggleGroup size="medium" defaultValue={["list"]}>
  <Toggle value="list">List</Toggle>
  <Toggle value="board">Board</Toggle>
</ToggleGroup>
<ToggleGroup size="large" defaultValue={["list"]}>
  <Toggle value="list">List</Toggle>
  <Toggle value="board">Board</Toggle>
</ToggleGroup>

Prompt

Copy Prompt hands your agent everything it needs to build the Toggle Group in the Geist style: the measured tokens, the CSS and the structure.

Show Prompt
# Geist Toggle Group

Provides a shared state to a series of toggle buttons.

Build a Toggle Group in this project that looks and behaves like Geist's. Measured from the running Geist app (vercel.com/geist). Keep every value exact. Map the tokens onto the project's own theme variables instead of hard-coding them. Use the project's own component library for behaviour, or [Base UI](https://base-ui.com/react/components/toggle-group) if it has none.

Fidelity: Partly measured from Geist's Switch, its segmented control. The dark checked colour comes from Geist's tokens, not the component. No reference has been captured yet.

## Variants

- `size`: `small`, `medium`, `large`

## Tokens

| Token | Light | Dark |
| --- | --- | --- |
| `--ds-background-100` | `hsl(0 0% 100%)` | `hsl(0 0% 4%)` |
| `--ds-gray-alpha-400` | `#00000014` | `#ffffff24` |
| `--font-size-regular` | `1rem` | `1rem` |
| `--radius-control` | `6px` | `6px` |
| `--radius-kbd` | `4px` | `4px` |

## CSS

Scoped under `[data-style="geist"]`; dark rules sit under `[data-theme="dark"]`. The `ui-*` classes and data attributes match the structure below.

```css
[data-style="geist"] {
  .ui-toggle-group-group {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    gap: 0;
    padding: 4px;
    border-radius: var(--radius-control);
    background-color: var(--ds-background-100);
    box-shadow: 0 0 0 1px var(--ds-gray-alpha-400);

    & > .ui-toggle {
      border-radius: var(--radius-kbd);
    }

    &[data-orientation="vertical"] {
      flex-direction: column;
      align-items: stretch;
    }

    &[data-disabled] {
      cursor: not-allowed;
    }

    &[data-size="small"] > .ui-toggle {
      height: 24px;
      min-width: 24px;
      padding: 0 12px;
    }

    &[data-size="medium"] > .ui-toggle {
      height: 28px;
      min-width: 28px;
      padding: 0 12px;
    }

    &[data-size="large"] {
      border-radius: 8px;

      & > .ui-toggle {
        height: 32px;
        min-width: 32px;
        padding: 0 16px;
        border-radius: var(--radius-control);
        font-size: var(--font-size-regular);
        line-height: 24px;
      }
    }

    @media (hover: hover) {
      & > [aria-pressed]:not([data-pressed]):hover {
        background-color: transparent;
      }
    }
  }
}
```

## Structure

How Replicas assembles it on Base UI.

```tsx
import { ToggleGroup as BaseToggleGroup } from "@base-ui/react/toggle-group";
import { join } from "./utils";

export function ToggleGroup({
  className,
  variant,
  size,
  ...props
}: Omit<BaseToggleGroup.Props, "className"> & { className?: string; variant?: string; size?: string }) {
  return (
    <BaseToggleGroup
      className={join("ui-toggle-group-group", className)}
      data-variant={variant}
      data-size={size}
      {...props}
    />
  );
}
```

## Example

```tsx
import { Toggle, ToggleGroup } from "@replicas/ui";

export default function ToggleGroupDemo() {
  return (
    <>
      <ToggleGroup defaultValue={["list"]} aria-label="Layout">
        <Toggle size="small" value="list">
          List
        </Toggle>
        <Toggle size="small" value="grid">
          Grid
        </Toggle>
        <Toggle size="small" value="calendar">
          Calendar
        </Toggle>
      </ToggleGroup>
      <ToggleGroup multiple defaultValue={["bold"]} aria-label="Formatting">
        <Toggle size="small" value="bold">
          Bold
        </Toggle>
        <Toggle size="small" value="italic">
          Italic
        </Toggle>
        <Toggle size="small" value="underline">
          Underline
        </Toggle>
        <Toggle size="small" value="strikethrough">
          Strikethrough
        </Toggle>
      </ToggleGroup>
    </>
  );
}
```

## Foundations

The rest of the Geist style, as a skill: https://replicas.raphaelsalaja.com/skills/geist/SKILL.md