Pular para o conteúdo

Radio API

Documentação da API para o componente React Radio . Aprenda sobre as propriedades disponíveis e a API CSS.

Demonstrações

For examples and details on the usage of this React component, visit the component demo pages:

Importação

import Radio from '@mui/material/Radio';
// ou
import { Radio } from '@mui/material';
Você pode aprender sobre a diferença lendo este guia sobre como minimizar o tamanho do pacote.

Nome do componente

The name MuiRadio can be used when providing default props or style overrides in the theme.

Propriedades

Propriedades do componente ButtonBase também estão disponíveis.

NomeTipoPadrãoDescrição
checkedboolfalse
If true, the component is checked.
checkedIconnode<RadioButtonIcon checked />
The icon to display when the component is checked.
classesobject
Sobrescreve ou extende os estilos aplicados para o componente. Veja a API CSS abaixo para maiores detalhes.
color'default'
| 'primary'
| 'secondary'
| 'error'
| 'info'
| 'success'
| 'warning'
| string
'primary'
The color of the component. It supports both default and custom theme colors, which can be added as shown in the palette customization guide.
disabledboolfalse
Se true, o componente está desabilitado.
disableRippleboolfalse
If true, the ripple effect is disabled.
iconnode<RadioButtonIcon />
The icon to display when the component is unchecked.
idstring
The id of the input element.
inputPropsobject
Attributes applied to the input element.
inputRefref
Pass a ref to the input element.
namestring
Name attribute of the input element.
onChangefunc
Callback fired when the state is changed.

Signature:
function(event: object) => void
event: The event source of the callback. You can pull out the new value by accessing event.target.value (string). You can pull out the new checked state by accessing event.target.checked (boolean).
requiredboolfalse
If true, the input element is required.
size'medium'
| 'small'
| string
'medium'
The size of the radio. small is equivalent to the dense radio styling.
sxArray<func
| object
| bool>
| func
| object
The system prop that allows defining system overrides as well as additional CSS styles. See the `sx` page for more details.
valueany
The value of the component. The DOM API casts this to a string.

O ref é encaminhado para o elemento raiz.

Herança

While not explicitly documented above, the props of the ButtonBase component are also available on Radio. You can take advantage of this to target nested components.

CSS

Nome da regraClasse globalDescrição
root.MuiRadio-rootEstilos aplicados ao elemento raiz.
checked.Mui-checkedPseudo-class aplicada a o elemento raiz se checked={true}.
disabled.Mui-disabledPseudo-class aplicada a o elemento raiz se disabled={true}.
colorPrimary.MuiRadio-colorPrimaryEstilos aplicados para o elemento raiz se color="primary".
colorSecondary.MuiRadio-colorSecondaryEstilos aplicados para o elemento raiz se color="secondary".

Você pode sobrescrever o estilo do componente usando uma dessas opções de customização: