shoelace/docs/components/radio.md

35 wiersze
983 B
Markdown
Czysty Zwykły widok Historia

2020-07-15 21:30:37 +00:00
# Radio
[component-header:sl-radio]
Radios allow the user to select one option from a group of many.
2021-04-09 12:15:33 +00:00
Radios are designed to be used with [radio groups](/components/radio-group). As such, all of the examples on this page utilize them to demonstrate their correct usage.
2020-07-15 21:30:37 +00:00
```html preview
2021-04-09 12:15:33 +00:00
<sl-radio-group label="Select an option" no-fieldset>
<sl-radio value="1" checked>Option 1</sl-radio>
<sl-radio value="2">Option 2</sl-radio>
<sl-radio value="3">Option 3</sl-radio>
</sl-radio-group>
2020-07-15 21:30:37 +00:00
```
2021-05-13 13:11:24 +00:00
?> This component doesn't work with standard forms. Use [`<sl-form>`](/components/form) instead.
2020-07-15 21:30:37 +00:00
## Examples
### Disabled
2021-04-09 12:15:33 +00:00
Use the `disabled` attribute to disable a radio.
2020-07-15 21:30:37 +00:00
```html preview
2021-04-09 12:15:33 +00:00
<sl-radio-group label="Select an option" no-fieldset>
<sl-radio value="1" checked>Option 1</sl-radio>
<sl-radio value="2">Option 2</sl-radio>
<sl-radio value="3">Option 3</sl-radio>
<sl-radio value="4" disabled>Disabled</sl-radio>
</sl-radio-group>
2020-07-15 21:30:37 +00:00
```
[component-metadata:sl-radio]