Skip to content

Commit a5053a5

Browse files
committed
docs(radio-button): add standalone example
1 parent 2324d37 commit a5053a5

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

docs/src/pages/components/RadioButton.svx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ components: ["RadioButtonGroup", "RadioButton", "RadioButtonSkeleton"]
1111

1212
## Default
1313

14+
`RadioButton` is intended to be used within a `RadioButtonGroup`. See [Standalone usage](#standalone-usage) for individual usage.
15+
1416
Create a group of radio buttons with a shared name and legend.
1517

1618
<RadioButtonGroup legendText="Storage tier (disk)" name="plan" selected="standard">
@@ -19,6 +21,12 @@ Create a group of radio buttons with a shared name and legend.
1921
<RadioButton labelText="Pro (128 GB)" value="pro" />
2022
</RadioButtonGroup>
2123

24+
## Standalone usage
25+
26+
Use `RadioButton` individually with a bindable `checked` prop for simple use cases.
27+
28+
<FileSource src="/framed/RadioButton/RadioButtonStandalone" />
29+
2230
## Hidden legend
2331

2432
Visually hide the legend while maintaining accessibility.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<script>
2+
import { RadioButton, Button } from "carbon-components-svelte";
3+
4+
let agreedToTerms = false;
5+
</script>
6+
7+
<div style:display="flex">
8+
<RadioButton
9+
bind:checked={agreedToTerms}
10+
labelText="I agree to the terms and conditions"
11+
name="terms"
12+
value="agreed"
13+
/>
14+
</div>
15+
16+
<div style:margin="var(--cds-layout-02) 0">
17+
<Button
18+
size="small"
19+
kind="secondary"
20+
disabled={!agreedToTerms}
21+
on:click={() => (agreedToTerms = !agreedToTerms)}
22+
>
23+
Reset
24+
</Button>
25+
</div>

0 commit comments

Comments
 (0)