# Geist Button Group

Joins related buttons into one control.

Build a Button 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 primitives if it has none.

Fidelity: Partly measured from Geist's Split Button. No reference has been captured yet.

## Tokens

None.

## 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-button-group {
    display: inline-flex;
    align-items: stretch;

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

    & > .ui-button {
      position: relative;

      &:focus-visible {
        z-index: 1;
      }
    }

    &[data-orientation="horizontal"] > .ui-button {
      &:not(:first-child) {
        margin-left: 1px;
        border-top-left-radius: 0;
        border-bottom-left-radius: 0;
      }

      &:not(:last-child) {
        border-top-right-radius: 0;
        border-bottom-right-radius: 0;
      }
    }

    &[data-orientation="vertical"] > .ui-button {
      &:not(:first-child) {
        margin-top: 1px;
        border-top-left-radius: 0;
        border-top-right-radius: 0;
      }

      &:not(:last-child) {
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
      }
    }
  }
}
```

## Structure

How Replicas assembles it on Base UI.

```tsx
import type { ComponentProps } from "react";
import { join } from "./utils";

export type ButtonGroupProps = ComponentProps<"div"> & {
  orientation?: "horizontal" | "vertical";
  variant?: string;
};

export function ButtonGroup({ className, orientation = "horizontal", variant, ...props }: ButtonGroupProps) {
  return (
    <div
      role="group"
      className={join("ui-button-group", className)}
      data-orientation={orientation}
      data-variant={variant}
      {...props}
    />
  );
}
```

## Example

```tsx
import { Button, ButtonGroup } from "@replicas/ui";

export default function ButtonGroupDemo() {
  return (
    <ButtonGroup>
      <Button>Previous</Button>
      <Button>Today</Button>
      <Button>Next</Button>
    </ButtonGroup>
  );
}
```

## Foundations

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