Usage
Overflow List measures ordered direct children and hides the contiguous items that no longer fit. It preserves every original element, listener, value, and DOM position while exposing visible and overflowed element/index pairs through read-only state and nord-overflow-change.
Importing the component registers its custom element:
import "@nordhealth/components/lib/OverflowList"
import "@nordhealth/components/lib/OverflowListCount"
import "@nordhealth/components/lib/OverflowListMenu"
Composition
- Overflow List Count provides a localized declarative count affordance.
- Overflow List Menu provides equivalent actions for hidden interactive items.
Use the declarative nord-overflow-list-menu helper when hidden items are actions. It owns the Nord Dropdown affordance, mirrors the currently overflowed actions, and forwards activation to each original element without moving or cloning it. At its default width, the canonical example keeps Overview, Properties, and Edit visible while Duplicate and Share move into a +2 more menu.
State is available as immutable visibleItems and overflowItems arrays of { element, index } records. The read-only overflowCount is also reflected as data-overflow-count. nord-overflow-change bubbles and is composed, and fires only when an ordered classified set or original index changes. The Count and Menu helpers cover the common declarative integrations; a custom slot="overflow" affordance can synchronize equivalent content from the same event.
Examples
Collapse direction
The default collapse-from="end" keeps the earliest fitting items. collapse-from="start" keeps the latest fitting items. Classified arrays always remain in original order.
Because the light-DOM component never moves consumer content, place the overflow affordance at the matching logical edge in DOM order: last for end, first for start. This keeps visual and keyboard order aligned in LTR and RTL. The start-collapse example uses a five-step row: Step 1 and Step 2 move into +2 more, leaving Steps 3–5 visible.
Badge tags
When individual hidden tags are nonessential and a summary count is sufficient, nest nord-overflow-list-count compact inside a consumer-owned Nord Badge. The helper derives the live count from the nearest Overflow List, formats it for the active document language, and renders +N; without compact, it renders +N more. Set singular-label and plural-label so its accessible text describes the content, such as “1 more tag” or “2 more tags”. The resizable example uses Nord Badge variants for React, TypeScript, StyleX, Storybook, and Vitest.
Dropdown actions
Action rows need an equivalent interactive representation of every hidden action. Place nord-overflow-list-menu directly in the list with slot="overflow"; use compact for a +N toggle, or omit it for +N more. The resizable action example keeps Save, Edit, and Duplicate visible at its default width and moves Share, Archive, and Delete into a +3 Nord Dropdown. Menu activation forwards to the original action, preserving its listener and state.
Original click handlers
The built-in menu activates the original action with HTMLElement.click(), so direct and generated menu activation both run the listener attached to that original exactly once and its currentTarget remains the original element. The forwarded original click is programmatic, which means its isTrusted value is false.
If application behavior specifically requires a trusted event or cannot be represented by a forwarded click, provide a custom slot="overflow" affordance and synchronize it with nord-overflow-change instead. The resizable example lets you click Archive directly, resize until it moves into overflow, and choose Archive from the menu while a live output reports the handler count, current target, and trusted-event state.
Observation modes
observe="self" responds to the component’s actual assigned inline size. Use observe="parent" only when the containing element’s CSS content box is the relevant constraint. A Shadow DOM container can constrain slotted content internally—for example, with Card padding that is not visible on the host—so use the default self observation in that case. Both modes also respond to direct-child, content, item-size, affordance-size, font, and direction changes in one animation-frame batch.
Minimum visibility
Set min-visible-items to retain a required number of items. The minimum wins even if those items and the overflow affordance exceed the available inline size, so use it only for genuinely essential leading or trailing content.
Dynamic items
Items can be added, removed, reordered, or updated without recreating the component. Each change invalidates stale measurements and produces at most one classified-state event after the next stable layout.
Constrained containers
The gap defaults to Nord’s small spacing token. Choose none, xs, s, m, l, xl, or xxl, or set --n-overflow-list-gap when the surrounding product layout has a specific constraint.
State and events
visibleItemsandoverflowItemsare immutable arrays of{ element, index }records.overflowCountis read-only and reflected asdata-overflow-count, including0.nord-overflow-changebubbles and is composed. It fires only when an ordered classified set or original index changes.nord-overflow-list-counthandles locale-aware visible counts and accessible singular/plural labels for common count-only affordances.nord-overflow-list-menuhandles the common action-menu case, including equivalent menu items and activation forwarding.- For a custom
slot="overflow"affordance, listen tonord-overflow-changeas the custom integration escape hatch. Use its original element/index records to synchronize equivalent content, and supply translated labels through the product localization layer.
Accessibility
- Overflowed originals are both
hiddenandinert, so their controls cannot remain in the tab order or accessibility tree. - Overflow List restores only attributes it added. Existing consumer
hiddenandinertstate is preserved. - Use
nord-overflow-list-menufor a keyboard-accessible equivalent of hidden actions, or provide a custom affordance with the same semantics and behavior. - The built-in menu keeps every generated action equivalent to its hidden original and forwards activation to that original, as shown in the Overview and Collapse from start examples.
- Keep the affordance at the logical collapse edge in DOM order. CSS-only visual reordering would create a different keyboard order and is intentionally avoided.
- Logical grid layout supports RTL, brand themes, high contrast, text resizing, and zoom without physical left/right assumptions.
API reference
OverflowList
Overflow List shows the contiguous set of direct child items that fits in the available inline size and exposes the remaining items to a consumer-owned overflow affordance.
<nord-overflow-list></nord-overflow-list>Props
| Property | Attribute | Description | Type | Default |
|---|---|---|---|---|
collapseFrom | collapse-from | Logical edge from which items collapse. | OverflowCollapseFrom | 'end' |
gap | gap | Nord spacing token used between items. | OverflowListGap | 's' |
minVisibleItems | min-visible-items | Minimum number of items that remain visible, even when they do not fit. | number | 0 |
observe | observe | Element whose available inline size is observed. | OverflowListObserve | 'self' |
Slots
| Slot name | Description |
|---|---|
Default slot | Ordered items managed by the Overflow List. |
overflow | Consumer-owned affordance for access to overflowed content. |
| Event | Detail Type | Description |
|---|---|---|
nord-overflow-change | OverflowListChangeEvent | Dispatched when the visible or overflowed item set changes. The event exposes immutable visibleItems and overflowItems arrays containing each element and its original index. |
CSS Properties
CSS Custom Properties provide more fine grain control over component presentation. We advise utilizing existing properties on the component before using these.
| Property | Description | Default |
|---|---|---|
--n-overflow-list-gap | Controls logical spacing between visible items and supplied overflow content. | var(--n-space-s) |
Parts
This component is made up of the following parts.
Overflow List Count
Displays the number of items currently hidden by the nearest Overflow List.
<nord-overflow-list-count></nord-overflow-list-count>Props
| Property | Attribute | Description | Type | Default |
|---|---|---|---|---|
compact | compact | Shows only the signed count visually while keeping the full accessible phrase. | boolean | false |
singularLabel | singular-label | Noun used by the accessible phrase when exactly one item is hidden. | string | undefined | — |
pluralLabel | plural-label | Noun used by the accessible phrase when multiple items are hidden. | string | undefined | — |
Overflow List Menu
Provides a declarative menu for actions hidden by the nearest Overflow List.
<nord-overflow-list-menu></nord-overflow-list-menu>Props
| Property | Attribute | Description | Type | Default |
|---|---|---|---|---|
size | size | Size passed to the owned Nord Dropdown and Button. | OverflowListMenuSize | 'm' |
compact | compact | Shows only the signed count inside the owned toggle. | boolean | false |
singularLabel | singular-label | Noun used when exactly one item is hidden. | string | undefined | — |
pluralLabel | plural-label | Noun used when multiple items are hidden. | string | undefined | — |
Design guidelinesFor designers
Usage
This section includes guidelines for designers and developers about using this component in different contexts.
Do
- Use Overflow List for one ordered row of actions, filters, breadcrumbs, or compact metadata that must adapt to its available inline size.
- Place custom
slot="overflow"content at the DOM end forcollapse-from="end"and at the DOM start forcollapse-from="start", so visual and keyboard order agree. - Use
nord-overflow-list-menufor the common action-menu case; it mirrors overflowed actions and forwards activation to their originals. - For non-interactive, nonessential overflow where a summary is sufficient, nest
nord-overflow-list-countinside a Badge or another suitable affordance to show a locale-aware+N more, or usecompactfor+N. - Set
singular-labelandplural-labelon either helper so its accessible label identifies the hidden content. - Listen for
nord-overflow-changeand use its original element/index pairs when a product needs a custom overflow affordance. - Provide an equivalent keyboard-accessible representation whenever hidden items are actionable or essential.
Don’t
- Don’t rebuild the standard count or action-menu behavior in setup scripts when the declarative helpers cover it.
- Don’t move or recreate items in response to the change event. The original elements remain in place and return when space is available.
- Don’t set
min-visible-itemshigher than the layout can reasonably accommodate unless deliberate host overflow is acceptable.
Observation
The default observe="self" mode measures the component’s actual assigned inline size. Use observe="parent" only when the containing element’s CSS content box owns the relevant constraint. If a Shadow DOM container constrains slotted content internally—for example, with Card padding that is not reflected by its host—keep the default self observation. Direct-child additions, removals, reordering and content changes, item or affordance resizes, font loading, direction changes, and observed-size changes are batched into the next animation frame.
The gap values use Nord spacing tokens. --n-overflow-list-gap is available for a product-specific spacing constraint.
Accessibility
Overflowed originals receive component-owned hidden and inert state, which removes their interactive descendants from the tab order and accessibility tree. When an item fits again, or the component disconnects, only state added by Overflow List is removed; consumer-owned hidden or inert attributes remain intact.
The base component does not create a default interactive affordance. If hidden items contain actions, use nord-overflow-list-menu as the direct slot="overflow" child. For non-interactive count-only content, nest nord-overflow-list-count inside the consumer-owned overflow Badge or another suitable affordance. A count alone is not an equivalent replacement for hidden actions. Keep the affordance at the logical collapse edge in DOM order so keyboard navigation matches the visual row in both LTR and RTL layouts.
Both helpers format the count for the active locale. Without compact, the visual label is +1 more or +2 more; compact Badge and menu affordances use +N. Their singular-label and plural-label attributes keep the accessible label equally specific. The canonical Overview, Badge Tags, Dropdown Actions, and Collapse From Start stories cover these declarative patterns.
Raw consumer-owned slot="overflow" content remains available as an escape hatch. Listen for nord-overflow-change when a custom affordance must synchronize different content or behavior, and use the event’s original element/index pairs without moving or recreating the originals.