Skip to content

Commit daca72d

Browse files
committed
docs(Single): document enroll and mandatory prop behaviors
1 parent c2b9d37 commit daca72d

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

  • apps/docs/src/pages/components/providers

apps/docs/src/pages/components/providers/single.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,37 @@ Radio-button-style single selection with size options that automatically deselec
3535

3636
:::
3737

38+
## Features
39+
40+
### Auto-Enrollment
41+
42+
Set `enroll` to automatically select the first registered item. Useful when items are rendered dynamically:
43+
44+
```vue
45+
<template>
46+
<!-- First item to register is selected automatically -->
47+
<Single.Root enroll v-model="selected">
48+
<Single.Item v-for="opt in options" :key="opt" :value="opt">
49+
{{ opt }}
50+
</Single.Item>
51+
</Single.Root>
52+
</template>
53+
```
54+
55+
### Mandatory Selection
56+
57+
Use `mandatory` to prevent deselecting the currently selected item. Use `mandatory="force"` to also auto-select the first item on mount:
58+
59+
```vue
60+
<template>
61+
<!-- User cannot deselect — at least one item must remain selected -->
62+
<Single.Root mandatory v-model="selected">
63+
<Single.Item value="a">Option A</Single.Item>
64+
<Single.Item value="b">Option B</Single.Item>
65+
</Single.Root>
66+
</template>
67+
```
68+
3869
## Anatomy
3970

4071
```vue Anatomy playground

0 commit comments

Comments
 (0)