---
title: "Name List"
description: "Writes a list of names as a sentence, such as Ana, Ben, and 3 others, with the commas and joins of the reader's language. The rest open in a popover."
url: https://gelatinui.com/components/name-list
markdown_url: https://gelatinui.com/components/name-list.md
access: free
install: "npx shadcn@latest add @gelatin-ui/name-list"
registry_item: https://gelatinui.com/r/name-list.json
version: "2026-11-09"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Name List

> Writes a list of names as a sentence, such as Ana, Ben, and 3 others, with the commas and joins of the reader's language. The rest open in a popover.

Page: https://gelatinui.com/components/name-list

## When to use it

Best for: A short list of names in a sentence, with the rest in a Popover.

- Pass `items` as strings, or as `{ id, label }` when two people can share a name.
- Set `max` for the names that show before the rest.
- Use `rest="none"` where a popup has no room, as in a Toast.
- Use `renderItem` to show a link or a face per name.

## When not to use it

- For faces in a row, use an [Avatar](https://gelatinui.com/components/avatar.md).
- For a list of items that are not names, use a [Data List](https://gelatinui.com/components/data-list.md).

## Notes for agents

- The commas and the and come from `Intl.ListFormat` in the locale.
- The rest text is English by default ("3 others"). Pass `labels={{ rest, showRest }}` for your language.
- A blank name drops. No names show the empty text.
- A long name wraps. It is never cut.

## Anatomy

```text
NameList
└─ NameListEmpty (0..n)
```

## API reference

### NameList

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `items` | `readonly NameListItem[]` |  | The names, in the order they read. |
| `max` | `number` | 2 | The most names that show before "N others". Default 2. |
| `type` | `NameListType` |  | `and` (default: "Ana and Ben") or `or` ("Ana or Ben"). |
| `length` | `NameListLength` |  | The join words of `Intl.ListFormat`: `long` (default, "and"), `short` ("&"), `narrow`. |
| `rest` | `"none" \| "popover"` | "popover" | `popover` (default): the rest is a button that opens a Popover with the other names. `none`: plain text ("3 others"), for a place with no room for a popup (a Toast, a row that is a link). |
| `labels` | `Partial<NameListLabels>` |  | The words (`NameListLabels`). Keep the object and its functions stable (module level). |
| `renderItem` | `function` |  | Renders one name: a link, an Avatar and a name, a Hover Card. Default: the label in weight 600. The rest Popover renders its names with it too. |
| `children` | `ReactNode` |  | A `NameListEmpty` part: the words of no value. With a value, they are not drawn. |
| `locale` | `string` |  | The BCP 47 locale. Default: the `DisplayLocaleProvider` locale, else `"en-US"`. |

### NameListEmpty

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `data-slot` | `string` |  | The `data-slot` of the root: the item's own slot (`"time-ago"`). Default `"empty-value"`. |

Also takes every prop of Base UI `UseRender`: https://base-ui.com/react/components/use-render

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| NameList | `name-list` |  |  |  |
| NameListEmpty | `name-list-empty` |  |  |  |

## Usage

Pass the names. Put a `NameListEmpty` inside for the words that show when the list is empty.

```tsx title="liked-by.tsx"
import { NameList, NameListEmpty } from "@/components/ui/name-list";

const POSTS = [
  { id: "launch", title: "We shipped dark mode", likes: ["Ana Silva", "Ben Okafor", "Cleo Park", "Dev Patel"] },
  { id: "hiring", title: "We are hiring in Lisbon", likes: [] },
];

export function LikedBy() {
  return (
    <ul className="flex flex-col gap-3 text-sm">
      {POSTS.map((post) => {
        return (
          <li key={post.id}>
            <p className="font-medium">{post.title}</p>
            <p className="text-muted-foreground">
              <NameList items={post.likes}>
                <NameListEmpty>No likes yet</NameListEmpty>
              </NameList>
            </p>
          </li>
        );
      })}
    </ul>
  );
}
```

## Compose

Rules:

- Compose the parts (`compose-parts`): Build each item from its named parts as children, and pass your text and icons in as parts.
- Every state is designed (`every-state`): Give each view of data its loading, empty, and error states: a skeleton in the final layout, an `Empty` with an illustration and one next action, and an error that says what failed and how to retry.

## Add it

```bash
npx shadcn@latest add @gelatin-ui/name-list
```

It adds 24 registry items: 21 files, 4147 lines, and the npm packages `@base-ui/react`, `@phosphor-icons/react`, `clsx`, `tailwind-merge`, `tailwind-variants`.

## Built on

- [Popover](https://gelatinui.com/components/popover.md)

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [Avatar](https://gelatinui.com/components/avatar.md)
- [Popover](https://gelatinui.com/components/popover.md)
- [Hover Card](https://gelatinui.com/components/hover-card.md)

## Keyboard

| Keys | Action |
| --- | --- |
| Tab | Moves to the rest button. |
| Enter | Opens the Popover with the other names. |
| Space | Opens the Popover with the other names. |
| Escape | Closes the Popover. |

## Accessibility

The rest is a button with a name such as "Show 3 more people".

The rest button has a 44px touch target.

## Motion

| Part | Motion |
| --- | --- |
| Rest Popover open | popup · 150ms · ease-panel (0.2, 0.4, 0.2, 1) |
| Rest Popover close | popup-exit · 120ms · ease-out (0, 0, 0.2, 1) |
