Components
Tabs
Switches between panels of content, with an indicator that slides to the active tab.
Staff backend engineer on the payments team. £140k to £165k, hybrid in London.
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@dex/shared/components/tabs'
export function TabsUnderline() {
return (
<Tabs defaultValue="role" className="w-full max-w-xl">
<TabsList>
<TabsTrigger value="role">Role</TabsTrigger>
<TabsTrigger value="company">Company</TabsTrigger>
<TabsTrigger value="process">Process</TabsTrigger>
</TabsList>
<TabsContent value="role">
<p className="text-sm text-muted-foreground">
Staff backend engineer on the payments team. £140k to £165k, hybrid in London.
</p>
</TabsContent>
<TabsContent value="company">
<p className="text-sm text-muted-foreground">
A Series B fintech with 120 people, 45 of them in engineering.
</p>
</TabsContent>
<TabsContent value="process">
<p className="text-sm text-muted-foreground">
An intro call, a system design interview and a day on site. About three weeks.
</p>
</TabsContent>
</Tabs>
)
}
Your CV as a hiring team sees it.
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@dex/shared/components/tabs'
export function TabsPill() {
return (
<Tabs defaultValue="preview" className="w-full max-w-md">
<TabsList variant="pill">
<TabsTrigger value="preview">Preview</TabsTrigger>
<TabsTrigger value="edit">Edit</TabsTrigger>
</TabsList>
<TabsContent value="preview">
<p className="text-sm text-muted-foreground">Your CV as a hiring team sees it.</p>
</TabsContent>
<TabsContent value="edit">
<p className="text-sm text-muted-foreground">Change the sections of your CV.</p>
</TabsContent>
</Tabs>
)
}
Eight years of backend work, the last three on payments. Meets the office days.
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@dex/shared/components/tabs'
export function TabsSecondary() {
return (
<Tabs defaultValue="role-fit" className="w-full max-w-xl">
<TabsList variant="secondary">
<TabsTrigger className="flex-none" value="role-fit">
Role fit
</TabsTrigger>
<TabsTrigger className="flex-none" value="profile">
Profile
</TabsTrigger>
<TabsTrigger className="flex-none" value="cv">
CV
</TabsTrigger>
<TabsTrigger className="flex-none" value="transcript">
Transcript
</TabsTrigger>
<TabsTrigger className="flex-none" value="history">
Match history
</TabsTrigger>
</TabsList>
<TabsContent value="role-fit">
<p className="text-sm text-muted-foreground">
Eight years of backend work, the last three on payments. Meets the office days.
</p>
</TabsContent>
<TabsContent value="profile">
<p className="text-sm text-muted-foreground">
Looking for a staff role at a Series B or later, in London or remote.
</p>
</TabsContent>
<TabsContent value="cv">
<p className="text-sm text-muted-foreground">Uploaded on 12 November.</p>
</TabsContent>
<TabsContent value="transcript">
<p className="text-sm text-muted-foreground">A 14 minute onboarding call.</p>
</TabsContent>
<TabsContent value="history">
<p className="text-sm text-muted-foreground">Five matches, two accepted.</p>
</TabsContent>
</Tabs>
)
}
Your CV as a hiring team sees it.
'use client'
import { useState } from 'react'
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@dex/shared/components/tabs'
import { Button } from '@dex/shared/components/button'
export function TabsControlled() {
const [view, setView] = useState('preview')
return (
<Tabs value={view} onValueChange={setView} className="w-full max-w-md">
<TabsList variant="pill">
<TabsTrigger value="preview">Preview</TabsTrigger>
<TabsTrigger value="edit">Edit</TabsTrigger>
</TabsList>
<TabsContent value="preview" className="flex flex-col items-start gap-3">
<p className="text-sm text-muted-foreground">Your CV as a hiring team sees it.</p>
<Button variant="outline" size="sm" onClick={() => setView('edit')}>
Edit CV
</Button>
</TabsContent>
<TabsContent value="edit">
<p className="text-sm text-muted-foreground">Change the sections of your CV.</p>
</TabsContent>
</Tabs>
)
}
Three new roles match your profile.
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@dex/shared/components/tabs'
export function TabsDisabledTab() {
return (
<Tabs defaultValue="matches" className="w-full max-w-md">
<TabsList variant="pill">
<TabsTrigger value="matches">Matches</TabsTrigger>
<TabsTrigger value="saved">Saved</TabsTrigger>
<TabsTrigger value="offers" disabled>
Offers
</TabsTrigger>
</TabsList>
<TabsContent value="matches">
<p className="text-sm text-muted-foreground">Three new roles match your profile.</p>
</TabsContent>
<TabsContent value="saved">
<p className="text-sm text-muted-foreground">You have saved two roles.</p>
</TabsContent>
<TabsContent value="offers">
<p className="text-sm text-muted-foreground">No offers yet.</p>
</TabsContent>
</Tabs>
)
}
- Use tabs when each option has its own panel of content. To switch a view or a setting with no panels, use a segmented control, which shares the pill look.
- Three variants, set on the list with
variant. Pick by where the tabs sit, not by how many there are:underline, the default: a page's main sections, such as a candidate's tabs under their name. A row along a hairline the width of its container, with a line under the active tab. Let the line run the page's full width, and inset the list by the page's gutter, so the first word lines up with the heading above. A tab is its word, with no padding either side: the line under it is exactly the word's width, and pointing at it darkens the word with no tint.pill: two or three tabs in a smaller space, such as a card header or a dialog. A muted track with the active tab raised on it, as the segmented control has.secondary: a second row of tabs inside a page that already has one. No track: the active tab is a muted block with a navigation item's corners (rounded-md).
- One variant per screen: tabs inside tabs take a different one from the tabs around them.
- The active tab's text is the foreground colour; the rest are muted until pointed at, when they take a faint tint.
- Arrow keys choose a tab as they move between them.
onValueChangereports only a tab someone chose, not one the tabs fall back to by themselves.