Skip to main content

Radio

Selects one option from a set; can be used standalone or composed with LhRadioGroup.

Basic usage​

Grouped radios

Selected: ink

import { useState } from 'react'
import { LhRadio, LhRadioGroup } from '@lh-ui/react'

export default function Demo() {
const [value, setValue] = useState('ink')

return (
<LhRadioGroup value={value} onChange={(val) => setValue(val as string)}>
<LhRadio value="ink">Ink</LhRadio>
<LhRadio value="danqing">Danqing</LhRadio>
<LhRadio value="blank">Blank</LhRadio>
</LhRadioGroup>
)
}

Radio Props​

PropDescriptionTypeOptionsDefault
valueOption value (required)unknown——
checkedControlled checked state (when used standalone)boolean——
defaultCheckedUncontrolled default checkedboolean—false
labelDisplay textstring——
disabledWhether to disableboolean—false
sizeSize'large' | 'middle' | 'small'—Follows ConfigProvider
nameNative name attribute (passed through by the Group)string——
sxShorthand layout propsSxProps——

Radio events​

EventDescriptionCallback signatureVue equivalent
onChangeEmitted when selected (two arguments)(checked: boolean, event: ChangeEvent) => void@change

RadioGroup Props​

PropDescriptionTypeDefault
valueControlled selected valueunknown—
defaultValueUncontrolled default valueunknown—
disabledDisable all childrenbooleanfalse
sizeChild size'large' | 'middle' | 'small'Follows ConfigProvider
nameNative name attribute passed through to childrenstring—

RadioGroup events​

EventDescriptionCallback signatureVue equivalent
onChangeEmitted when the selection changes; the callback argument is the option's value(value: unknown) => void@change
onChange argument difference

LhRadio's onChange callback is (checked, event); LhRadioGroup's onChange callback is directly the selected option's value — consistent with CheckboxGroup.

Styles​

import '@lh-ui/react/style/radio'