@humanonlyweb/ui 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (168) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +45 -2
  3. package/dist/components/accordion/Accordion.js +60 -0
  4. package/dist/components/accordion/Accordion.vue.d.ts +28 -0
  5. package/dist/components/accordion/AccordionItem.js +102 -0
  6. package/dist/components/accordion/AccordionItem.vue.d.ts +33 -0
  7. package/dist/components/avatar/Avatar.js +52 -0
  8. package/dist/components/avatar/Avatar.vue.d.ts +26 -0
  9. package/dist/components/avatar/AvatarGroup.js +48 -0
  10. package/dist/components/avatar/AvatarGroup.vue.d.ts +16 -0
  11. package/dist/components/breadcrumbs/Breadcrumbs.js +59 -0
  12. package/dist/components/breadcrumbs/Breadcrumbs.vue.d.ts +14 -0
  13. package/dist/components/button/Button.js +95 -0
  14. package/dist/components/button/Button.vue.d.ts +74 -0
  15. package/dist/components/button/IconButton.js +47 -0
  16. package/dist/components/button/IconButton.vue.d.ts +115 -0
  17. package/dist/components/checkbox/Checkbox.js +93 -0
  18. package/dist/components/checkbox/Checkbox.vue.d.ts +43 -0
  19. package/dist/components/checkbox-group/CheckboxGroup.js +89 -0
  20. package/dist/components/checkbox-group/CheckboxGroup.vue.d.ts +43 -0
  21. package/dist/components/combobox/Combobox.js +294 -0
  22. package/dist/components/combobox/Combobox.vue.d.ts +80 -0
  23. package/dist/components/context-menu/ContextMenu.js +170 -0
  24. package/dist/components/context-menu/ContextMenu.vue.d.ts +38 -0
  25. package/dist/components/dialog/ConfirmDialog.js +103 -0
  26. package/dist/components/dialog/ConfirmDialog.vue.d.ts +46 -0
  27. package/dist/components/dialog/Dialog.js +160 -0
  28. package/dist/components/dialog/Dialog.vue.d.ts +54 -0
  29. package/dist/components/field/FieldMessage.js +31 -0
  30. package/dist/components/fieldset/Fieldset.js +59 -0
  31. package/dist/components/fieldset/Fieldset.vue.d.ts +29 -0
  32. package/dist/components/input/Input.js +111 -0
  33. package/dist/components/input/Input.vue.d.ts +50 -0
  34. package/dist/components/kbd/Kbd.js +48 -0
  35. package/dist/components/kbd/Kbd.vue.d.ts +24 -0
  36. package/dist/components/menu/Menu.js +124 -0
  37. package/dist/components/menu/Menu.vue.d.ts +41 -0
  38. package/dist/components/otp-input/OtpInput.js +179 -0
  39. package/dist/components/otp-input/OtpInput.vue.d.ts +48 -0
  40. package/dist/components/pagination/Pagination.js +128 -0
  41. package/dist/components/pagination/Pagination.vue.d.ts +24 -0
  42. package/dist/components/password-input/PasswordInput.js +151 -0
  43. package/dist/components/password-input/PasswordInput.vue.d.ts +32 -0
  44. package/dist/components/popover/Popover.js +83 -0
  45. package/dist/components/popover/Popover.vue.d.ts +37 -0
  46. package/dist/components/progress/Progress.js +52 -0
  47. package/dist/components/progress/Progress.vue.d.ts +17 -0
  48. package/dist/components/radio-group/RadioGroup.js +125 -0
  49. package/dist/components/radio-group/RadioGroup.vue.d.ts +45 -0
  50. package/dist/components/segmented/Segmented.js +110 -0
  51. package/dist/components/segmented/Segmented.vue.d.ts +41 -0
  52. package/dist/components/select/Select.js +231 -0
  53. package/dist/components/select/Select.vue.d.ts +59 -0
  54. package/dist/components/slider/Slider.js +196 -0
  55. package/dist/components/slider/Slider.vue.d.ts +49 -0
  56. package/dist/components/spin-button/SpinButton.js +231 -0
  57. package/dist/components/spin-button/SpinButton.vue.d.ts +48 -0
  58. package/dist/components/split-button/SplitButton.js +69 -0
  59. package/dist/components/split-button/SplitButton.vue.d.ts +38 -0
  60. package/dist/components/switch/Switch.js +95 -0
  61. package/dist/components/switch/Switch.vue.d.ts +42 -0
  62. package/dist/components/table/Table.js +173 -0
  63. package/dist/components/table/Table.vue.d.ts +45 -0
  64. package/dist/components/tabs/Tabs.js +103 -0
  65. package/dist/components/tabs/Tabs.vue.d.ts +39 -0
  66. package/dist/components/tag-input/TagInput.js +186 -0
  67. package/dist/components/tag-input/TagInput.vue.d.ts +36 -0
  68. package/dist/components/textarea/Textarea.js +118 -0
  69. package/dist/components/textarea/Textarea.vue.d.ts +34 -0
  70. package/dist/components/toast/ToastItem.js +91 -0
  71. package/dist/components/toast/ToastItem.vue.d.ts +29 -0
  72. package/dist/components/toast/ToastViewport.js +56 -0
  73. package/dist/components/toast/ToastViewport.vue.d.ts +25 -0
  74. package/dist/components/toolbar/Toolbar.js +91 -0
  75. package/dist/components/toolbar/Toolbar.vue.d.ts +21 -0
  76. package/dist/components/tooltip/Tooltip.js +85 -0
  77. package/dist/components/tooltip/Tooltip.vue.d.ts +25 -0
  78. package/dist/components/visually-hidden/VisuallyHidden.js +16 -0
  79. package/dist/components/visually-hidden/VisuallyHidden.vue.d.ts +19 -0
  80. package/dist/composables/internal/env.js +5 -0
  81. package/dist/composables/internal/is-equal.js +14 -0
  82. package/dist/composables/internal/on-click-outside.js +18 -0
  83. package/dist/composables/internal/standard-schema.d.ts +38 -0
  84. package/dist/composables/internal/use-document-visibility.js +16 -0
  85. package/dist/composables/internal/use-event-listener.js +24 -0
  86. package/dist/composables/internal/use-interval-fn.js +21 -0
  87. package/dist/composables/internal/use-resize-observer.js +21 -0
  88. package/dist/composables/internal/use-timeout-fn.js +25 -0
  89. package/dist/composables/use-accordion.d.ts +9 -0
  90. package/dist/composables/use-accordion.js +10 -0
  91. package/dist/composables/use-combobox.d.ts +44 -0
  92. package/dist/composables/use-combobox.js +185 -0
  93. package/dist/composables/use-field.d.ts +17 -0
  94. package/dist/composables/use-field.js +27 -0
  95. package/dist/composables/use-form.d.ts +44 -0
  96. package/dist/composables/use-form.js +146 -0
  97. package/dist/composables/use-menu.d.ts +26 -0
  98. package/dist/composables/use-menu.js +117 -0
  99. package/dist/composables/use-platform.d.ts +17 -0
  100. package/dist/composables/use-platform.js +126 -0
  101. package/dist/composables/use-popover.d.ts +35 -0
  102. package/dist/composables/use-popover.js +49 -0
  103. package/dist/composables/use-roving-selection.d.ts +22 -0
  104. package/dist/composables/use-roving-selection.js +65 -0
  105. package/dist/composables/use-select.d.ts +31 -0
  106. package/dist/composables/use-select.js +169 -0
  107. package/dist/composables/use-slide-indicator.d.ts +24 -0
  108. package/dist/composables/use-slide-indicator.js +52 -0
  109. package/dist/composables/use-toast.d.ts +23 -0
  110. package/dist/composables/use-toast.js +51 -0
  111. package/dist/config.d.ts +40 -0
  112. package/dist/config.js +35 -0
  113. package/dist/docs/README.md +52 -0
  114. package/dist/docs/changelog.md +21 -0
  115. package/dist/docs/components/accordion.md +100 -0
  116. package/dist/docs/components/avatar-group.md +58 -0
  117. package/dist/docs/components/avatar.md +40 -0
  118. package/dist/docs/components/breadcrumbs.md +81 -0
  119. package/dist/docs/components/button.md +109 -0
  120. package/dist/docs/components/checkbox-group.md +118 -0
  121. package/dist/docs/components/checkbox.md +123 -0
  122. package/dist/docs/components/combobox.md +207 -0
  123. package/dist/docs/components/confirm-dialog.md +107 -0
  124. package/dist/docs/components/context-menu.md +98 -0
  125. package/dist/docs/components/dialog.md +127 -0
  126. package/dist/docs/components/fieldset.md +65 -0
  127. package/dist/docs/components/icon-button.md +47 -0
  128. package/dist/docs/components/input.md +89 -0
  129. package/dist/docs/components/kbd.md +41 -0
  130. package/dist/docs/components/menu.md +112 -0
  131. package/dist/docs/components/otp-input.md +92 -0
  132. package/dist/docs/components/pagination.md +62 -0
  133. package/dist/docs/components/password-input.md +55 -0
  134. package/dist/docs/components/popover.md +72 -0
  135. package/dist/docs/components/progress.md +56 -0
  136. package/dist/docs/components/radio-group.md +114 -0
  137. package/dist/docs/components/segmented.md +96 -0
  138. package/dist/docs/components/select.md +129 -0
  139. package/dist/docs/components/slider.md +105 -0
  140. package/dist/docs/components/spin-button.md +73 -0
  141. package/dist/docs/components/split-button.md +64 -0
  142. package/dist/docs/components/switch.md +71 -0
  143. package/dist/docs/components/table.md +241 -0
  144. package/dist/docs/components/tabs.md +106 -0
  145. package/dist/docs/components/tag-input.md +88 -0
  146. package/dist/docs/components/textarea.md +46 -0
  147. package/dist/docs/components/toast.md +135 -0
  148. package/dist/docs/components/toolbar.md +71 -0
  149. package/dist/docs/components/tooltip.md +57 -0
  150. package/dist/docs/components/visually-hidden.md +53 -0
  151. package/dist/docs/forms.md +182 -0
  152. package/dist/docs/index.md +11 -0
  153. package/dist/docs/installation.md +71 -0
  154. package/dist/docs/localisation.md +42 -0
  155. package/dist/docs/ssr.md +24 -0
  156. package/dist/docs/styling.md +82 -0
  157. package/dist/index.d.ts +60 -0
  158. package/dist/index.js +56 -0
  159. package/dist/nuxt/module.d.ts +15 -0
  160. package/dist/nuxt/module.js +80 -0
  161. package/dist/nuxt/runtime/plugin.d.ts +4 -0
  162. package/dist/nuxt/runtime/plugin.js +24 -0
  163. package/dist/package.js +4 -0
  164. package/dist/styles/core.css +310 -0
  165. package/dist/translations.d.ts +85 -0
  166. package/dist/translations.js +62 -0
  167. package/dist/types.d.ts +69 -0
  168. package/package.json +93 -4
@@ -0,0 +1,55 @@
1
+ # Password Input
2
+
3
+ > A password field with a show/hide toggle.
4
+
5
+ ## Examples
6
+
7
+ ### Basic
8
+
9
+ ```vue
10
+ <script setup lang="ts">
11
+ const password = ref("");
12
+ </script>
13
+
14
+ <template>
15
+ <div class="demo-field">
16
+ <UiPasswordInput
17
+ v-model="password"
18
+ label="Password"
19
+ hint="At least 8 characters."
20
+ autocomplete="current-password"
21
+ />
22
+ </div>
23
+ </template>
24
+ ```
25
+
26
+ ## API
27
+
28
+ | Prop | Type | Default | Description |
29
+ | --- | --- | --- | --- |
30
+ | `label` | `string` | — | Visible label, linked to the control. |
31
+ | `hint` | `string` | — | Help text under the control, announced as its description. |
32
+ | `error` | `string \| boolean` | — | `true` marks the control invalid; a string also shows it as the message, replacing the hint. |
33
+ | `optional` | `boolean` | `false` | Appends the `optional` translation to the label. |
34
+ | `disabled` | `boolean` | `false` | Disables the control and its reveal button. |
35
+ | `autocomplete` | `string` | `"current-password"` | Value of the native `autocomplete` attribute, e.g. `new-password` on a sign-up form. |
36
+ | `id` | `string` | — | Id for the control; generated with `useId()` when omitted. |
37
+ | `modelValue` | `string` | — | The password. |
38
+
39
+ | Event | Payload | Description |
40
+ | --- | --- | --- |
41
+ | `update:modelValue` | `[value: string \| undefined]` | `v-model:modelValue` update. |
42
+
43
+ ## Styling
44
+
45
+ Password Input reuses Input's parts, so the same styles apply; only the reveal button is new.
46
+
47
+ - Parts (`[data-part="…"]`): `field`, `field-label`, `field-optional`, `input-control`, `input`, `password-toggle`, `field-message`
48
+ - State attributes: `data-field-error`, `data-field-tone`
49
+
50
+ ## Accessibility
51
+
52
+ - The reveal button is a `type="button"` with `aria-pressed`, so it never submits the password by accident and its state is announced.
53
+ - Its name changes with the state: "Show password" while concealed, "Hide password" while revealed, both from the `translations` config.
54
+ - The label never changes between hidden and shown; the value stays in the field, and toggling never moves focus out of it.
55
+ - Revealing only switches the native input's `type`, so password managers and autofill keep working.
@@ -0,0 +1,72 @@
1
+ # Popover
2
+
3
+ > A non-modal panel anchored to a trigger.
4
+
5
+ ## Examples
6
+
7
+ ### Basic
8
+
9
+ ```vue
10
+ <script setup lang="ts">
11
+ const toast = useToast();
12
+ const email = ref("");
13
+
14
+ function invite(close: () => void) {
15
+ toast.success(`Invited ${email.value || "a teammate"}`);
16
+ email.value = "";
17
+ close();
18
+ }
19
+ </script>
20
+
21
+ <template>
22
+ <UiPopover label="Invite a teammate">
23
+ <template #trigger="{ attrs }">
24
+ <UiButton variant="secondary" v-bind="attrs">
25
+ <template #leading><Icon name="plus" :size="14" /></template>
26
+ Invite
27
+ </UiButton>
28
+ </template>
29
+
30
+ <template #default="{ close }">
31
+ <form class="demo-popover" @submit.prevent="invite(close)">
32
+ <UiInput v-model="email" type="email" label="Email" placeholder="ada@example.com" />
33
+ <UiButton type="submit" size="small" full-width>Send invite</UiButton>
34
+ </form>
35
+ </template>
36
+ </UiPopover>
37
+ </template>
38
+ ```
39
+
40
+ ## API
41
+
42
+ | Prop | Type | Default | Description |
43
+ | --- | --- | --- | --- |
44
+ | `label` (required) | `string` | — | Accessible name for the panel (role="dialog"). |
45
+ | `align` | `"end" \| "start"` | `"start"` | Which trigger edge the panel lines up with. Flips automatically near the viewport edge. |
46
+ | `open` | `boolean` | `false` | Whether the panel is open. |
47
+
48
+ | Event | Payload | Description |
49
+ | --- | --- | --- |
50
+ | `update:open` | `[value: boolean]` | `v-model:open` update. |
51
+
52
+ | Slot | Props | Description |
53
+ | --- | --- | --- |
54
+ | `trigger` | `{ isOpen: boolean; attrs: Record<string, unknown>; }` | The trigger. Bind `attrs` to a `<button>`. |
55
+ | `default` | `{ close: () => void; }` | Panel content. Mounted on first open. |
56
+
57
+ ## Styling
58
+
59
+ - Parts (`[data-part="…"]`): `popover-anchor`, `popover`
60
+ - State attributes: `data-popover-align`
61
+
62
+ ## Keyboard
63
+
64
+ | Keys | Action |
65
+ | ----------------- | -------------------------------------------- |
66
+ | `Enter` / `Space` | Toggle |
67
+ | `Escape` | Close and return focus to the trigger |
68
+ | `Tab` | Move through the panel; leaving it closes it |
69
+
70
+ ## Accessibility
71
+
72
+ - Focus moves into the panel on open.
@@ -0,0 +1,56 @@
1
+ # Progress
2
+
3
+ > A bar showing how far a task has got.
4
+
5
+ ## Examples
6
+
7
+ ### Basic
8
+
9
+ ```vue
10
+ <template>
11
+ <div class="demo-stack demo-field">
12
+ <UiProgress label="Uploading" :value="62" show-value />
13
+ <p class="demo-note">
14
+ The bar is 62% full; the percentage is repeated to the right, hidden from screen readers.
15
+ </p>
16
+ </div>
17
+ </template>
18
+ ```
19
+
20
+ ### Indeterminate
21
+
22
+ With no `value` — or a non-finite one — the length of the task isn't known.
23
+
24
+ ```vue
25
+ <template>
26
+ <div class="demo-stack demo-field">
27
+ <UiProgress label="Loading" />
28
+ <p class="demo-note">
29
+ With no value it's indeterminate: it shows work is happening, not how much.
30
+ </p>
31
+ </div>
32
+ </template>
33
+ ```
34
+
35
+ ## API
36
+
37
+ | Prop | Type | Default | Description |
38
+ | --- | --- | --- | --- |
39
+ | `value` | `number` | — | Current value. Omit it, or pass a non-finite number, for an indeterminate bar. |
40
+ | `max` | `number` | `100` | The value at which the bar is full. |
41
+ | `label` | `string` | — | Accessible name, e.g. "Uploading". |
42
+ | `valueText` | `string` | — | Spoken and displayed text for the value, e.g. "3 of 5 files". Defaults to a percentage. |
43
+ | `showValue` | `boolean` | `false` | Shows the value next to the bar. |
44
+
45
+ ## Styling
46
+
47
+ The indicator is placed with `--ui-progress`, a percentage from `0%` to `100%`. A root marked `data-progress-indeterminate` has no value to show.
48
+
49
+ - Parts (`[data-part="…"]`): `progress`, `progress-track`, `progress-indicator`, `progress-value`
50
+ - State attributes: `data-progress-indeterminate`
51
+
52
+ ## Accessibility
53
+
54
+ - The bar is a `role="progressbar"` with `aria-valuemin`, `aria-valuemax` and, when the value is known, `aria-valuenow`.
55
+ - `label` names the bar; `value-text` says the value in words, e.g. "3 of 5 files".
56
+ - An indeterminate bar has no `aria-valuenow`, so screen readers say it's working without a number.
@@ -0,0 +1,114 @@
1
+ # Radio Group
2
+
3
+ > A single choice from a list.
4
+
5
+ ## Examples
6
+
7
+ ### Basic
8
+
9
+ ```vue
10
+ <script setup lang="ts">
11
+ const plan = ref("pro");
12
+ const plans = [
13
+ { label: "Hobby — free", value: "hobby" },
14
+ { label: "Pro — $20/month", value: "pro" },
15
+ { label: "Enterprise — contact us", value: "enterprise", disabled: true },
16
+ ];
17
+ </script>
18
+
19
+ <template>
20
+ <UiRadioGroup v-model="plan" :options="plans" label="Plan" hint="You can change it any time." />
21
+ </template>
22
+ ```
23
+
24
+ ### Horizontal
25
+
26
+ ```vue
27
+ <script setup lang="ts">
28
+ const size = ref("m");
29
+ const sizes = ["xs", "s", "m", "l", "xl"].map((value) => ({ label: value.toUpperCase(), value }));
30
+ </script>
31
+
32
+ <template>
33
+ <UiRadioGroup v-model="size" :options="sizes" label="Size" orientation="horizontal" />
34
+ </template>
35
+ ```
36
+
37
+ ### Custom options
38
+
39
+ The `option` slot replaces each radio's content. Include `radio-control` to keep the circle.
40
+
41
+ ```vue
42
+ <script setup lang="ts">
43
+ const plan = ref("pro");
44
+ const plans = [
45
+ { label: "Hobby", value: "hobby", price: "Free", detail: "One project, community support" },
46
+ { label: "Pro", value: "pro", price: "$20/mo", detail: "Unlimited projects, email support" },
47
+ { label: "Team", value: "team", price: "$60/mo", detail: "Shared workspaces, SSO" },
48
+ ];
49
+ </script>
50
+
51
+ <template>
52
+ <UiRadioGroup v-model="plan" :options="plans" label="Plan" class="plan-cards">
53
+ <template #option="{ option }">
54
+ <span data-part="radio-control" aria-hidden="true" />
55
+ <span class="plan-text">
56
+ <strong>{{ option.label }}</strong>
57
+ <small>{{ plans.find((p) => p.value === option.value)?.detail }}</small>
58
+ </span>
59
+ <span class="plan-price">{{ plans.find((p) => p.value === option.value)?.price }}</span>
60
+ </template>
61
+ </UiRadioGroup>
62
+ </template>
63
+ ```
64
+
65
+ ## API
66
+
67
+ | Prop | Type | Default | Description |
68
+ | --- | --- | --- | --- |
69
+ | `options` | `SelectOption<T>[]` | `[]` | Radios to render, in order. |
70
+ | `label` | `string` | — | Visible group label, which names the radiogroup. |
71
+ | `hint` | `string` | — | Help text under the control, announced as its description. |
72
+ | `error` | `string \| boolean` | — | `true` marks the control invalid; a string also shows it as the message, replacing the hint. |
73
+ | `disabled` | `boolean` | `false` | Disables the control. |
74
+ | `orientation` | `"horizontal" \| "vertical"` | `"vertical"` | Layout hook, exposed as `data-orientation` and `aria-orientation`. |
75
+ | `name` | `string` | — | Form field name: submits the value with a native form, via hidden inputs. |
76
+ | `id` | `string` | — | Id for the control; generated with `useId()` when omitted. |
77
+ | `modelValue` | `T` | — | The selected value. |
78
+
79
+ | Event | Payload | Description |
80
+ | --- | --- | --- |
81
+ | `update:modelValue` | `[value: T \| undefined]` | `v-model:modelValue` update. |
82
+
83
+ | Slot | Props | Description |
84
+ | --- | --- | --- |
85
+ | `option` | `{ option: SelectOption<T>; checked: boolean; }` | Radio content, replacing the control and label. |
86
+
87
+ Types:
88
+
89
+ ```ts
90
+ export interface SelectOption<T extends SelectValue = SelectValue> {
91
+ label: string;
92
+ value: T;
93
+ disabled?: boolean;
94
+ }
95
+
96
+ export type SelectValue = string | number;
97
+ ```
98
+
99
+ ## Styling
100
+
101
+ - Parts (`[data-part="…"]`): `field`, `field-label`, `radio-group`, `radio`, `radio-control`, `radio-label`, `field-message`
102
+ - State attributes: `data-field-error`, `data-field-name`, `data-orientation`, `data-radio-checked`, `data-field-tone`
103
+
104
+ ## Keyboard
105
+
106
+ | Keys | Action |
107
+ | -------------- | ------------------------------------------ |
108
+ | `Tab` | Focus the selected radio |
109
+ | Arrow keys | Select the next / previous radio, wrapping |
110
+ | `Home` / `End` | Select the first / last radio |
111
+
112
+ ## Accessibility
113
+
114
+ - In right-to-left layouts, `←` / `→` follow the visual direction.
@@ -0,0 +1,96 @@
1
+ # Segmented
2
+
3
+ > A single choice shown as a row of buttons.
4
+
5
+ ## Examples
6
+
7
+ ### Basic
8
+
9
+ ```vue
10
+ <script setup lang="ts">
11
+ const view = ref("week");
12
+ const views = [
13
+ { label: "Day", value: "day" },
14
+ { label: "Week", value: "week" },
15
+ { label: "Month", value: "month" },
16
+ { label: "Year", value: "year" },
17
+ ];
18
+ </script>
19
+
20
+ <template>
21
+ <UiSegmented v-model="view" :options="views" label="Calendar view" />
22
+ </template>
23
+ ```
24
+
25
+ ### Icon only
26
+
27
+ The option labels become the buttons' names.
28
+
29
+ ```vue
30
+ <script setup lang="ts">
31
+ const style = ref<"bold" | "italic" | "underline">("bold");
32
+ const styles = [
33
+ { label: "Bold", value: "bold" },
34
+ { label: "Italic", value: "italic" },
35
+ { label: "Underline", value: "underline" },
36
+ ] as const;
37
+ </script>
38
+
39
+ <template>
40
+ <UiSegmented v-model="style" :options="[...styles]" label="Text style" size="small" icon-only>
41
+ <template #option="{ option }"><Icon :name="option.value" :size="14" /></template>
42
+ </UiSegmented>
43
+ </template>
44
+ ```
45
+
46
+ ## API
47
+
48
+ | Prop | Type | Default | Description |
49
+ | --- | --- | --- | --- |
50
+ | `options` | `SelectOption<T>[]` | `[]` | Segments to render, in order. |
51
+ | `label` | `string` | — | Accessible name for the group. |
52
+ | `size` | `"medium" \| "small"` | `"medium"` | Size hook, exposed as `data-segmented-size`. |
53
+ | `iconOnly` | `boolean` | `false` | Segments render only the `option` slot (e.g. an icon); labels become their accessible names. |
54
+ | `disabled` | `boolean` | `false` | Disables every segment. |
55
+ | `name` | `string` | — | Form field name: submits the value with a native form, via hidden inputs. |
56
+ | `modelValue` | `T` | — | The selected value. |
57
+
58
+ | Event | Payload | Description |
59
+ | --- | --- | --- |
60
+ | `update:modelValue` | `[value: T \| undefined]` | `v-model:modelValue` update. |
61
+
62
+ | Slot | Props | Description |
63
+ | --- | --- | --- |
64
+ | `option` | `{ option: SelectOption<T>; checked: boolean; }` | Segment content, e.g. an icon. |
65
+
66
+ Types:
67
+
68
+ ```ts
69
+ export interface SelectOption<T extends SelectValue = SelectValue> {
70
+ label: string;
71
+ value: T;
72
+ disabled?: boolean;
73
+ }
74
+
75
+ export type SelectValue = string | number;
76
+ ```
77
+
78
+ ## Styling
79
+
80
+ `--ui-indicator-x`, `--ui-indicator-width`, `--ui-indicator-top` and `--ui-indicator-height` place the indicator on the selected item.
81
+
82
+ - Parts (`[data-part="…"]`): `segmented`, `segmented-indicator`, `segment`
83
+ - State attributes: `data-field-name`, `data-segmented-size`, `data-segmented-icon-only`, `data-segmented-sliding`, `data-segmented-animate`, `data-segment-checked`
84
+
85
+ ## Keyboard
86
+
87
+ | Keys | Action |
88
+ | -------------- | ---------------------------------- |
89
+ | `Tab` | Focus the selected segment |
90
+ | Arrow keys | Select the next / previous segment |
91
+ | `Home` / `End` | Select the first / last segment |
92
+
93
+ ## Accessibility
94
+
95
+ - The indicator is measured in the browser, so also style `[data-segment-checked]` for the first paint.
96
+ - In right-to-left layouts, `←` / `→` follow the visual direction.
@@ -0,0 +1,129 @@
1
+ # Select
2
+
3
+ > A single or multiple choice from a dropdown.
4
+
5
+ ## Examples
6
+
7
+ ### Basic
8
+
9
+ ```vue
10
+ <script setup lang="ts">
11
+ const timezone = ref<string>("Europe/London");
12
+ const timezones = [
13
+ { label: "Lagos", value: "Africa/Lagos", offset: "UTC+1" },
14
+ { label: "London", value: "Europe/London", offset: "UTC+0" },
15
+ { label: "New York", value: "America/New_York", offset: "UTC−5" },
16
+ { label: "Tokyo", value: "Asia/Tokyo", offset: "UTC+9" },
17
+ { label: "Sydney", value: "Australia/Sydney", offset: "UTC+10", disabled: true },
18
+ ];
19
+ </script>
20
+
21
+ <template>
22
+ <div class="demo-field">
23
+ <UiSelect v-model="timezone" :options="timezones" label="Timezone">
24
+ <template #option="{ option, selected }">
25
+ <span class="option-label">{{ option.label }}</span>
26
+ <span class="option-detail">{{
27
+ timezones.find((t) => t.value === option.value)?.offset
28
+ }}</span>
29
+ <Icon v-if="selected" name="check" :size="14" class="option-check" />
30
+ </template>
31
+ </UiSelect>
32
+ </div>
33
+ </template>
34
+ ```
35
+
36
+ ### Multiple
37
+
38
+ ```vue
39
+ <script setup lang="ts">
40
+ const labels = ref(["bug", "docs"]);
41
+ const options = [
42
+ { label: "Bug", value: "bug", color: "oklch(0.68 0.19 25)" },
43
+ { label: "Feature", value: "feature", color: "oklch(0.72 0.15 250)" },
44
+ { label: "Docs", value: "docs", color: "oklch(0.75 0.14 150)" },
45
+ { label: "Question", value: "question", color: "oklch(0.8 0.14 85)" },
46
+ ];
47
+ const colorOf = (value: string | number) => options.find((o) => o.value === value)?.color;
48
+ </script>
49
+
50
+ <template>
51
+ <div class="demo-field">
52
+ <UiSelect v-model="labels" :options="options" label="Labels" placeholder="Add labels" multiple>
53
+ <template #value="{ selected, placeholder }">
54
+ <span v-if="selected.length" class="chips">
55
+ <span v-for="option in selected" :key="option.value" class="chip">
56
+ <span class="dot" :style="{ background: colorOf(option.value) }" />
57
+ {{ option.label }}
58
+ </span>
59
+ </span>
60
+ <template v-else>{{ placeholder }}</template>
61
+ </template>
62
+ <template #option="{ option, selected }">
63
+ <span class="dot" :style="{ background: colorOf(option.value) }" />
64
+ <span class="option-label">{{ option.label }}</span>
65
+ <Icon v-if="selected" name="check" :size="14" class="option-check" />
66
+ </template>
67
+ </UiSelect>
68
+ </div>
69
+ </template>
70
+ ```
71
+
72
+ ## API
73
+
74
+ | Prop | Type | Default | Description |
75
+ | --- | --- | --- | --- |
76
+ | `options` | `SelectOption<T>[]` | `[]` | Options to choose from. |
77
+ | `error` | `string \| boolean` | — | `true` marks the control invalid; a string also shows it as the message, replacing the hint. |
78
+ | `placeholder` | `string` | `"Select an option"` | Shown when nothing is selected. |
79
+ | `multiple` | `boolean` | `false` | Allow several selections; `v-model` becomes an array and the list stays open while picking. |
80
+ | `optional` | `boolean` | `false` | Appends the `optional` translation to the label. |
81
+ | `disabled` | `boolean` | `false` | Disables the control. |
82
+ | `label` | `string` | — | Visible label, linked to the control. |
83
+ | `hint` | `string` | — | Help text under the control, announced as its description. |
84
+ | `name` | `string` | — | Form field name: submits the value with a native form, via hidden inputs. |
85
+ | `id` | `string` | — | Id for the control; generated with `useId()` when omitted. |
86
+ | `modelValue` | `T \| T[]` | — | The selected value, or values with `multiple`. |
87
+
88
+ | Event | Payload | Description |
89
+ | --- | --- | --- |
90
+ | `update:modelValue` | `[value: T \| T[] \| undefined]` | `v-model:modelValue` update. |
91
+
92
+ | Slot | Props | Description |
93
+ | --- | --- | --- |
94
+ | `value` | `{ selected: SelectOption<T>[]; placeholder: string; }` | Trigger content, replacing the selected label or placeholder. |
95
+ | `option` | `{ option: SelectOption<T>; selected: boolean; active: boolean; }` | Option content. |
96
+ | `chevron` | — | Replaces the trigger's chevron. |
97
+ | `check` | — | Replaces the selected option's check mark. |
98
+
99
+ Types:
100
+
101
+ ```ts
102
+ export interface SelectOption<T extends SelectValue = SelectValue> {
103
+ label: string;
104
+ value: T;
105
+ disabled?: boolean;
106
+ }
107
+
108
+ export type SelectValue = string | number;
109
+ ```
110
+
111
+ ## Styling
112
+
113
+ - Parts (`[data-part="…"]`): `field`, `field-label`, `field-optional`, `select-control`, `select-trigger`, `select-value`, `select-chevron`, `select-listbox`, `select-option`, `select-option-check`, `select-option-label`, `field-message`
114
+ - State attributes: `data-field-error`, `data-field-name`, `data-select-open`, `data-select-error`, `data-select-placeholder`, `data-select-active`, `data-field-tone`
115
+
116
+ ## Keyboard
117
+
118
+ | Keys | Action |
119
+ | ----------------- | ---------------------------------------------------- |
120
+ | `↓` / `↑` | Open, then move between options |
121
+ | `Enter` / `Space` | Open, or select the active option |
122
+ | `Home` / `End` | First / last option |
123
+ | Any letter | Jump to an option by label; repeat a letter to cycle |
124
+ | `Tab` | Keep the active option and close |
125
+ | `Escape` | Close |
126
+
127
+ ## Accessibility
128
+
129
+ - Focus stays on the trigger; the active option is set with `aria-activedescendant`.
@@ -0,0 +1,105 @@
1
+ # Slider
2
+
3
+ > Pick a number, or a range, by dragging or with the keyboard.
4
+
5
+ ## Examples
6
+
7
+ ### Basic
8
+
9
+ ```vue
10
+ <script setup lang="ts">
11
+ const volume = ref(60);
12
+ </script>
13
+
14
+ <template>
15
+ <UiSlider v-model="volume" label="Volume" :format-value="(v) => `${v}%`" />
16
+ </template>
17
+ ```
18
+
19
+ ### Range
20
+
21
+ Bind a `[start, end]` array for two thumbs. `commit` fires when a drag ends, for anything expensive.
22
+
23
+ ```vue
24
+ <script setup lang="ts">
25
+ const price = ref<[number, number]>([200, 800]);
26
+ const toast = useToast();
27
+ </script>
28
+
29
+ <template>
30
+ <div class="demo-stack">
31
+ <UiSlider
32
+ v-model="price"
33
+ label="Price"
34
+ :min="0"
35
+ :max="1000"
36
+ :step="10"
37
+ :format-value="(v) => `$${v}`"
38
+ @commit="([low, high]) => toast.info(`Filtering $${low}–$${high}`)"
39
+ />
40
+ <p class="demo-note">${{ price[0] }} – ${{ price[1] }}</p>
41
+ </div>
42
+ </template>
43
+ ```
44
+
45
+ ### Vertical
46
+
47
+ ```vue
48
+ <script setup lang="ts">
49
+ const bass = ref(4);
50
+ const treble = ref(-2);
51
+ </script>
52
+
53
+ <template>
54
+ <div class="demo-row">
55
+ <UiSlider v-model="bass" orientation="vertical" label="Bass" :min="-12" :max="12" />
56
+ <UiSlider v-model="treble" orientation="vertical" label="Treble" :min="-12" :max="12" />
57
+ </div>
58
+ </template>
59
+ ```
60
+
61
+ ## API
62
+
63
+ | Prop | Type | Default | Description |
64
+ | --- | --- | --- | --- |
65
+ | `min` | `number` | `0` | Lowest value. |
66
+ | `max` | `number` | `100` | Highest value. |
67
+ | `step` | `number` | `1` | Arrow-key increment. Values snap to it. |
68
+ | `largeStep` | `number` | — | PageUp/PageDown increment. Defaults to ten steps. |
69
+ | `orientation` | `"horizontal" \| "vertical"` | `"horizontal"` | Layout hook, exposed as `data-orientation` and `aria-orientation`. |
70
+ | `disabled` | `boolean` | `false` | Disables the slider. |
71
+ | `label` | `string` | — | Visible label, which names the thumb(s). |
72
+ | `thumbLabels` | `[string, string]` | — | Accessible names for the two thumbs of a range. Default to `rangeStart` / `rangeEnd`. |
73
+ | `formatValue` | `((value: number) => string)` | — | Text for `aria-valuetext`, e.g. `(v) => \`${v}%\``. |
74
+ | `name` | `string` | — | Form field name; renders a hidden input per value. |
75
+ | `modelValue` | `T` | — | A number, or `[start, end]` for a range. Empty starts at `min`. |
76
+
77
+ | Event | Payload | Description |
78
+ | --- | --- | --- |
79
+ | `commit` | `[value: T]` | A drag ended, or a key changed the value. Use it for expensive work. |
80
+ | `update:modelValue` | `[value: T \| undefined]` | `v-model:modelValue` update. |
81
+
82
+ | Slot | Props | Description |
83
+ | --- | --- | --- |
84
+ | `thumb` | `{ value: number; index: number; }` | Thumb content, e.g. a value bubble. |
85
+
86
+ ## Styling
87
+
88
+ The range and thumbs are placed with `--ui-slider-start`, `--ui-slider-end` and `--ui-slider-value` (percentages).
89
+
90
+ - Parts (`[data-part="…"]`): `slider`, `slider-label`, `slider-control`, `slider-track`, `slider-range`, `slider-thumb`
91
+ - State attributes: `data-orientation`, `data-slider-disabled`, `data-slider-thumb`
92
+
93
+ ## Keyboard
94
+
95
+ | Keys | Action |
96
+ | ----------------------- | ---------------------------------- |
97
+ | `←` / `→`, `↓` / `↑` | One step |
98
+ | `Page Up` / `Page Down` | `largeStep` (ten steps by default) |
99
+ | `Home` / `End` | Minimum / maximum |
100
+
101
+ ## Accessibility
102
+
103
+ - Each thumb is named by `label`; a range's thumbs also get `thumb-labels` (“Minimum”, “Maximum”).
104
+ - Use `format-value` so screen readers hear units, e.g. “60%”.
105
+ - In right-to-left layouts, `←` / `→` follow the visual direction.