Data
Overflow List
List that adapts to available width by collapsing overflow into a "+N more" indicator.
Preview
01 Installation
Install
Pull Overflow List from the barrel for everyday use, or the granular path when you want a tighter bundle.
tsxBarrel1 line
import { OverflowList } from "@brika/clay";tsxGranular1 line
import { OverflowList } from "@brika/clay/components/overflow-list"; 02 Usage
A minimal example
Drop this into a page. Native HTML attributes pass through to the underlying primitive.
tsxOverflow List.tsx43 lines
'use client';
import { Badge } from '@brika/clay/components/badge';
import {
OverflowList,
OverflowListContent,
OverflowListIndicator,
OverflowListItem,
useOverflowList,
} from '@brika/clay/components/overflow-list';
const TAGS = [
'production',
'staging',
'eu-west-1',
'us-east-1',
'ap-southeast-2',
'cdn',
'edge',
'preview',
];
/** Tags that overflow the container collapse into a "+N more" badge. Resize the window to see it adapt. */
export default function OverflowListDefaultDemo() {
const { containerRef, visible, overflow } = useOverflowList({
items: TAGS,
getKey: (t) => t,
});
return (
<OverflowList className="w-full max-w-sm">
<OverflowListContent ref={containerRef}>
{TAGS.map((tag) => (
<OverflowListItem key={tag} itemId={tag}>
<Badge variant={visible.includes(tag) ? 'outline' : 'secondary'}>{tag}</Badge>
</OverflowListItem>
))}
</OverflowListContent>
<OverflowListIndicator active={overflow.length > 0}>
<Badge>+{overflow.length} more</Badge>
</OverflowListIndicator>
</OverflowList>
);
} 03 Examples
Overflow List, every way
Active
The active item is always kept visible even when it would otherwise be hidden.
04 Accessibility
Accessibility
- Hidden items remain in the DOM, the indicator communicates the count to all users.
- The
activeKeyitem is always visible; this preserves context for the current selection. - Consider wrapping the indicator in a
PopoverorTooltipto reveal hidden items on demand.
05 API reference
API reference
Props specific to Overflow List. Native HTML attributes pass through to the underlying primitive, see the component source on GitHub for the full type signature.
<OverflowList />
passthroughNo wrapper-specific props, all attributes pass through to the underlying primitive.
<OverflowListContent />
passthroughNo wrapper-specific props, all attributes pass through to the underlying primitive.
<OverflowListIndicator />
1 prop- activedefault
falsebooleanWhether to render in the active overflow state.
<OverflowListItem />
1 prop- stringStable identifier matching one of the items passed to
useOverflowList.