@k8ordo/ui

Radio

A group of radio buttons. Pass the options to options; onChange receives the chosen value.

Import

ts
import { Radio } from '@k8ordo/ui';

Usage

Framework

tsx
import { Radio } from '@k8ordo/ui';

const options = [
  { label: 'React', value: 'react' },
  { label: 'Vue', value: 'vue' },
  { label: 'Svelte', value: 'svelte' },
];

<p id="radio-label">Framework</p>
<Radio
  defaultValue="vue"
  disabled={false}
  aria-labelledby="radio-label"
  options={options}
/>

Controlled

Framework

tsx
const [value, setValue] = useState('react');

<p id="radio-controlled-label">Framework</p>
<Radio
  disabled={false}
  aria-labelledby="radio-controlled-label"
  onChange={(value) => setValue(value)}
  options={options}
  value={value}
/>

Disabled

Framework

tsx
<p id="radio-disabled-label">Framework</p>
<Radio
  defaultValue="vue"
  disabled
  aria-labelledby="radio-disabled-label"
  options={options}
/>

Props

aria-labelledby
Type: string
Default: -
options
Type: readonly Option[]
Default: -
defaultValue?
Type: string
Default: -
disabled?
Type: boolean
Default: false
invalid?
Type: boolean
Default: false
name?
Type: string
Default: -
onChange?
Type: (value: string, event: ChangeEvent<HTMLInputElement>) => void
Default: -
ref?
Type: Ref<HTMLDivElement>
Default: -
required?
Type: boolean
Default: false
value?
Type: string
Default: -
PropTypeDefault
aria-labelledbystring-
optionsreadonly Option[]-
defaultValue?string-
disabled?booleanfalse
invalid?booleanfalse
name?string-
onChange?(value: string, event: ChangeEvent<HTMLInputElement>) => void-
ref?Ref<HTMLDivElement>-
required?booleanfalse
value?string-

Inherited attributes (except the ones set internally): HTMLAttributes<HTMLDivElement>

k8ordo

React libraries that use Baseline features without holding back.