Multiple Choice

A multi-select field with customizable indicators, badge support, max selection limits, and a built-in 'none' option.

Demo

Preferred frameworks

Select all that apply

Installation

pnpm dlx shadcn@latest add @turbopills-ui/multiple-choice

Usage

tsx
1import { MultipleChoice } from "@/components/turbopills/ui/multiple-choice"
2import type { ChoiceOption } from "@/components/turbopills/ui/types"
tsx
1const options: ChoiceOption[] = [
2  { value: "email", label: "Email" },
3  { value: "sms", label: "SMS" },
4  { value: "push", label: "Push notifications" },
5]
6 
7export function NotificationPreferences() {
8  const [value, setValue] = React.useState<string[]>([])
9 
10  return (
11    <MultipleChoice
12      title="Notifications"
13      hint="Select your preferred channels"
14      options={options}
15      value={value}
16      onChange={setValue}
17    />
18  )
19}

Examples

Max Selections

Limit the number of items a user can select with maxSelections. Options become disabled once the limit is reached:

Choose your plans

Select up to 2

None Option

An option with none: true acts as an exclusive toggle — selecting it deselects all other options, and selecting any other option deselects the "none" option:

Medical conditions

Select all that apply

Checkbox Variant

Use checkboxVariant="checkbox" for a traditional checkbox indicator instead of the default icon. Combine with checkboxPosition="left" to place the indicator before the label:

Notification preferences

Numbered Options

Enable showNumbers to display an index next to each option. Useful for ordered or ranked lists:

Rank your symptoms

Select the ones that apply

Props

MultipleChoiceProps

PropTypeDefaultDescription
titlestringOptional heading displayed above the options.
hintstringOptional hint text shown below the title.
optionsChoiceOption[]Required. Array of options to render.
valuestring[][]Currently selected option values (controlled).
onChange(value: string[]) => voidCallback fired when the selection changes.
maxSelectionsnumberMaximum number of items that can be selected. Remaining options become disabled once the limit is reached.
disabledbooleanfalseDisables the entire field.
checkboxPosition"left" | "right""right"Where to render the selection indicator relative to the label.
checkboxVariant"checkbox" | "icon" | "none""icon"Visual style of the indicator. "icon" shows a filled circle-check, "checkbox" shows a standard checkbox, "none" hides the indicator.
showNumbersbooleanfalseDisplays a 1-based index badge next to each option.
highlightOnHoverbooleantrueApplies a hover highlight to option rows.
showOutlineOnSelectbooleantrueShows a border outline on selected options.
showFillOnSelectbooleanfalseFills the background of selected options.
showShadowOnSelectbooleanfalseAdds a shadow to selected options.
allowTextSelectionbooleanfalseAllows selecting text inside option rows. Disabled by default to prevent accidental highlighting during repeated clicks.
classNamestringAdditional class names for the root container.

ChoiceOption

PropTypeDefaultDescription
valuestringRequired. Unique identifier for the option.
labelReact.ReactNodeRequired. Text or element displayed as the option label.
badgestringOptional badge text rendered next to the label.
disabledbooleanfalseDisables this individual option.
nonebooleanfalseMarks this option as exclusive — selecting it deselects all others, and selecting any other deselects this one.