UNPKG

@carbon/react

Version:

React components for the Carbon Design System

77 lines (76 loc) 2.47 kB
/** * 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'; type ExcludedAttributes = 'onChange'; export interface RadioButtonProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, ExcludedAttributes> { /** * Specify whether the `<RadioButton>` is currently checked */ checked?: boolean; /** * Provide an optional className to be applied to the containing node */ className?: string; /** * **Experimental**: Provide a `decorator` component to be rendered inside the `RadioButton` component */ decorator?: ReactNode; /** * Specify whether the `<RadioButton>` should be checked by default */ defaultChecked?: boolean; /** * Specify whether the control is disabled */ disabled?: boolean; /** * Specify whether the label should be hidden, or not */ hideLabel?: boolean; /** * Provide a unique id for the underlying `<input>` node */ id?: string; /** * Provide where label text should be placed * NOTE: `top`/`bottom` are deprecated */ labelPosition?: 'left' | 'right'; /** * Provide label text to be read by screen readers when interacting with the * control */ labelText: ReactNode; /** * Provide a name for the underlying `<input>` node */ name?: string; /** * Provide an optional `onChange` hook that is called each time the value of * the underlying `<input>` changes */ onChange?: (value: RadioButtonProps['value'], name: RadioButtonProps['name'], event: React.ChangeEvent<HTMLInputElement>) => void; /** * Provide a handler that is invoked when a user clicks on the control */ onClick?: (evt: React.MouseEvent<HTMLInputElement>) => void; /** * @deprecated please use decorator instead. * **Experimental**: Provide a `Slug` component to be rendered inside the `RadioButton` component */ slug?: ReactNode; /** * Specify the value of the `<RadioButton>` */ value?: string | number; /** * `true` to specify if the input is required. */ required?: boolean; } declare const RadioButton: React.ForwardRefExoticComponent<RadioButtonProps & React.RefAttributes<HTMLInputElement>>; export default RadioButton;