GooseUI

Components

Option Picker

New

A single choice from a short list, drawn in one of five ways. Every variant is a group of native radio inputs: one tab stop, the arrow keys move the selection, and the value goes into FormData on its own. The selected look and the moving highlight of the segment variant are CSS through :has(:checked), so the component is a Server Component with no JavaScript.

Browser Support

:has()

Styles elements based on their contents

Your browser:
color-mix()

Colors indicators and selection bar

Your browser:

Preview

Switch the variant, the value stays the same.

Variant

Selected: Team

Installation

npx shadcn@latest add @gooseui/option-picker
pnpm dlx shadcn@latest add @gooseui/option-picker
yarn dlx shadcn@latest add @gooseui/option-picker
bunx --bun shadcn@latest add @gooseui/option-picker

Usage

import { OptionPicker } from "@/components/ui/option-picker"

const plans = [
  { value: "starter", label: "Starter", description: "1 seat" },
  { value: "team", label: "Team", description: "Up to 10 seats" },
  { value: "studio", label: "Studio", description: "Unlimited" },
]

// A Server Component: the value lives in the radio inputs
export default function Example() {
  return (
    <form action="/checkout">
      <OptionPicker
        aria-label="Plan"
        name="plan"
        variant="segment"
        options={plans}
        defaultValue="team"
      />
    </form>
  )
}

// Inside a client component you can control it
<OptionPicker options={plans} value={plan} onValueChange={setPlan} />

Examples

Icons and descriptions

Each option takes an icon and a short description. tiles shows them stacked, rows puts the description on the right.

const options = [
  { value: "walk", label: "On foot", description: "Under 2 km", icon: <Footprints /> },
  { value: "bike", label: "By bike", description: "2–10 km", icon: <Bike /> },
  { value: "train", label: "By train", description: "Any distance", icon: <TrainFront /> },
  { value: "car", label: "By car", description: "Any distance", icon: <Car /> },
]

<OptionPicker variant="tiles" options={options} defaultValue="bike" />
<OptionPicker variant="rows" options={options} defaultValue="train" />

Scales

slider and bars suit ordered values where further means more. The slider stops are radio inputs too: click a stop or its caption, or use the arrow keys. Before the first pick it shows emptyLabel.

<OptionPicker variant="slider" options={levels} emptyLabel="Not selected" />
<OptionPicker variant="bars" options={levels} defaultValue="3" />

Native forms

name is the name of the radio group, so the value goes into FormData without any script. The form below works with JavaScript turned off.

import { Button } from "@/components/ui/button"

<form action={savePlan}>
  <OptionPicker name="plan" options={plans} defaultValue="starter" />
  <Button type="submit">Submit</Button>
</form>

Props

PropTypeDefaultDescription
optionsOptionPickerOption[]-List of options
valuestring-Selected value in controlled mode
defaultValuestring-Initial value in uncontrolled mode
onValueChange(value: string) => void-Called with the new value. Only inside client components
variant"segment" | "rows" | "tiles" | "slider" | "bars""segment"How the choice is drawn
namestring-Name of the radio group for forms
disabledbooleanfalseDisable the whole group
requiredboolean-The form is not sent until something is picked
emptyLabelstring"Not selected"Text of the slider before anything is picked
classNamestring-Additional CSS classes

OptionPickerOption

PropTypeDefaultDescription
valuestring-Unique value
labelstring-Visible text, also used as the accessible name
descriptionstring-Secondary text
iconReactNode-Icon before the label
disabledbooleanfalseOption cannot be picked