# Geist Label

A caption for a form control.

Build a Label 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 Label. No reference has been captured yet.

## Tokens

| Token | Light | Dark |
| --- | --- | --- |
| `--ds-gray-700` | `hsl(0 0% 56%)` | `hsl(0 0% 56%)` |
| `--ds-gray-900` | `hsl(0 0% 30%)` | `hsl(0 0% 63%)` |
| `--ds-red-900` | `oklch(54.99% 0.232 25.29)` | `oklch(69.96% 0.2136 22.03)` |
| `--font-size-mini` | `0.8125rem` | `0.8125rem` |
| `--font-weight-normal` | `400` | `400` |

## 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-label {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    color: var(--ds-gray-900);
    font-size: var(--font-size-mini);
    font-weight: var(--font-weight-normal);
    line-height: 19.5px;
    cursor: default;
  }

  .ui-label-required {
    color: var(--ds-red-900);
  }

  .ui-label-optional {
    color: var(--ds-gray-700);
  }
}
```

## Structure

How Replicas assembles it on Base UI.

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

export type LabelProps = ComponentProps<"label"> & {
  size?: string;
  required?: boolean;
  optional?: boolean;
};

export function Label({ className, size, required = false, optional = false, children, ...props }: LabelProps) {
  return (
    <label className={join("ui-label", className)} data-size={size} {...props}>
      {children}
      {required ? (
        <span className="ui-label-required" aria-hidden>
          *
        </span>
      ) : null}
      {optional ? <span className="ui-label-optional">Optional</span> : null}
    </label>
  );
}
```

## Example

```tsx
import { Input, Label } from "@replicas/ui";

export default function LabelDemo() {
  return (
    <div style={{ display: "flex", flexDirection: "column", gap: 6, width: 260 }}>
      <Label htmlFor="label-demo">Project name</Label>
      <Input id="label-demo" placeholder="Mobile App" />
    </div>
  );
}
```

## Foundations

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