# Writing

Voice, labels and capitalisation: the words on buttons, in dialogs and in messages, written the way a person would say them.

API [Button](/ui/storybook/?path=/docs/ui-primitives-button--docs) [ConfirmDialog](/ui/storybook/?path=/docs/ui-confirmdialog--docs) [Toaster](/ui/storybook/?path=/docs/ui-primitives-toaster--docs) [LoadFailure](/ui/storybook/?path=/docs/ui-loadfailure--docs) [LoadMoreFooter](/ui/storybook/?path=/docs/ui-loadmorefooter--docs) [Switch](/ui/storybook/?path=/docs/ui-primitives-switch--docs) [Label](/ui/storybook/?path=/docs/ui-primitives-label--docs) [Tabs](/ui/storybook/?path=/docs/ui-primitives-tabs--docs) [Table](/ui/storybook/?path=/docs/ui-primitives-table--docs) [Textarea](/ui/storybook/?path=/docs/ui-primitives-textarea--docs) [InfoPopover](/ui/storybook/?path=/docs/ui-primitives-infopopover--docs) [FieldDescription](/ui/storybook/?path=/docs/ui-primitives-fielddescription--docs) [Timestamp](/ui/storybook/?path=/docs/ui-primitives-timestamp--docs)

> **Write what a person would say out loud: short, specific, in sentence case, and naming what happens.**

```tsx
import { type AccessToken, TOKENS } from "@orz/fixtures/account.ts";
import { Button } from "@orz/ui/components/button";
import { ConfirmDialog } from "@orz/ui/components/confirm-dialog";
import { EmptyState } from "@orz/ui/components/empty-state";
import { List, ListItem } from "@orz/ui/components/list";
import { KeyRoundIcon } from "lucide-react";
import { useState } from "react";
import { toast } from "sonner";

export function RevokeToken() {
  const [tokens, setTokens] = useState(TOKENS);
  const [revoking, setRevoking] = useState<AccessToken>();
  // Kept apart from `revoking` so the dialog keeps its title while it fades out.
  const [open, setOpen] = useState(false);
  return (
    <div>
      {tokens.length === 0 ? (
        <EmptyState title="No access tokens" className="py-3">
          Scripts and bots that need one get it from the command line.
        </EmptyState>
      ) : (
        <List purpose="collection">
          <ul>
            {tokens.map((token) => (
              <ListItem key={token.id} asChild>
                <li className="flex min-h-row items-center gap-3 py-3">
                  <KeyRoundIcon className="size-4 shrink-0 text-muted-foreground" />
                  <div className="grid min-w-0 flex-1 gap-0.5">
                    <span className="truncate font-medium font-mono text-ui">
                      {token.name}
                    </span>
                    <span className="text-muted-foreground text-ui-sm">
                      {token.scopes} · {token.lastUsed}
                    </span>
                  </div>
                  <Button
                    variant="destructive"
                    aria-label={`Revoke ${token.name}`}
                    onClick={() => {
                      setRevoking(token);
                      setOpen(true);
                    }}
                  >
                    Revoke…
                  </Button>
                </li>
              </ListItem>
            ))}
          </ul>
        </List>
      )}
      <ConfirmDialog
        open={open}
        onOpenChange={setOpen}
        destructive
        title={`Revoke the token for ${revoking?.name}?`}
        description="Anything that signs in with it stops working at once. A revoked token cannot be restored: you would create a new one and update everything that used the old."
        confirmLabel="Revoke"
        onConfirm={() => {
          setTokens((now) => now.filter((each) => each !== revoking));
          setOpen(false);
          toast(`Revoked the token for ${revoking?.name}`);
        }}
      />
    </div>
  );
}
```

Each **Revoke…** button names the action and ends in an ellipsis because it asks before it acts. The dialog's title is the question, its description says what stops working and that there is no way back, and the button that answers it repeats the verb. The toast afterwards says what happened, to what. Revoke all three for the empty state, which says what would be here and how it gets here.

## Voice

The people using these tools are in the middle of something else. Words that get out of their way read as plain, calm and exact.

- **Plain.** The everyday word over the technical one, unless the reader's own job uses the technical one: a CI tool says *run* and *artifact*, not *execution* and *output object*.
- **Calm.** No exclamation marks, no jokes in an error, no "Oops". A failure is reported, not performed.
- **About the thing, not about the app.** The app does not say *I* or *we*, and it does not thank the reader for waiting. "Conversation archived", not "We've successfully archived your conversation!".
- **Never blaming.** Say what is wrong with the input and how to fix it, not that the reader got it wrong: "Enter an email address, like <alice@example.com>.", not "You entered an invalid email".
- **The same word for the same thing.** If it is a *conversation* in the list, it is a *conversation* in the toast and the empty state, never a *thread* or an *email*.

## Labels

A label is the shortest phrase that says what a control does. Buttons and menu items start with a verb; the rest name the setting or the thing.

**Do**

Answer a dialog with the verb its title asks about, and keep **Cancel** for the way out.

**Don't**

Answer with **Yes**, **No** or **OK**. The reader has to go back to the title to find out what they agreed to.

- **Verb, then object** on a button or menu item: "Save profile", "Mark as unread", "Copy link". Drop the object only when the surface already names it: a dialog titled "Revoke the token for ci-runner?" can end in "Revoke".
- **An ellipsis (…) when the control asks for more before it acts**: it opens a dialog, a picker or a form ("Revoke…", the theme menu's "Custom themes…"). Not on a control that just opens a view, and not on the confirming button inside the dialog.
- **A toggle names its on state.** A `Switch` or `Checkbox` says what is true when it is on: "Wrap long lines", never "Don't wrap long lines". A negative label makes off a double negative.
- **An icon-only button still has a label**, as its `aria-label`, and shows it in a tooltip. See [Accessibility](/ui/guidelines/content/accessibility/index.md#names-and-roles).

**Do**

Name what is true when the switch is on.

**Don't**

Name the off state, so that turning it on turns something off.

## Explanations

The screen already says most of what a sentence would: the label names the setting, the switch shows its state, and a missing Save button says that changes apply at once. Write only what it cannot show, and put that behind an `InfoPopover`.

**Do**

Put what a setting does behind an (i) right after its label, where a mouse, a thumb and the keys all open it.

**Don't**

Run a grey line under every label, or a subtitle that says what the controls already show. The reader learns to skip them, and skips the one that mattered.

| Words                                                                                                                                     | Where                                               |
| ----------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------- |
| What a setting, an option or a section does, or why it is there                                                                           | Behind an (i), when the label alone does not say it |
| What the screen already shows: the heading again, "Changes apply at once" over switches, "Saved when you press Save" beside a Save button | Nowhere                                             |
| A limit the reader needs while typing: a format, a length                                                                                 | Under the field, as a `FieldDescription`            |
| What is wrong with a field                                                                                                                | Under the field, as a `FieldError`                  |
| Empty, failed, done                                                                                                                       | On screen, as the message (see **Messages** below)  |
| What a confirmation's action does, and that it cannot be undone                                                                           | In the dialog's description                         |

- **One (i) per thing explained**, right after its label or title, never at the far end of the row, where the row's own control sits.
- **Name it** when a view holds more than one: `label="About format on save"`, so a screen reader tells them apart. A lone one may keep its default, "More information".
- **A sentence or two.** It may end in a link to where the subject is told in full; anything longer is a page of its own.
- **Never the only copy of what the task needs.** A required format, a consequence that cannot be undone: those stay on screen.

## Capitalisation

**Sentence case everywhere**: capitalise the first word and proper nouns, and nothing else. That includes titles, buttons, menu items, tabs and column headers — "Terminal theme", "Exit fullscreen", "Load more", as @orz/ui's own labels are written. Product and brand names keep their own spelling: GitHub, Storybook, npm.

This differs from both sources: Apple's HIG puts macOS buttons and menu items in title case, and GNOME's capitalises headers. One rule for every surface is easier to keep than a table of which surface gets which, and sentence case reads as speech, which title case does not.

| Text                                               | Case     | Ends with                             | Example                             |
| -------------------------------------------------- | -------- | ------------------------------------- | ----------------------------------- |
| Title of a page, a dialog or an empty state        | Sentence | Nothing, or `?` when it asks          | Revoke the token for ci-runner?     |
| Button, menu item, tab                             | Sentence | Nothing, or `…` when it asks for more | Custom themes…                      |
| Field label, setting, column header                | Sentence | Nothing; no colon                     | Terminal theme                      |
| Description, help, message of one sentence or more | Sentence | A full stop                           | A revoked token cannot be restored. |
| Toast                                              | Sentence | Nothing                               | Conversation archived               |
| Placeholder                                        | Sentence | `…` when it asks to be typed into     | Leave a comment in markdown…        |

```tsx
import { CI_RUN } from "@orz/fixtures/ci-run.ts";
import { Button } from "@orz/ui/components/button";
import { FrameBar } from "@orz/ui/components/frame";
import {
  GroupDescription,
  GroupHeading,
} from "@orz/ui/components/group-heading";
import { Label } from "@orz/ui/components/label";
import {
  Table,
  TableBody,
  TableCell,
  TableHead,
  TableHeader,
  TableRow,
} from "@orz/ui/components/table";
import {
  Tabs,
  TabsContent,
  TabsList,
  TabsTrigger,
} from "@orz/ui/components/tabs";
import { Textarea } from "@orz/ui/components/textarea";
import { useState } from "react";

export function PullRequestChecks() {
  const [comment, setComment] = useState("");
  return (
    <Tabs variant="framed" defaultValue="checks">
      <FrameBar>
        <TabsList>
          <TabsTrigger value="conversation">Conversation</TabsTrigger>
          <TabsTrigger value="checks">Checks</TabsTrigger>
        </TabsList>
      </FrameBar>
      <TabsContent value="conversation" className="p-3">
        <form
          className="grid gap-2"
          onSubmit={(event) => {
            event.preventDefault();
            setComment("");
          }}
        >
          <Label htmlFor="writing-comment">Comment</Label>
          <Textarea
            id="writing-comment"
            placeholder="Leave a comment in markdown…"
            value={comment}
            onChange={(event) => setComment(event.target.value)}
          />
          <Button
            type="submit"
            className="justify-self-end"
            disabled={comment.trim() === ""}
          >
            Comment
          </Button>
        </form>
      </TabsContent>
      <TabsContent value="checks" className="grid gap-3 p-3">
        <div>
          <GroupHeading asChild>
            <h3>Some checks were not successful</h3>
          </GroupHeading>
          <GroupDescription>
            Merging is blocked until every check passes.
          </GroupDescription>
        </div>
        <Table>
          <TableHeader>
            <TableRow>
              <TableHead>Check</TableHead>
              <TableHead>Status</TableHead>
              <TableHead className="text-right">Duration</TableHead>
            </TableRow>
          </TableHeader>
          <TableBody>
            {CI_RUN.jobs.map((job) => (
              <TableRow key={job.id}>
                <TableCell>
                  {CI_RUN.workflow} / {job.name}
                </TableCell>
                <TableCell>
                  {job.status === "failed" ? "Failed" : "Passed"}
                </TableCell>
                <TableCell className="text-right tabular-nums">
                  {job.duration}s
                </TableCell>
              </TableRow>
            ))}
          </TableBody>
        </Table>
      </TabsContent>
    </Tabs>
  );
}
```

The pull request's tabs, the checks' title, its explanation and the table's column headers are sentence case; only the explanation is a sentence, so only it ends in a full stop. Under **Conversation**, the field's label has no colon and the placeholder ends in `…`, because it asks to be typed into.

## Messages

Loading, empty, failed and done each look different and say so. A message says what happened and, when the reader can do something about it, what that is.

- **Done**: a toast in the past tense, naming the object: "Conversation archived", "3 conversations archived". No "successfully": a toast that appears has already said that.
- **Loading**: say what is loading when it takes more than a moment ("Loading conversations…"); a skeleton needs no words.
- **Empty**: say what would be here and how it gets here: "No access tokens. Scripts and bots that need one get it from the command line."
- **Failed**: what failed, in the reader's terms, then the way out. `LoadFailure` takes the message, the raw error as its `detail` (shown on hover, not in the sentence) and a Retry; `RefreshFailure` and `LoadMoreFooter` write their own sentence and keep the raw error out of it the same way. Never show a stack trace or an HTTP status as the message.

## Spelling, numbers and symbols

- **One spelling per app.** @orz/ui's own labels use British spelling ("Find a colour"); its code uses American, as CSS does (`color`). An app may pick either, and then holds to it.
- **Numerals for numbers**, "3 conversations", not "three conversations", and the plural that matches: "1 conversation", "2 conversations". Build the plural with `Intl.PluralRules` rather than writing "conversation(s)".
- **The right character, where it has a job**: `…` for an ellipsis, `–` for a range ("10–20"), `×` for dimensions ("44 × 44"), `—` between two halves of a sentence.
- **Dates and times** with `Timestamp` and `TimestampRange`, in the reader's language and time zone; see below.

## Dates and times

```tsx
import { CI_RUN } from "@orz/fixtures/ci-run.ts";
import { Button } from "@orz/ui/components/button";
import { Timestamp } from "@orz/ui/components/timestamp";
import { RefreshCwIcon } from "lucide-react";
import { useState } from "react";

const LOGS_KEPT_UNTIL = new Date(
  Date.parse(CI_RUN.startedAt) + 90 * 24 * 60 * 60 * 1000,
).toISOString();

export function RunTimes() {
  const [refreshed, setRefreshed] = useState(CI_RUN.startedAt);
  return (
    <dl className="grid w-fit grid-cols-[auto_auto] items-center gap-x-6 gap-y-2 text-ui">
      <dt className="text-muted-foreground">Started</dt>
      <dd>
        <Timestamp value={CI_RUN.startedAt} />
      </dd>
      <dt className="text-muted-foreground">Logs kept until</dt>
      <dd>
        <Timestamp value={LOGS_KEPT_UNTIL} format="date" />
      </dd>
      <dt className="text-muted-foreground">Checks refreshed</dt>
      <dd className="flex items-center gap-2">
        <Timestamp value={refreshed} format="relative" />
        <Button
          variant="outline"
          size="sm"
          onClick={() => setRefreshed(new Date().toISOString())}
        >
          <RefreshCwIcon />
          Refresh
        </Button>
      </dd>
    </dl>
  );
}
```

A run from the Pull request demo. When it started is a time to set beside its log, so it takes the date and the time; how long its logs are kept needs only the day. Press **Refresh**: the checks were refreshed "now", and the words keep up as the minutes pass.

`Timestamp` writes one instant, in the reader's language and time zone, and puts the whole of it, to the second and with the zone, in its `title`.

- `datetime`, the default, for when something happened: a comment's header, an event on a timeline, a task's **Updated** field.
- `date` where the day is all that counts: when someone joined, when a file went to the trash.
- `time` where the day is already written beside it: a chart's axis over the last day, the rows under a day's heading. The same day again on every row only makes the rows longer.
- `relative` where how fresh something is matters more than when: a list sorted by activity, the last refresh or sync. It keeps itself current while it is on screen, and past a week it writes the date.
- `datetime` and `date` leave the year out within the reader's current year and write it for any other, so this year's dates stay short and an old one cannot pass for this year's.
- One kind of time takes one format on every screen of an app: a comment's time is not `datetime` in the timeline and `relative` in the inbox.
- A relative time never stands alone where the exact time matters. Its `title` holds the time, and a title shows on hover, never under a finger.

`TimestampRange` writes a span from one instant to another, as `datetime` or `date`, and writes what both ends share once: an hour on one day reads "Nov 27, 6:00 – 7:00 PM", where two `Timestamp`s with a dash between them write the day twice. It leaves the year out when both ends are in the reader's current year. Its `end` is the instant the span stops, outside it, as a server sends a chart's bucket: a week from Monday ends at the next Monday's midnight, and `date` writes it as ending on Sunday. Pass the span as it came, whichever format writes it.

Do not format a date or a span by hand, with `toLocaleString()` or a format string of your own: each one writes a different shape, in a different zone. A place that takes a string, such as a chart's labels drawn in SVG or an `aria-label`, takes the same text from `formatTimestamp` and `formatTimestampRange`.

## On each platform

The same words are read with a mouse and with a thumb, so they name what happens, not the gesture that makes it happen.

|              | Pointer                                                 | Touch                                                       |
| ------------ | ------------------------------------------------------- | ----------------------------------------------------------- |
| Instructions | "Select a conversation", "Open the menu"; never "Click" | The same words; never "Tap"                                 |
| Tooltips     | Repeat a label or add a shortcut                        | Do not appear, so they never hold the only copy of anything |
| Shortcuts    | May appear in a tooltip or menu item                    | Left out; there is no keyboard to press them on             |
| Length       | A label can be longer where the layout is wide          | Write the label to fit a 390px screen first                 |

## In the demos

- [Settings](/ui/demos/settings/index.md): Each Switch names its on state (Wrap long lines), buttons are a verb and its object (Save profile), and a button that opens a dialog first ends in an ellipsis (Revoke…).
- [Sign in](/ui/demos/sign-in/index.md): Each error says how to put it right, Enter an email address, like alice\@example.com. Buttons are a verb and its object, Send code or Save password, and a saved password is said in a toast, Password changed.
- [Mail](/ui/demos/mail/index.md): Toasts name the thing and what happened (“3 conversations archived”), each empty folder says what would be in it, and Delete forever… asks with the count.
