KKiotaPay UI
Browse documentation

Radio Group

The single-choice counterpart to Checkbox Group, with the same option-key API.

Installation

pnpm dlx shadcn@latest add https://kiotapay-ui-staging.staging.kiotapay.com/r/radio.json

Usage

'use client'

import { Radio } from '@/components/custom/radio'

export function LeaveTypeField({ types, value, onChange }) {
  return (
    <Radio
      label="Leave type"
      required
      data={types}
      value={value}
      onChange={onChange}
      searchPlaceholder=""
    />
  )
}

Props

PropTypeDefaultDescription
dataFieldOption[][]Options. Any object shape.
valueunknown—Matched against option[valueKey].
onChange(value: any) => void—Receives option[valueKey].
valueKeystring'value'Property read for the stored value.
labelKeystring | string[]'label'Property or properties read for the label.
labelstring—Required. Labels the group.
placeholderstring'Select an option...'Shown when the list is empty or filtered to nothing.
searchPlaceholderstring'Search...'Pass '' to hide the filter entirely.
disabledbooleanfalseBlocks every option.
errorbooleanfalseSwitches the group border to the danger ramp.
errorMessageReactNode—Shown only while error is true.

Behaviour notes

The group name is generated, not the label. Radio inputs are grouped by their name attribute, so using the visible heading merges any two groups that happen to share one — selecting in the first silently clears the second. Each instance gets its own generated id instead.

Native inputs underneath. The visible circle is styling over a real <input type="radio">, so arrow-key navigation within the group works exactly as the platform defines it.

Hide the filter on short lists. Under about eight options it is noise; pass searchPlaceholder="".