Skip to content
EspañolEnglish
All components (283)

Overflow list

Utilities · OverflowList

What it is and when to use it

A row of items that never wraps: those that do not fit are gathered in a "+3" button that shows them. It is really measured, so it does not matter how much each one measures.

When to use it

  • Tags in a table cell or a card, people on a team, applied filters.
  • maxVisible sets a limit even if more would fit.

When not to

  • Breadcrumbs: Breadcrumbs already clips its own.
  • Actions: ActionMenu.

Keyboard: Tab reaches the "+N" button; Enter opens the panel and Escape closes it.

Accessibility: the button says how many are missing ("3 more") and whether it is open. What does not fit does not stay in the document twice: it leaves the group and enters the panel.

Fine-tuning: --amset-overflowlist-gap is the gap between items.

What it looks like

Silver
Gold
Rings
Necklaces
Earrings
Bracelets
Handmade
Engraved
Gift
New
Wedding
Sale

    <OverflowList
      label="Product tags"
      items={etiquetas}
      itemKey={(etiqueta) => etiqueta}
      renderItem={(etiqueta) => <Tag>{etiqueta}</Tag>}
    />

    Props

    Import it with import { OverflowList } from '@amset/ui'. Required props are marked.

    PropTypeWhat it does
    itemsrequiredreadonly Item[]—
    labelrequiredstringWhat the list is: "Tags". It names the list and the panel of those that do not fit.
    classNamestringMerged with the library classes; it does not replace them.
    collapseFrom"start" | "end"Which side is cut: `end` hides the last ones, `start` the first ones. Defaults to `end`.
    defaultOpenboolean—
    gapnumberSpace between items, in pixels. Defaults to the theme one.
    itemKey(item: Item, index: number) => stringThe stable key of each item. By default, its position: with a list that changes, it is better to give it.
    maxRowsnumberHow many rows are allowed before the rest is gathered into «+N». Defaults to 1.
    maxVisiblenumberA limit, even if more would fit. Without this, those that fit.
    onOpenChange(open: boolean) => void—
    openbooleanPanel controlled from outside.
    openOnHoverbooleanOpens the panel when the mouse goes over the button, as well as on click.
    renderItem(item: Item, index: number) => ReactNodeHow each item is painted. By default, its text or its `label`.
    renderOverflow(hidden: readonly Item[], controls: OverflowControls) => ReactNodeHow the content of the panel of the hidden ones is drawn. Defaults to a list using `renderItem`.

    It also accepts the attributes of the element it renders: className, style, data-*, aria-* and its events.

    In the test bench

    Every state and variant, to try one at a time, on its page at storybook.amsetui.com: