@carbon/react
Version:
React components for the Carbon Design System
94 lines (93 loc) • 3.07 kB
TypeScript
/**
* Copyright IBM Corp. 2016, 2025
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
import React, { type ReactNode } from 'react';
import type { RadioButtonProps } from '../RadioButton';
export declare const RadioButtonGroupContext: React.Context<null>;
type ExcludedAttributes = 'onChange';
export interface RadioButtonGroupProps extends Omit<React.InputHTMLAttributes<HTMLFieldSetElement>, ExcludedAttributes> {
/**
* Provide a collection of `<RadioButton>` components to render in the group
*/
children?: ReactNode;
/**
* Provide an optional className to be applied to the container node
*/
className?: string;
/**
* **Experimental**: Provide a decorator component to be rendered inside the `RadioButtonGroup` component
*/
decorator?: ReactNode;
/**
* Specify the `<RadioButton>` to be selected by default
*/
defaultSelected?: RadioButtonProps['value'];
/**
* Specify whether the group is disabled
*/
disabled?: boolean;
/**
* Provide text that is used alongside the control label for additional help
*/
helperText?: ReactNode;
/**
* Specify whether the control is currently invalid
*/
invalid?: boolean;
/**
* Provide the text that is displayed when the control is in an invalid state
*/
invalidText?: ReactNode;
/**
* Provide where label text should be placed
*/
labelPosition?: 'left' | 'right';
/**
* Provide a legend to the RadioButtonGroup input that you are
* exposing to the user
*/
legendText?: ReactNode;
/**
* Specify the name of the underlying `<input>` nodes
*/
name: string;
/**
* Provide an optional `onChange` hook that is called whenever the value of
* the group changes
*/
onChange?: (selection: RadioButtonProps['value'], name: RadioButtonGroupProps['name'], event: React.ChangeEvent<HTMLInputElement>) => void;
/**
* Provide where radio buttons should be placed
*/
orientation?: 'horizontal' | 'vertical';
/**
* Whether the RadioButtonGroup should be read-only
*/
readOnly?: boolean;
/**
* @deprecated please use decorator instead.
* **Experimental**: Provide a `Slug` component to be rendered inside the `RadioButtonGroup` component
*/
slug?: ReactNode;
/**
* Specify whether the control is currently in warning state
*/
warn?: boolean;
/**
* Provide the text that is displayed when the control is in warning state
*/
warnText?: ReactNode;
/**
* Specify the value that is currently selected in the group
*/
valueSelected?: RadioButtonProps['value'];
/**
* `true` to specify if input selection in group is required.
*/
required?: boolean;
}
declare const RadioButtonGroup: React.ForwardRefExoticComponent<RadioButtonGroupProps & React.RefAttributes<unknown>>;
export default RadioButtonGroup;