@atlaskit/radio
Version:
A radio input allows users to select only one option from a number of choices. Radio is generally displayed in a radio group.
68 lines (67 loc) • 2.73 kB
TypeScript
import React, { type SyntheticEvent } from 'react';
import { type UIAnalyticsEvent } from '@atlaskit/analytics-next';
import { type OptionsPropType, type RadioValue } from './types';
export interface RadioGroupProps {
id?: string;
/**
* Once set, controls the selected value on the `RadioGroup`.
*/
value?: RadioValue | null;
/**
* Sets the initial selected value on the `RadioGroup`.
*/
defaultValue?: RadioValue | null;
/**
* Sets the disabled state of all `Radio` elements in the group. Overrides the `isDisabled` setting of all child `Radio` items.
*/
isDisabled?: boolean;
/**
* Sets the required state of all `Radio` elements in the group.
*/
isRequired?: boolean;
/**
* Sets the invalid state of all `Radio` elements in the group.
*/
isInvalid?: boolean;
/**
* An array of objects, each object is mapped onto a `Radio` element within the group. Name must be unique to the group.
*/
options: OptionsPropType;
/**
* Function that gets fired after each invalid event.
*/
onInvalid?: (event: SyntheticEvent<any>) => void;
/**
* Function that gets after each change event.
*/
onChange?: (e: React.ChangeEvent<HTMLInputElement>, analyticsEvent: UIAnalyticsEvent) => void;
/**
* Sets the `name` prop on each of the `Radio` elements in the group.
*/
name?: string;
/**
* Additional information to be included in the `context` of analytics events that come from radio.
*/
analyticsContext?: Record<string, any>;
/**
* The id of the element that links to this radio group.
*
* @deprecated Use the `labelId` prop instead.
*/
'aria-labelledby'?: string;
/**
* This sets the `aria-labelledby` attribute. It sets an accessible name for
* the radio, for people who use assistive technology. Use of a visible label
* is highly recommended for greater accessibility support.
*/
labelId?: string;
/**
* A `testId` prop is provided for specified elements, which is a unique string that appears as a data attribute `data-testid` in the rendered code, serving as a hook for automated tests.
* The specified `testId` is applied to the root element of `RadioGroup`. If no `testId` is supplied in the `options` prop, then the one supplied to `RadioGroup` will also be propagated to
* the `Radio` children. Otherwise, the `testId` supplied in the `options` prop will be used.
*
* See [here](/components/radio/code#testId) for details about how `testId` is used on `Radio`.
*/
testId?: string;
}
export default function RadioGroup(props: RadioGroupProps): React.JSX.Element;