# Icons

Lucide, at the size of the text beside it, in the colour of that text. An icon alone always carries a name.

API [Button](/ui/storybook/?path=/docs/ui-primitives-button--docs) [Tooltip](/ui/storybook/?path=/docs/ui-primitives-tooltip--docs) [DropdownMenu](/ui/storybook/?path=/docs/ui-primitives-dropdownmenu--docs) [Badge](/ui/storybook/?path=/docs/ui-primitives-badge--docs) [Avatar](/ui/storybook/?path=/docs/ui-primitives-avatar--docs)

**Draw icons from [Lucide](https://lucide.dev/icons/), let the component size them, and give every icon-only control an `aria-label`.** An icon is shorthand for a word; the word still has to be there for the people and tools that cannot see the picture.

```tsx
import { Button } from "@orz/ui/components/button";
import {
  DropdownMenu,
  DropdownMenuContent,
  DropdownMenuItem,
  DropdownMenuTrigger,
} from "@orz/ui/components/dropdown-menu";
import { Frame } from "@orz/ui/components/frame";
import { Pane } from "@orz/ui/components/pane";
import { Textarea } from "@orz/ui/components/textarea";
import { ToolbarButton } from "@orz/ui/components/toolbar";
import {
  Tooltip,
  TooltipContent,
  TooltipProvider,
  TooltipTrigger,
} from "@orz/ui/components/tooltip";
import {
  ArchiveIcon,
  EllipsisIcon,
  ForwardIcon,
  LinkIcon,
  MailIcon,
  SendIcon,
  Trash2Icon,
} from "lucide-react";
import { useState } from "react";
import { toast } from "sonner";

const ACTIONS = [
  { label: "Archive", Icon: ArchiveIcon },
  { label: "Delete", Icon: Trash2Icon },
  { label: "Mark as unread", Icon: MailIcon },
];

export function ThreadToolbar() {
  const [reply, setReply] = useState("");
  return (
    <TooltipProvider>
      <Frame asChild>
        <Pane purpose="panel" className="grid gap-3">
          <Pane
            purpose="toolbar"
            edge="bottom"
            className="flex items-center gap-0.5 px-1.5 py-1"
          >
            {ACTIONS.map(({ label, Icon }) => (
              <Tooltip key={label}>
                <TooltipTrigger asChild>
                  <ToolbarButton aria-label={label}>
                    <Icon />
                  </ToolbarButton>
                </TooltipTrigger>
                <TooltipContent>{label}</TooltipContent>
              </Tooltip>
            ))}
            <DropdownMenu>
              <Tooltip>
                <TooltipTrigger asChild>
                  <DropdownMenuTrigger asChild>
                    <ToolbarButton
                      className="ml-auto"
                      aria-label="More actions"
                    >
                      <EllipsisIcon />
                    </ToolbarButton>
                  </DropdownMenuTrigger>
                </TooltipTrigger>
                <TooltipContent>More actions</TooltipContent>
              </Tooltip>
              <DropdownMenuContent align="end" className="w-44">
                <DropdownMenuItem>
                  <ForwardIcon />
                  Forward
                </DropdownMenuItem>
                <DropdownMenuItem onSelect={() => toast("Link copied")}>
                  <LinkIcon />
                  Copy link
                </DropdownMenuItem>
              </DropdownMenuContent>
            </DropdownMenu>
          </Pane>
          <form
            aria-label="Reply"
            className="flex items-end gap-2 px-3 pb-3"
            onSubmit={(event) => {
              event.preventDefault();
              setReply("");
            }}
          >
            <Textarea
              aria-label="Reply"
              placeholder="Reply in markdown…"
              value={reply}
              onChange={(event) => setReply(event.target.value)}
              className="min-h-10 flex-1"
            />
            <Button type="submit" disabled={reply.trim() === ""}>
              <SendIcon data-icon="inline-start" />
              Send
            </Button>
          </form>
        </Pane>
      </Frame>
    </TooltipProvider>
  );
}
```

The Mail demo's toolbar over an open conversation, and its reply box. **Archive**, **Delete** and **Mark as unread** are icons alone, each named for a screen reader and shown its name in a tooltip on hover or focus: people use them all day, and Undo takes back a delete. **Send** keeps its word, because it is what the reply box is for. **More actions** needs no word anywhere, and the rarer actions behind it, **Forward** and **Copy link**, have theirs.

## One set

`lucide-react` is a peer dependency of `@orz/ui`, and every icon in the components comes from it. Draw your own from the same set, imported by name with the `Icon` suffix (`SearchIcon`, `ChevronDownIcon`), so a bundler keeps only those you use and every icon shares one stroke and one grid. An icon from another set, even a better one, looks foreign beside the rest.

## Size and colour

| Where                                    | Size                                                                                                   |
| ---------------------------------------- | ------------------------------------------------------------------------------------------------------ |
| In a `Button`, `Badge` or menu item      | Nothing to set: the component sizes it, 16px in a default or `lg` `Button`, 14px in `sm`, 12px in `xs` |
| Beside `text-ui`                         | `size-4` (16px)                                                                                        |
| Beside `text-ui-sm`                      | `size-3.5` or `size-3`                                                                                 |
| An empty state's or error's illustration | `size-8` to `size-10`, `text-muted-foreground`                                                         |

```tsx
import { INBOX_THREADS } from "@orz/fixtures/inbox.ts";
import { Badge } from "@orz/ui/components/badge";
import { Button } from "@orz/ui/components/button";
import { EmptyState } from "@orz/ui/components/empty-state";
import { Timestamp } from "@orz/ui/components/timestamp";
import { InboxIcon, SquarePenIcon, StarIcon, TagIcon } from "lucide-react";

const thread = INBOX_THREADS.find(({ id }) => id === "touch-sizes");

export function IconSizes() {
  return (
    <div className="grid gap-4 sm:grid-cols-2">
      <div className="grid content-start gap-3">
        <div className="flex flex-wrap items-center gap-2">
          <Button>
            <SquarePenIcon data-icon="inline-start" />
            Compose
          </Button>
          <Badge variant="outline">
            <TagIcon />
            design
          </Badge>
        </div>
        <p className="flex items-center gap-2 text-ui">
          <InboxIcon className="size-4 text-muted-foreground" />
          Inbox
        </p>
        <div className="grid gap-0.5">
          <p className="truncate text-ui">{thread?.subject}</p>
          <p className="flex items-center gap-1 text-muted-foreground text-ui-sm">
            <StarIcon aria-label="Starred" className="size-3 fill-current" />
            <Timestamp value="2026-10-27T10:50:00Z" format="date" />
          </p>
        </div>
      </div>
      <EmptyState
        icon={StarIcon}
        title="Nothing in Starred"
        className="content-center px-4 py-6"
      >
        Star a conversation to find it here later.
      </EmptyState>
    </div>
  );
}
```

Icons draw in `currentColor`, so they take the text colour around them. Set `text-muted-foreground` on an icon that is decoration beside a label; leave it alone on an icon that is the control.

An icon drawn on a field, as a search box's glass is, is placed with `top-sunken-centre` and `-translate-y-1/2`, not `top-1/2`: a field is a well, shaded under its top edge, and that puts the middle of its lit part, and of the words in it, below the middle of its box. The utility follows each style's well, so the icon lines up with the words in all of them.

In a `Button`, mark an icon before or after the label with `data-icon="inline-start"` or `"inline-end"`, and the button trims its padding on that side so the icon sits optically centred. Each `icon` size draws its icon as large as the text size of its height does, `icon-sm` at 14px as `sm` does, so a toolbar command's icon keeps its size when the bar hides the command's words.

## Names

- **An icon-only control** carries `aria-label`, named for what it does ("Refresh", "Close"), never for what it shows ("Arrows").
- **An icon beside a word** is decoration and stays out of the accessibility tree. Lucide renders `aria-hidden="true"` by itself unless you pass a label, so there is nothing to add.
- **An icon that carries meaning on its own**, such as a status in a table cell, gets a visible word next to it or an `aria-label`, and never relies on colour alone.

**Do**

Give an icon button its name with `aria-label`, and add a `Tooltip` on a pointer so a sighted user can read it too.

**Don't**

Put the name only in a `title` or a tooltip. Neither shows on a touchscreen, and a screen reader may never announce a tooltip that is not the control's label.

| The action                                                                                        | Show                                        |
| ------------------------------------------------------------------------------------------------- | ------------------------------------------- |
| Universally recognised (close, search, menu, more, back)                                          | Icon alone, with `aria-label`               |
| Frequent, in a toolbar people learn (bold, wrap, refresh, archive, a delete that Undo takes back) | Icon alone, with `aria-label` and a tooltip |
| The main action of a view, or anything destructive that cannot be undone                          | Icon and word, or the word alone            |
| Rare, or with no established icon                                                                 | The word alone                              |

## Avatars

An avatar is a person's icon, and follows the same rules. Put one beside the name where people scan a column of who: a conversation's authors, the reviewers of a pull request, an assignee column, a menu of people. The face is found before the word is read. There the name says who it is, so the `Avatar` is `aria-hidden`, as the pull request and Tasks demos have it. The name alone is enough where the person is one fact in a line of text ("alice committed 2 hours ago"), or where every row is the same person. An avatar never stands in for the name: one shown alone, in a stack or a narrow column, carries the name as its `aria-label`, and on a pointer a tooltip as well. The label makes it an image of that name, whose initials and badge go unread, so a badge that means something, such as a bot's mark, is said in the label too. A mark that is not a person, a project or an organisation, takes `shape="square"`. A `SelectTrigger` and a `QueryBox`'s value rows draw an avatar at their line's height on their own. Elsewhere, where none of the three sizes fits the line it sits in, size the `Avatar` with a `className` and leave out `size`, whose `sm` and `lg` outrank the class: its initials shrink to fit the box.

## On each platform

- **Pointer.** A tooltip names an icon button on hover and on keyboard focus.
- **Touch.** There is no hover, so no tooltip: an icon whose meaning is not obvious needs its word beside it on a phone, or moves into a menu where it has one. The button's hit area grows on a coarse pointer; the icon inside keeps its size.

## In the demos

- [Mail](/ui/demos/mail/index.md): The toolbars are Lucide icons alone, each with an aria-label and a tooltip, and unread and starred are said in words too. Compose, Send and Delete forever… keep their words, except in the narrow rail, where every place is an icon with a tooltip.
