# Linear Text

Body copy, headings and captions in the style's type scale.

Build a Text in this project that looks and behaves like Linear's. Measured from the running Linear app (linear.app). 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: Measured from Linear's issue title, description and settings headings.

## Variants

- `variant`: `mini`, `small`, `small-plus`, `regular`, `large`, `title3`, `title2`, `title1`
- `tone`: `title`, `base`, `muted`, `faint`

## Tokens

| Token | Light | Dark |
| --- | --- | --- |
| `--text-primary` | `lch(9.794% 0 282)` | `lch(100% 0 272)` |
| `--text-secondary` | `lch(19.588% 1.25 282)` | `lch(90.451% 1.2 272)` |
| `--text-tertiary` | `lch(39.176% 1.25 282)` | `lch(61.803% 1.2 272)` |
| `--text-quaternary` | `lch(64.64% 1.25 282)` | `lch(36.975% 1.2 272)` |
| `--font-size-mini` | `0.75rem` | `0.75rem` |
| `--font-size-small` | `0.8125rem` | `0.8125rem` |
| `--font-size-regular` | `0.9375rem` | `0.9375rem` |
| `--font-size-large` | `1.125rem` | `1.125rem` |
| `--font-size-title3` | `1.25rem` | `1.25rem` |
| `--font-size-title2` | `1.5rem` | `1.5rem` |
| `--font-size-title1` | `2.25rem` | `2.25rem` |
| `--font-weight-normal` | `450` | `450` |
| `--font-weight-medium` | `500` | `500` |
| `--font-weight-semibold` | `600` | `600` |

## CSS

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

```css
[data-style="linear"] {
  .ui-text {
    margin: 0;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: var(--font-size-small);
    font-weight: var(--font-weight-normal);
    line-height: 1.5;
  }

  .ui-text[data-variant="mini"] {
    font-size: var(--font-size-mini);
  }

  .ui-text[data-variant="small"] {
    font-size: var(--font-size-small);
  }

  .ui-text[data-variant="small-plus"] {
    font-size: var(--font-size-small);
    font-weight: var(--font-weight-medium);
  }

  .ui-text:is([data-variant="regular"], [data-variant="body"]) {
    letter-spacing: -0.1px;
  }

  .ui-text[data-variant="regular"] {
    font-size: var(--font-size-regular);
    line-height: 24px;
  }

  .ui-text[data-variant="large"] {
    font-size: var(--font-size-large);
    font-weight: var(--font-weight-medium);
    line-height: 1.4;
  }

  .ui-text:is(
      [data-variant="title3"],
      [data-variant="title2"],
      [data-variant="title1"],
      [data-variant="heading"],
      [data-variant="large"]
    ) {
    color: var(--text-primary);
  }

  .ui-text[data-variant="title3"] {
    font-size: var(--font-size-title3);
    font-weight: var(--font-weight-semibold);
    line-height: 28px;
    letter-spacing: -0.12px;
  }

  .ui-text[data-variant="title2"] {
    font-size: var(--font-size-title2);
    font-weight: var(--font-weight-semibold);
    line-height: 1.6;
    letter-spacing: -0.1px;
    font-feature-settings: "calt";
    font-variation-settings: "opsz" 32;
  }

  .ui-text[data-variant="title1"] {
    font-size: var(--font-size-title1);
    font-weight: var(--font-weight-semibold);
    line-height: 1.2;
    letter-spacing: -0.4px;
  }

  .ui-text[data-variant="heading"] {
    font-size: var(--font-size-regular);
    font-weight: var(--font-weight-medium);
    line-height: 23px;
  }

  .ui-text[data-tone="title"] {
    color: var(--text-primary);
  }

  .ui-text[data-tone="base"] {
    color: var(--text-secondary);
  }

  .ui-text:is([data-tone="muted"], [data-tone="secondary"]) {
    color: var(--text-tertiary);
  }

  .ui-text:is([data-tone="faint"], [data-tone="tertiary"]) {
    color: var(--text-quaternary);
  }
}
```

## Structure

How Replicas assembles it on Base UI.

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

export type TextProps = ComponentProps<"p"> & {
  as?: ElementType;
  variant?: string;
  tone?: string;
};

export function Text({ as: Element = "p", className, variant = "body", tone, ...props }: TextProps) {
  return <Element className={join("ui-text", className)} data-variant={variant} data-tone={tone} {...props} />;
}
```

## Example

```tsx
import { Text } from "@replicas/ui";

export default function TextDemo() {
  return (
    <div style={{ display: "flex", flexDirection: "column", gap: 8, maxWidth: 420 }}>
      <Text variant="heading">Getting started</Text>
      <Text>Invite your team, upload a few files and create your first project.</Text>
      <Text tone="secondary">Takes about five minutes</Text>
    </div>
  );
}
```

## Foundations

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