Components
Choice cards
Options that each need a sentence of explanation, with a radio or checkbox on the right.
import { ChoiceCardRadio, ChoiceCardRadioGroup } from '@dex/shared/components/choice-card'
import { FieldDescription, FieldLegend, FieldSet } from '@dex/shared/components/field'
export function ChoiceCardsSingleChoice() {
return (
<FieldSet className="w-full max-w-xl">
<FieldLegend>How should Dex match you?</FieldLegend>
<FieldDescription>You can change this any time in settings.</FieldDescription>
<ChoiceCardRadioGroup defaultValue="open">
<ChoiceCardRadio
value="active"
title="Actively looking"
description="Dex sends roles as soon as they match."
/>
<ChoiceCardRadio
value="open"
title="Open to the right role"
description="Only strong matches, a few times a month."
/>
<ChoiceCardRadio
value="browsing"
title="Just browsing"
description="No alerts. Check your matches when you like."
/>
</ChoiceCardRadioGroup>
</FieldSet>
)
}
'use client'
import { useState } from 'react'
import { ChoiceCardCheckbox, ChoiceCardCheckboxGroup } from '@dex/shared/components/choice-card'
import { FieldDescription, FieldLegend, FieldSet } from '@dex/shared/components/field'
export function ChoiceCardsMultipleChoice() {
const [roles, setRoles] = useState({ ml: true, research: false, applied: true })
return (
<FieldSet className="w-full max-w-xl">
<FieldLegend>Which roles should Dex look for?</FieldLegend>
<FieldDescription>Choose all that apply.</FieldDescription>
<ChoiceCardCheckboxGroup>
<ChoiceCardCheckbox
title="Machine learning engineer"
description="Training, evaluation and getting models into production."
checked={roles.ml}
onCheckedChange={(ml) => setRoles((current) => ({ ...current, ml }))}
/>
<ChoiceCardCheckbox
title="Research scientist"
description="New methods, experiments and papers."
checked={roles.research}
onCheckedChange={(research) => setRoles((current) => ({ ...current, research }))}
/>
<ChoiceCardCheckbox
title="Applied AI engineer"
description="Shipping LLM features inside a product."
checked={roles.applied}
onCheckedChange={(applied) => setRoles((current) => ({ ...current, applied }))}
/>
</ChoiceCardCheckboxGroup>
</FieldSet>
)
}
import { ChoiceCardRadio, ChoiceCardRadioGroup } from '@dex/shared/components/choice-card'
import { FieldLegend, FieldSet } from '@dex/shared/components/field'
export function ChoiceCardsInARow() {
return (
<FieldSet className="w-full">
<FieldLegend>Your level now</FieldLegend>
<ChoiceCardRadioGroup columns={4} defaultValue="senior">
<ChoiceCardRadio value="mid" title="Mid" description="3–4 yrs" />
<ChoiceCardRadio value="senior" title="Senior" description="5–8 yrs" />
<ChoiceCardRadio value="staff" title="Staff" description="9–12 yrs" />
<ChoiceCardRadio value="principal" title="Principal" description="13+ yrs" />
</ChoiceCardRadioGroup>
</FieldSet>
)
}
'use client'
import { useState } from 'react'
import { ChoiceCardRadio, ChoiceCardRadioGroup } from '@dex/shared/components/choice-card'
import { FieldLegend, FieldMessage, FieldSet } from '@dex/shared/components/field'
export function ChoiceCardsInvalid() {
const [answer, setAnswer] = useState('')
return (
<FieldSet invalid={!answer} className="w-full max-w-xl">
<FieldLegend>Are you open to relocating?</FieldLegend>
<ChoiceCardRadioGroup columns={2} value={answer} onValueChange={setAnswer}>
<ChoiceCardRadio value="yes" title="Yes" description="Within the UK" />
<ChoiceCardRadio value="no" title="No" description="Stay where I am" />
</ChoiceCardRadioGroup>
{!answer && <FieldMessage error="Choose whether you're open to relocating." />}
</FieldSet>
)
}
import { ChoiceCardRadio, ChoiceCardRadioGroup } from '@dex/shared/components/choice-card'
import { FieldLegend, FieldSet } from '@dex/shared/components/field'
export function ChoiceCardsDisabled() {
return (
<FieldSet className="w-full max-w-xl">
<FieldLegend>What kind of contract do you want?</FieldLegend>
<ChoiceCardRadioGroup columns={2} defaultValue="permanent">
<ChoiceCardRadio
value="permanent"
title="Permanent"
description="A salaried role with equity"
disabled
/>
<ChoiceCardRadio
value="contract"
title="Contract"
description="A day rate for a fixed term"
disabled
/>
</ChoiceCardRadioGroup>
</FieldSet>
)
}
'use client'
import { useState } from 'react'
import { ChoiceCardCheckbox, ChoiceCardCheckboxGroup } from '@dex/shared/components/choice-card'
import { FieldLegend, FieldSet } from '@dex/shared/components/field'
export function ChoiceCardsDisabledGroup() {
const [roles, setRoles] = useState({ ml: true, research: false })
return (
<FieldSet className="w-full max-w-xl">
<FieldLegend>Which roles should Dex look for?</FieldLegend>
<ChoiceCardCheckboxGroup columns={2} disabled>
<ChoiceCardCheckbox
title="Machine learning engineer"
description="Training, evaluation and getting models into production."
checked={roles.ml}
onCheckedChange={(ml) => setRoles((current) => ({ ...current, ml }))}
/>
<ChoiceCardCheckbox
title="Research scientist"
description="New methods, experiments and papers."
checked={roles.research}
onCheckedChange={(research) => setRoles((current) => ({ ...current, research }))}
/>
</ChoiceCardCheckboxGroup>
</FieldSet>
)
}
- Use choice cards for options that need a sentence of explanation. Short answers with no description are chips.
- Stack the cards, or put 2 to 4 in an equal-width row with
columns. A row stacks on a phone. - The whole card is the click target, and the radio or checkbox sits on its right.
- A selected card takes a primary border and its control fills. The surface stays card, so the description stays readable.
- Focus marks the card, not the radio or checkbox inside it.
- Set
invalidon theFieldSet, oraria-invalidon the group, and every card's border turns red. One message goes 8px below the cards.