UNPKG

@yamada-ui/radio

Version:

Yamada UI radio component

59 lines (56 loc) 1.93 kB
import * as react from 'react'; import { ChangeEvent } from 'react'; import { PropGetter } from '@yamada-ui/core'; import { Dict } from '@yamada-ui/utils'; interface UseRadioGroupProps<Y extends number | string = string> { /** * The top-level id string that will be applied to the radios. * The index of the radio will be appended to this top-level id. */ id?: string; /** * The HTML `name` attribute used for forms. */ name?: string; /** * The initial value of the radio group. */ defaultValue?: Y; /** * If `true`, input elements will receive `checked` attribute instead of `isChecked`. * * This assumes, you're using native radio inputs. * * @default false * * @deprecated It will be deprecated in version 2.0. */ isNative?: boolean; /** * The value of the radio group. */ value?: Y; /** * The callback fired when any children radio is checked or unchecked. */ onChange?: (value: Y) => void; } declare const useRadioGroup: <Y extends number | string, M extends Dict = Dict>({ id, name, defaultValue, isNative, value: valueProp, onChange: onChangeProp, ...props }: M & UseRadioGroupProps<Y>) => { id: string; name: string; props: Omit<M & UseRadioGroupProps<Y>, "value" | "defaultValue" | "name" | "id" | "onChange" | "isNative">; setValue: react.Dispatch<react.SetStateAction<Y>>; value: Y; getContainerProps: PropGetter<"div", undefined>; getRadioProps: PropGetter<{ value?: Y; }, { checked?: boolean; isChecked?: boolean; value?: Y; }>; onChange: (evOrValue: ChangeEvent<HTMLInputElement> | Y) => void; onFocus: () => void; }; type UseRadioGroupReturn<Y extends number | string = string> = ReturnType<typeof useRadioGroup<Y>>; export { type UseRadioGroupProps, type UseRadioGroupReturn, useRadioGroup };