Docs
Radio Group
Radio Group
A set of checkable buttons—known as radio buttons—where no more than one of the buttons can be checked at a time.
Loading...
<script lang="ts">
import * as RadioGroup from "@/components/ui/radio-group";
import { Label } from "@/components/ui/label";
</script>
<RadioGroup.Root value="comfortable">
<div class="flex items-center space-x-2">
<RadioGroup.Item value="default" id="r1" />
<Label for="r1">Default</Label>
</div>
<div class="flex items-center space-x-2">
<RadioGroup.Item value="comfortable" id="r2" />
<Label for="r2">Comfortable</Label>
</div>
<div class="flex items-center space-x-2">
<RadioGroup.Item value="compact" id="r3" />
<Label for="r3">Compact</Label>
</div>
<RadioGroup.Input name="spacing" />
</RadioGroup.Root>
<script lang="ts">
import * as RadioGroup from "@/components/ui/radio-group";
import { Label } from "@/components/ui/label";
</script>
<RadioGroup.Root value="comfortable">
<div class="flex items-center space-x-2">
<RadioGroup.Item value="default" id="r1" />
<Label for="r1">Default</Label>
</div>
<div class="flex items-center space-x-2">
<RadioGroup.Item value="comfortable" id="r2" />
<Label for="r2">Comfortable</Label>
</div>
<div class="flex items-center space-x-2">
<RadioGroup.Item value="compact" id="r3" />
<Label for="r3">Compact</Label>
</div>
<RadioGroup.Input name="spacing" />
</RadioGroup.Root>
Installation
npx shadcn-svelte add radio-group
Usage
<script lang="ts">
import { Label } from "$components/ui/label";
import * as RadioGroup from "$components/ui/radio-group";
</script>
<RadioGroup.Root value="option-one">
<div class="flex items-center space-x-2">
<RadioGroup.Item value="option-one" id="option-one" />
<Label for="option-one">Option One</Label>
</div>
<div class="flex items-center space-x-2">
<RadioGroup.Item value="option-two" id="option-two" />
<Label for="option-two">Option Two</Label>
</div>
</RadioGroup.Root>
On This Page