# Radio Button
[component-header:sl-radio-button]
Radios buttons allow the user to select a single option from a group using a button-like control.
Radio buttons are designed to be used with [radio groups](/components/radio-group). When a radio button has focus, the arrow keys can be used to change the selected option just like standard radio controls.
```html preview
Option 1
Option 2
Option 3
```
```jsx react
import { SlRadioButton, SlRadioGroup } from '@shoelace-style/shoelace/dist/react';
const App = () => (
Option 1
Option 2
Option 3
);
```
## Examples
### Checked
To set the initial checked state, use the `checked` attribute.
```html preview
Option 1
Option 2
Option 3
```
```jsx react
import { SlRadioButton, SlRadioGroup } from '@shoelace-style/shoelace/dist/react';
const App = () => (
Option 1
Option 2
Option 3
);
```
### Disabled
Use the `disabled` attribute to disable a radio button.
```html preview
Option 1
Option 2
Option 3
```
```jsx react
import { SlRadioButton, SlRadioGroup } from '@shoelace-style/shoelace/dist/react';
const App = () => (
Option 1
Option 2
Option 3
);
```
### Sizes
Use the `size` attribute to change a radio button's size.
```html preview
Option 1
Option 2
Option 3
Option 1
Option 2
Option 3
Option 1
Option 2
Option 3
```
```jsx react
import { SlRadioButton, SlRadioGroup } from '@shoelace-style/shoelace/dist/react';
const App = () => (
Option 1
Option 2
Option 3
Option 1
Option 2
Option 3
Option 1
Option 2
Option 3
);
```
### Pill Buttons
Use the `pill` attribute to give radio buttons rounded edges.
```html preview
Option 1
Option 2
Option 3
Option 1
Option 2
Option 3
Option 1
Option 2
Option 3
```
```jsx react
import { SlRadioButton, SlRadioGroup } from '@shoelace-style/shoelace/dist/react';
const App = () => (
Option 1
Option 2
Option 3
Option 1
Option 2
Option 3
Option 1
Option 2
Option 3
);
```
### Prefix and Suffix Icons
Use the `prefix` and `suffix` slots to add icons.
```html preview
Option 1
Option 2
Option 3
```
```jsx react
import { SlIcon, SlRadioButton, SlRadioGroup } from '@shoelace-style/shoelace/dist/react';
const App = () => (
Option 1
Option 2
Option 3
);
```
### Buttons with Icons
You can omit button labels and use icons instead. Make sure to set a `label` attribute on each icon so screen readers will announce each option correctly.
```html preview
```
```jsx react
import { SlIcon, SlRadioButton, SlRadioGroup } from '@shoelace-style/shoelace/dist/react';
const App = () => (
);
```
### Custom Validity
Use the `setCustomValidity()` method to set a custom validation message. This will prevent the form from submitting and make the browser display the error message you provide. To clear the error, call this function with an empty string.
```html preview
```
```jsx react
import { useEffect, useRef } from 'react';
import { SlButton, SlIcon, SlRadioButton, SlRadioGroup } from '@shoelace-style/shoelace/dist/react';
const App = () => {
const radio = useRef(null);
const errorMessage = 'You must choose this option';
function handleChange(event) {
radio.current.setCustomValidity(radio.current.checked ? '' : errorMessage);
}
function handleSubmit(event) {
event.preventDefault();
alert('All fields are valid!');
}
useEffect(() => {
radio.current.setCustomValidity(errorMessage);
}, []);
return (
);
};
```
[component-metadata:sl-radio-button]