TabbedChips (Alpha)
A chip component commonly used in filter context to refine a date source@coinbase/cds-web@8.64.0
Alpha componentAlpha components are stable and safe to use. They allow us to provide new and powerful features quickly, without forcing breaking changes. Components will exit the alpha status when their deprecated counterpart is removed in the next major version.
import { TabbedChips } from '@coinbase/cds-web/alpha/tabbed-chips/TabbedChips'
Peer dependencies
- framer-motion: ^10.18.0
Related components
Basic usage
Loading...
Live Codefunction ExampleDefault() { const tabs = [ { id: 'all', label: 'All' }, { id: 'swap', label: 'Swap' }, { id: 'collect', label: 'Collect' }, { id: 'bridge', label: 'Bridge' }, ]; const [activeTab, setActiveTab] = useState(tabs[0]); return <TabbedChips activeTab={activeTab} onChange={setActiveTab} tabs={tabs} />; }
Compact
function ExampleCompactNoStart() {
const tabs = [
{ id: 'all', label: 'All' },
{ id: 'swap', label: 'Swap' },
{ id: 'collect', label: 'Collect' },
{ id: 'bridge', label: 'Bridge' },
];
const [activeTab, setActiveTab] = useState(tabs[0]);
return <TabbedChips activeTab={activeTab} compact onChange={setActiveTab} tabs={tabs} />;
}
Many tabs (paddles)
Paddles & overflow
Paddles appear automatically when the tab list overflows.
Loading...
Live Codefunction ExampleWithPaddles() { const tabs = Array.from({ length: 12 }).map((_, i) => ({ id: `tab_${i + 1}`, label: `Tab ${i + 1}`, })); const [activeTab, setActiveTab] = useState(tabs[0]); return <TabbedChips activeTab={activeTab} onChange={setActiveTab} tabs={tabs} />; }
With autoScrollOffset
Auto-scroll offset
The autoScrollOffset prop controls the X position offset when auto-scrolling to the active tab. This prevents the active tab from being covered by the paddle on the left side. Try clicking tabs near the edges to see the difference.
Loading...
Live Codefunction ExampleAutoScrollOffset() { const tabs = Array.from({ length: 25 }).map((_, i) => ({ id: `tab_${i + 1}`, label: `Tab ${i + 1}`, })); const [activeTab, setActiveTab] = useState(tabs[0]); return ( <VStack gap={2}> <Text as="p" font="body"> Default offset (50px) </Text> <TabbedChips activeTab={activeTab} onChange={setActiveTab} tabs={tabs} /> <Text as="p" font="body"> Custom offset (100px) </Text> <TabbedChips activeTab={activeTab} onChange={setActiveTab} tabs={tabs} autoScrollOffset={100} /> </VStack> ); }
With custom sized paddles
Paddle styling
You can adjust the size of the paddles via styles.paddle.
Loading...
Live Codefunction ExampleCustomPaddles() { const tabs = Array.from({ length: 10 }).map((_, i) => ({ id: `t_${i + 1}`, label: `Item ${i + 1}`, })); const [activeTab, setActiveTab] = useState(tabs[0]); return ( <TabbedChips activeTab={activeTab} onChange={setActiveTab} tabs={tabs} styles={{ paddle: { transform: 'scale(0.8)' } }} /> ); }
Long text tabs
Loading...
Live Codefunction ExampleLongText() { const tabs = [ { id: 'a', label: 'Very long tab label that can wrap on small widths' }, { id: 'b', label: 'Another extra long label to test overflow' }, { id: 'c', label: 'Short' }, ]; const [activeTab, setActiveTab] = useState(tabs[0]); return <TabbedChips activeTab={activeTab} onChange={setActiveTab} tabs={tabs} />; }
Disabled tab
Loading...
Live Codefunction ExampleDisabled() { const tabs = [ { id: 'first', label: 'First' }, { id: 'second', label: 'Second', disabled: true }, { id: 'third', label: 'Third' }, ]; const [activeTab, setActiveTab] = useState(tabs[0]); return <TabbedChips activeTab={activeTab} onChange={setActiveTab} tabs={tabs} />; }
With start media
Media sizing
For start media, use circular images sized 24×24 for regular chips and 16×16 for compact chips.
Loading...
Live Codefunction ExampleWithStart() { const icon = { height: 24, width: 24, shape: 'circle', source: assets.eth.imageUrl }; const compactIcon = { height: 16, width: 16, shape: 'circle', source: assets.eth.imageUrl }; const tabs = [ { id: 'all', label: 'All', start: <RemoteImage {...icon} /> }, { id: 'swap', label: 'Swap', start: <RemoteImage {...icon} /> }, { id: 'collect', label: 'Collect', start: <RemoteImage {...icon} /> }, { id: 'bridge', label: 'Bridge', start: <RemoteImage {...icon} /> }, ]; const compactTabs = tabs.map((tab) => ({ ...tab, start: <RemoteImage {...compactIcon} /> })); const [activeTab, setActiveTab] = useState(tabs[0]); return ( <VStack gap={2}> <TabbedChips activeTab={activeTab} onChange={setActiveTab} tabs={tabs} /> <TabbedChips compact activeTab={activeTab} onChange={setActiveTab} tabs={compactTabs} /> </VStack> ); }