UNPKG

@base-ui-components/react

Version:

Base UI is a library of headless ('unstyled') React components and low-level hooks. You gain complete control over your app's CSS and accessibility features.

67 lines 2.37 kB
import * as React from 'react'; import type { BaseUIComponentProps } from "../utils/types.js"; import type { FieldRoot } from "../field/root/FieldRoot.js"; import type { BaseUIChangeEventDetails } from "../utils/createBaseUIEventDetails.js"; import { REASONS } from "../utils/reasons.js"; /** * Provides a shared state to a series of radio buttons. * Renders a `<div>` element. * * Documentation: [Base UI Radio Group](https://base-ui.com/react/components/radio) */ export declare const RadioGroup: React.ForwardRefExoticComponent<RadioGroupProps & React.RefAttributes<HTMLDivElement>>; export interface RadioGroupState extends FieldRoot.State { /** * Whether the user should be unable to select a different radio button in the group. */ readOnly: boolean | undefined; } export interface RadioGroupProps extends Omit<BaseUIComponentProps<'div', RadioGroup.State>, 'value'> { /** * Whether the component should ignore user interaction. * @default false */ disabled?: boolean; /** * Whether the user should be unable to select a different radio button in the group. * @default false */ readOnly?: boolean; /** * Whether the user must choose a value before submitting a form. * @default false */ required?: boolean; /** * Identifies the field when a form is submitted. */ name?: string; /** * The controlled value of the radio item that should be currently selected. * * To render an uncontrolled radio group, use the `defaultValue` prop instead. */ value?: unknown; /** * The uncontrolled value of the radio button that should be initially selected. * * To render a controlled radio group, use the `value` prop instead. */ defaultValue?: unknown; /** * Callback fired when the value changes. */ onValueChange?: (value: unknown, eventDetails: RadioGroup.ChangeEventDetails) => void; /** * A ref to access the hidden input element. */ inputRef?: React.Ref<HTMLInputElement>; } export type RadioGroupChangeEventReason = typeof REASONS.none; export type RadioGroupChangeEventDetails = BaseUIChangeEventDetails<RadioGroup.ChangeEventReason>; export declare namespace RadioGroup { type State = RadioGroupState; type Props = RadioGroupProps; type ChangeEventReason = RadioGroupChangeEventReason; type ChangeEventDetails = RadioGroupChangeEventDetails; }