@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,73 @@
1
+ # Spin Button
2
+
3
+ > A number input with step buttons.
4
+
5
+ ## Examples
6
+
7
+ ### Basic
8
+
9
+ ```vue
10
+ <script setup lang="ts">
11
+ const seats = ref(3);
12
+ </script>
13
+
14
+ <template>
15
+ <UiSpinButton v-model="seats" label="Seats" :min="1" :max="50" hint="Between 1 and 50." />
16
+ </template>
17
+ ```
18
+
19
+ ### Decimal step
20
+
21
+ Values round to the step's precision.
22
+
23
+ ```vue
24
+ <script setup lang="ts">
25
+ const opacity = ref(0.8);
26
+ </script>
27
+
28
+ <template>
29
+ <UiSpinButton v-model="opacity" label="Opacity" :min="0" :max="1" :step="0.05" />
30
+ </template>
31
+ ```
32
+
33
+ ## API
34
+
35
+ | Prop | Type | Default | Description |
36
+ | --- | --- | --- | --- |
37
+ | `id` | `string` | — | Id for the control; generated with `useId()` when omitted. |
38
+ | `min` | `number` | `Number.NEGATIVE_INFINITY` | Lowest value. Home jumps here. |
39
+ | `max` | `number` | `Number.POSITIVE_INFINITY` | Highest value. End jumps here. |
40
+ | `step` | `number` | `1` | Arrow-key and button increment; PageUp/PageDown move ten steps. Its decimals set the rounding. |
41
+ | `hint` | `string` | — | Help text under the control, announced as its description. |
42
+ | `label` | `string` | — | Visible label, linked to the control. |
43
+ | `optional` | `boolean` | `false` | Appends the `optional` translation to the label. |
44
+ | `disabled` | `boolean` | `false` | Disables the control. |
45
+ | `error` | `string \| boolean` | — | `true` marks the control invalid; a string also shows it as the message, replacing the hint. |
46
+ | `modelValue` | `number` | — | The value. `undefined` while the input is empty. |
47
+
48
+ | Event | Payload | Description |
49
+ | --- | --- | --- |
50
+ | `update:modelValue` | `[value: number \| undefined]` | `v-model:modelValue` update. |
51
+
52
+ | Slot | Props | Description |
53
+ | --- | --- | --- |
54
+ | `decrement` | — | Decrease button icon. |
55
+ | `increment` | — | Increase button icon. |
56
+
57
+ ## Styling
58
+
59
+ - Parts (`[data-part="…"]`): `field`, `field-label`, `field-optional`, `spinbutton`, `spinbutton-decrement`, `spinbutton-input`, `spinbutton-increment`, `field-message`
60
+ - State attributes: `data-field-error`, `data-spinbutton-error`, `data-spinbutton-disabled`, `data-field-tone`
61
+
62
+ ## Keyboard
63
+
64
+ | Keys | Action |
65
+ | ----------------------- | ----------------- |
66
+ | `↑` / `↓` | Step up / down |
67
+ | `Page Up` / `Page Down` | Ten steps |
68
+ | `Home` / `End` | Minimum / maximum |
69
+
70
+ ## Accessibility
71
+
72
+ - The buttons repeat while held and are skipped by Tab.
73
+ - Values are clamped and rounded on blur.
@@ -0,0 +1,64 @@
1
+ # Split Button
2
+
3
+ > A main action with a menu of alternatives.
4
+
5
+ ## Examples
6
+
7
+ ### With a menu
8
+
9
+ Pass the menu's trigger `attrs` to `trigger-attrs`.
10
+
11
+ ```vue
12
+ <script setup lang="ts">
13
+ const toast = useToast();
14
+ const options = [
15
+ { label: "Save as draft", value: "draft" },
16
+ { label: "Save and publish", value: "publish" },
17
+ { label: "Save a copy", value: "copy" },
18
+ ];
19
+ </script>
20
+
21
+ <template>
22
+ <UiMenu :items="options" align="end" @select="(value) => toast.success(`Saved (${value})`)">
23
+ <template #trigger="{ attrs }">
24
+ <UiSplitButton
25
+ variant="primary"
26
+ menu-label="More save options"
27
+ :trigger-attrs="attrs"
28
+ @action="toast.success('Saved')"
29
+ >
30
+ Save
31
+ </UiSplitButton>
32
+ </template>
33
+ </UiMenu>
34
+ </template>
35
+ ```
36
+
37
+ ## API
38
+
39
+ | Prop | Type | Default | Description |
40
+ | --- | --- | --- | --- |
41
+ | `menuLabel` (required) | `string` | — | Accessible name for the toggle half, e.g. "More save options". |
42
+ | `triggerAttrs` | `Record<string, unknown>` | — | The `attrs` from a `<Menu>` or `<Popover>` trigger slot, bound to the toggle half. |
43
+ | `variant` | `"danger" \| "ghost" \| "primary" \| "secondary" \| "solid"` | `"secondary"` | Style hook, exposed as `data-button-variant` on both halves. |
44
+ | `size` | `"medium" \| "small"` | `"medium"` | Size hook, exposed as `data-button-size` on both halves. |
45
+ | `disabled` | `boolean` | `false` | Disables both halves. |
46
+
47
+ | Event | Payload | Description |
48
+ | --- | --- | --- |
49
+ | `action` | `[]` | The main half was pressed. |
50
+ | `toggle` | `[]` | The toggle half was pressed. |
51
+
52
+ | Slot | Props | Description |
53
+ | --- | --- | --- |
54
+ | `default` | — | Main action label. |
55
+ | `caret` | `{ open: boolean; }` | Replaces the toggle's chevron. |
56
+
57
+ ## Styling
58
+
59
+ - Parts (`[data-part="…"]`): `split-button`, `button-label`
60
+ - State attributes: `data-split-variant`, `data-split-part`, `data-split-open`
61
+
62
+ ## Accessibility
63
+
64
+ - Name the toggle with `menu-label`.
@@ -0,0 +1,71 @@
1
+ # Switch
2
+
3
+ > An on/off toggle.
4
+
5
+ ## Examples
6
+
7
+ ### Basic
8
+
9
+ ```vue
10
+ <script setup lang="ts">
11
+ const notifications = ref(true);
12
+ const marketing = ref(false);
13
+ </script>
14
+
15
+ <template>
16
+ <div class="demo-stack">
17
+ <UiSwitch v-model="notifications" label="Push notifications" />
18
+ <UiSwitch v-model="marketing" label="Product updates" size="small" />
19
+ <UiSwitch :model-value="true" label="Required" disabled />
20
+ </div>
21
+ </template>
22
+ ```
23
+
24
+ ### Hint
25
+
26
+ Like other fields, `hint` and `error` show under the label and are read as its description.
27
+
28
+ ```vue
29
+ <script setup lang="ts">
30
+ const digest = ref(true);
31
+ </script>
32
+
33
+ <template>
34
+ <div class="demo-stack">
35
+ <UiSwitch v-model="digest" label="Weekly digest" hint="A summary every Monday morning." />
36
+ </div>
37
+ </template>
38
+ ```
39
+
40
+ ## API
41
+
42
+ | Prop | Type | Default | Description |
43
+ | --- | --- | --- | --- |
44
+ | `disabled` | `boolean` | `false` | Disables the switch. |
45
+ | `label` | `string` | — | Text next to the switch. The default slot overrides it. |
46
+ | `size` | `"medium" \| "small"` | `"medium"` | Size hook, exposed as `data-switch-size`. |
47
+ | `hint` | `string` | — | Help text under the switch, announced as its description. |
48
+ | `error` | `string \| boolean` | — | `true` marks it invalid; a string also shows it as the message, replacing the hint. |
49
+ | `name` | `string` | — | Form field name: while on, a native form submits `value` under it. |
50
+ | `value` | `string` | `"on"` | What a native form submits while on, as a checkbox would. |
51
+ | `id` | `string` | — | Id for the switch; generated with `useId()` when omitted. |
52
+ | `modelValue` | `boolean` | `false` | On or off. |
53
+
54
+ | Event | Payload | Description |
55
+ | --- | --- | --- |
56
+ | `update:modelValue` | `[value: boolean]` | `v-model:modelValue` update. |
57
+
58
+ | Slot | Props | Description |
59
+ | --- | --- | --- |
60
+ | `default` | — | Label content, replacing `label`. |
61
+
62
+ ## Styling
63
+
64
+ - Parts (`[data-part="…"]`): `switch`, `switch-track`, `switch-thumb`, `switch-label`, `field-message`
65
+ - State attributes: `data-switch-size`, `data-switch-checked`, `data-switch-error`, `data-field-name`, `data-field-tone`
66
+
67
+ ## Keyboard
68
+
69
+ | Keys | Action |
70
+ | ----------------- | ------ |
71
+ | `Space` / `Enter` | Toggle |
@@ -0,0 +1,241 @@
1
+ # Table
2
+
3
+ > A data table with custom cells.
4
+
5
+ ## Examples
6
+
7
+ ### Basic
8
+
9
+ ```vue
10
+ <script setup lang="ts">
11
+ const columns = [
12
+ { key: "name", header: "Member" },
13
+ { key: "role", header: "Role" },
14
+ { key: "commits", header: "Commits", numeric: true },
15
+ ];
16
+
17
+ const rows = [
18
+ {
19
+ id: 1,
20
+ name: "Ada Lovelace",
21
+ email: "ada@example.com",
22
+ avatar: "/avatars/ada.svg",
23
+ role: "Maintainer",
24
+ commits: 1243,
25
+ },
26
+ {
27
+ id: 2,
28
+ name: "Grace Hopper",
29
+ email: "grace@example.com",
30
+ avatar: "/avatars/grace.svg",
31
+ role: "Reviewer",
32
+ commits: 812,
33
+ },
34
+ { id: 3, name: "Alan Turing", email: "alan@example.com", role: "Contributor", commits: 97 },
35
+ ];
36
+ </script>
37
+
38
+ <template>
39
+ <UiTable :columns="columns" :rows="rows" row-key="id" caption="Contributors">
40
+ <template #name-cell="{ row }">
41
+ <span class="person">
42
+ <UiAvatar :name="row.name" :src="row.avatar" size="small" />
43
+ <span>
44
+ {{ row.name }}
45
+ <small>{{ row.email }}</small>
46
+ </span>
47
+ </span>
48
+ </template>
49
+ <template #role-cell="{ value }">
50
+ <span class="badge" :data-tone="value === 'Maintainer' ? 'accent' : undefined">{{
51
+ value
52
+ }}</span>
53
+ </template>
54
+ <template #commits-cell="{ value }">{{ (value as number).toLocaleString("en-US") }}</template>
55
+ </UiTable>
56
+ </template>
57
+ ```
58
+
59
+ ### Custom cells
60
+
61
+ Replace any cell, header or footer with the `<key>-cell`, `<key>-header` and `<key>-footer` slots.
62
+
63
+ ```vue
64
+ <script setup lang="ts">
65
+ interface Invoice {
66
+ id: string;
67
+ customer: string;
68
+ status: "paid" | "due" | "overdue";
69
+ amount: number;
70
+ }
71
+
72
+ const columns = [
73
+ { key: "id", header: "Invoice" },
74
+ { key: "status", header: "Status" },
75
+ { key: "amount", header: "Amount", numeric: true },
76
+ { key: "actions", header: "", align: "right" as const, width: "64px" as const },
77
+ ];
78
+
79
+ const rows: Invoice[] = [
80
+ { id: "INV-001", customer: "Acme Inc.", status: "paid", amount: 1200 },
81
+ { id: "INV-002", customer: "Globex", status: "due", amount: 860 },
82
+ { id: "INV-003", customer: "Initech", status: "overdue", amount: 2400 },
83
+ ];
84
+
85
+ const tones = { paid: "success", due: "warning", overdue: "danger" } as const;
86
+ const total = rows.reduce((sum, row) => sum + row.amount, 0);
87
+ const money = (value: number) => `$${value.toLocaleString("en-US")}`;
88
+
89
+ const toast = useToast();
90
+ const actions = [
91
+ { label: "View", value: "view" },
92
+ { label: "Download PDF", value: "download" },
93
+ { label: "Void", value: "void" },
94
+ ];
95
+ </script>
96
+
97
+ <template>
98
+ <UiTable :columns="columns" :rows="rows" row-key="id">
99
+ <template #id-cell="{ row }">
100
+ <span class="stacked">
101
+ {{ row.id }}
102
+ <small>{{ row.customer }}</small>
103
+ </span>
104
+ </template>
105
+ <template #status-cell="{ row }">
106
+ <span class="badge" :data-tone="tones[row.status]">{{ row.status }}</span>
107
+ </template>
108
+ <template #amount-cell="{ row }">{{ money(row.amount) }}</template>
109
+ <template #amount-footer>{{ money(total) }}</template>
110
+ <template #actions-cell="{ row }">
111
+ <UiMenu :items="actions" align="end" @select="(action) => toast.info(`${action} ${row.id}`)">
112
+ <template #trigger="{ attrs }">
113
+ <UiIconButton :label="`Actions for ${row.id}`" size="small" v-bind="attrs">
114
+ <Icon name="more" :size="14" />
115
+ </UiIconButton>
116
+ </template>
117
+ </UiMenu>
118
+ </template>
119
+ </UiTable>
120
+ </template>
121
+ ```
122
+
123
+ ### Sorting
124
+
125
+ Mark a column `sortable` and its header becomes a button that sets `v-model:sort`. The table doesn't reorder rows: sort them yourself, or on the server.
126
+
127
+ ```vue
128
+ <script setup lang="ts">
129
+ import type { TableSort } from "@humanonlyweb/ui";
130
+
131
+ const columns = [
132
+ { key: "name", header: "Package", sortable: true },
133
+ { key: "size", header: "Size (kB)", numeric: true, sortable: true },
134
+ { key: "downloads", header: "Weekly downloads", numeric: true, sortable: true },
135
+ ];
136
+
137
+ const packages = [
138
+ { name: "vue", size: 112, downloads: 7_100_000 },
139
+ { name: "nuxt", size: 820, downloads: 1_050_000 },
140
+ { name: "vite", size: 3_900, downloads: 31_000_000 },
141
+ { name: "zod", size: 590, downloads: 26_000_000 },
142
+ ];
143
+
144
+ const sort = ref<TableSort>({ key: "downloads", direction: "descending" });
145
+
146
+ // The table only reports the sort; ordering the rows (here, or on a server) is yours.
147
+ const rows = computed(() => {
148
+ const { key, direction } = sort.value;
149
+ const sign = direction === "ascending" ? 1 : -1;
150
+ return packages.toSorted((a, b) => {
151
+ const x = a[key as keyof typeof a];
152
+ const y = b[key as keyof typeof b];
153
+ return (
154
+ (typeof x === "number" && typeof y === "number"
155
+ ? x - y
156
+ : String(x).localeCompare(String(y))) * sign
157
+ );
158
+ });
159
+ });
160
+ </script>
161
+
162
+ <template>
163
+ <UiTable v-model:sort="sort" :columns="columns" :rows="rows" row-key="name" caption="Packages">
164
+ <template #downloads-cell="{ value }">{{ Number(value).toLocaleString("en-US") }}</template>
165
+ </UiTable>
166
+ </template>
167
+ ```
168
+
169
+ ### Empty
170
+
171
+ ```vue
172
+ <script setup lang="ts">
173
+ const columns = [
174
+ { key: "name", header: "Name" },
175
+ { key: "email", header: "Email" },
176
+ ];
177
+ </script>
178
+
179
+ <template>
180
+ <UiTable :columns="columns" :rows="[]" caption="Members">
181
+ <template #empty>
182
+ <div class="empty">
183
+ <p>No members yet</p>
184
+ <UiButton size="small" variant="secondary">
185
+ <template #leading><Icon name="plus" :size="14" /></template>
186
+ Invite someone
187
+ </UiButton>
188
+ </div>
189
+ </template>
190
+ </UiTable>
191
+ </template>
192
+ ```
193
+
194
+ ## API
195
+
196
+ | Prop | Type | Default | Description |
197
+ | --- | --- | --- | --- |
198
+ | `columns` (required) | `TableColumn<T>[]` | — | Column definitions: `key`, `header`, and optional `accessor`, `align`, `numeric`, `width`. |
199
+ | `rows` (required) | `T[]` | — | Row data. |
200
+ | `rowKey` | `((row: T, index: number) => PropertyKey) \| keyof T` | — | Stable key per row: a property name or a function. Defaults to the index. |
201
+ | `caption` | `string` | — | Visible caption. Also names the scroll region. |
202
+ | `sort` | `TableSort` | — | The sorted column and direction, set by `sortable` columns' headers. Rows aren't reordered for you. |
203
+
204
+ | Event | Payload | Description |
205
+ | --- | --- | --- |
206
+ | `update:sort` | `[value: TableSort \| undefined]` | `v-model:sort` update. |
207
+
208
+ | Slot | Props | Description |
209
+ | --- | --- | --- |
210
+ | `empty` | — | Shown when there are no rows. |
211
+ | `sort-indicator` | `{ direction: "ascending" \| "descending" \| undefined; }` | Replaces a sortable header's direction arrow. |
212
+
213
+ Types:
214
+
215
+ ```ts
216
+ export interface TableColumn<T> {
217
+ key: string;
218
+ header: string;
219
+ accessor?: (row: T) => unknown;
220
+ align?: TdHTMLAttributes["align"];
221
+ numeric?: boolean;
222
+ width?: `${number}px` | `${number}%`;
223
+ /** Its header becomes a button that sets the table's `v-model:sort`. */
224
+ sortable?: boolean;
225
+ }
226
+
227
+ /** A table's sort: which column, which way. Sorting the rows is up to you. */
228
+ export interface TableSort {
229
+ key: string;
230
+ direction: "ascending" | "descending";
231
+ }
232
+ ```
233
+
234
+ ## Styling
235
+
236
+ - Parts (`[data-part="…"]`): `table-scroll`, `table`, `table-caption`, `table-header`, `table-row`, `table-cell`, `table-sort`, `table-sort-indicator`, `table-empty`, `table-footer`
237
+ - State attributes: `data-table-overflow`, `data-table-align`, `data-table-numeric`, `data-table-sort`
238
+
239
+ ## Accessibility
240
+
241
+ - A table wider than its container scrolls in a region named by `caption`, focusable so the keyboard can scroll it.
@@ -0,0 +1,106 @@
1
+ # Tabs
2
+
3
+ > Panels switched by tabs.
4
+
5
+ ## Examples
6
+
7
+ ### Basic
8
+
9
+ ```vue
10
+ <script setup lang="ts">
11
+ const tab = ref("overview");
12
+ const tabs = [
13
+ { label: "Overview", value: "overview" },
14
+ { label: "Activity", value: "activity" },
15
+ { label: "Settings", value: "settings" },
16
+ { label: "Billing", value: "billing", disabled: true },
17
+ ];
18
+ </script>
19
+
20
+ <template>
21
+ <UiTabs v-model="tab" :items="tabs" label="Project" class="demo-wide" v-slot="{ value }">
22
+ <p v-if="value === 'overview'">A summary of the project.</p>
23
+ <p v-else-if="value === 'activity'">Recent commits and comments.</p>
24
+ <p v-else>Name, visibility and danger zone.</p>
25
+ </UiTabs>
26
+ </template>
27
+ ```
28
+
29
+ ### Counts
30
+
31
+ The `tab` slot replaces each tab's text, e.g. to add a count.
32
+
33
+ ```vue
34
+ <script setup lang="ts">
35
+ const tab = ref("open");
36
+ const tabs = [
37
+ { label: "Open", value: "open", count: 12 },
38
+ { label: "In review", value: "review", count: 3 },
39
+ { label: "Closed", value: "closed", count: 148 },
40
+ ];
41
+ const countOf = (value?: string) => tabs.find((t) => t.value === value)?.count;
42
+ </script>
43
+
44
+ <template>
45
+ <UiTabs v-model="tab" :items="tabs" label="Issues" class="demo-wide">
46
+ <template #tab="{ item, selected }">
47
+ {{ item.label }}
48
+ <span class="tab-count" :data-selected="selected || undefined">{{
49
+ countOf(item.value)
50
+ }}</span>
51
+ </template>
52
+ <template #default="{ value }">
53
+ <p>{{ countOf(value) }} issues.</p>
54
+ </template>
55
+ </UiTabs>
56
+ </template>
57
+ ```
58
+
59
+ ## API
60
+
61
+ | Prop | Type | Default | Description |
62
+ | --- | --- | --- | --- |
63
+ | `items` | `SelectOption<T>[]` | `[]` | Tabs to render, in order. |
64
+ | `label` | `string` | — | Accessible name for the tablist. |
65
+ | `disabled` | `boolean` | `false` | Disables every tab. |
66
+ | `modelValue` | `T` | — | The selected tab's value. |
67
+
68
+ | Event | Payload | Description |
69
+ | --- | --- | --- |
70
+ | `update:modelValue` | `[value: T \| undefined]` | `v-model:modelValue` update. |
71
+
72
+ | Slot | Props | Description |
73
+ | --- | --- | --- |
74
+ | `default` | `{ value: T \| undefined; }` | Panel content for the selected tab. |
75
+ | `tab` | `{ item: SelectOption<T>; selected: boolean; }` | Tab content. |
76
+
77
+ Types:
78
+
79
+ ```ts
80
+ export interface SelectOption<T extends SelectValue = SelectValue> {
81
+ label: string;
82
+ value: T;
83
+ disabled?: boolean;
84
+ }
85
+
86
+ export type SelectValue = string | number;
87
+ ```
88
+
89
+ ## Styling
90
+
91
+ `--ui-indicator-x`, `--ui-indicator-width`, `--ui-indicator-top` and `--ui-indicator-height` place the indicator on the selected item.
92
+
93
+ - Parts (`[data-part="…"]`): `tabs`, `tablist`, `tab-indicator`, `tab`, `tabpanel`
94
+ - State attributes: `data-tabs-sliding`, `data-tabs-animate`, `data-tab-selected`
95
+
96
+ ## Keyboard
97
+
98
+ | Keys | Action |
99
+ | -------------- | -------------------------------------- |
100
+ | `Tab` | Focus the selected tab, then the panel |
101
+ | `←` / `→` | Select the previous / next tab |
102
+ | `Home` / `End` | Select the first / last tab |
103
+
104
+ ## Accessibility
105
+
106
+ - In right-to-left layouts, `←` / `→` follow the visual direction.
@@ -0,0 +1,88 @@
1
+ # Tag Input
2
+
3
+ > Free-form tags typed as chips.
4
+
5
+ ## Examples
6
+
7
+ ### Basic
8
+
9
+ Type a tag and press Enter or a comma; leaving the field adds it too.
10
+
11
+ ```vue
12
+ <script setup lang="ts">
13
+ const topics = ref(["vue"]);
14
+ </script>
15
+
16
+ <template>
17
+ <div class="demo-field">
18
+ <UiTagInput
19
+ v-model="topics"
20
+ label="Topics"
21
+ hint="Press Enter or type a comma to add a tag."
22
+ placeholder="Add a topic…"
23
+ />
24
+ <p class="demo-note">Tags: {{ topics.join(", ") || "none" }}</p>
25
+ </div>
26
+ </template>
27
+ ```
28
+
29
+ ### Max
30
+
31
+ `max` stops the list growing; the field stays usable so tags can still be removed.
32
+
33
+ ```vue
34
+ <script setup lang="ts">
35
+ const topics = ref(["vue", "css"]);
36
+ </script>
37
+
38
+ <template>
39
+ <div class="demo-field">
40
+ <UiTagInput
41
+ v-model="topics"
42
+ label="Topics"
43
+ hint="Up to three topics."
44
+ placeholder="Add a topic…"
45
+ :max="3"
46
+ />
47
+ </div>
48
+ </template>
49
+ ```
50
+
51
+ ## API
52
+
53
+ | Prop | Type | Default | Description |
54
+ | --- | --- | --- | --- |
55
+ | `label` | `string` | — | Visible label, linked to the control. |
56
+ | `hint` | `string` | — | Help text under the control, announced as its description. |
57
+ | `error` | `string \| boolean` | — | `true` marks the control invalid; a string also shows it as the message, replacing the hint. |
58
+ | `optional` | `boolean` | `false` | Appends the `optional` translation to the label. |
59
+ | `disabled` | `boolean` | `false` | Disables the control and its remove buttons. |
60
+ | `placeholder` | `string` | — | Placeholder for the text field. |
61
+ | `max` | `number` | — | Most tags allowed; unlimited when omitted. |
62
+ | `name` | `string` | — | Form field name: submits one hidden input per tag. |
63
+ | `id` | `string` | — | Id for the text field; generated with `useId()` when omitted. |
64
+ | `modelValue` | `string[]` | — | The tags. |
65
+
66
+ | Event | Payload | Description |
67
+ | --- | --- | --- |
68
+ | `update:modelValue` | `[value: string[] \| undefined]` | `v-model:modelValue` update. |
69
+
70
+ ## Styling
71
+
72
+ - Parts (`[data-part="…"]`): `field`, `field-label`, `field-optional`, `tag-input-control`, `tag-input-chip`, `tag-input-chip-label`, `tag-input-chip-remove`, `tag-input`, `field-message`
73
+ - State attributes: `data-field-error`, `data-field-name`, `data-tag-input-disabled`, `data-tag-input-full`, `data-field-tone`
74
+
75
+ ## Keyboard
76
+
77
+ | Keys | Action |
78
+ | ------------ | ------------------------------------------- |
79
+ | `Enter`, `,` | Add the typed tag |
80
+ | `Backspace` | Remove the last tag when the field is empty |
81
+ | `Tab` | Move to the next chip's remove button |
82
+
83
+ ## Accessibility
84
+
85
+ - Each chip's remove button is a real `<button>` named by the `removeItem` translation with the tag, so it's reachable and announced on its own.
86
+ - With `name`, one hidden input per tag submits the tags with a native form.
87
+ - The label is linked to the text field; hint and error are part of its description.
88
+ - Duplicate tags are kept: the value is exactly what the user entered.
@@ -0,0 +1,46 @@
1
+ # Textarea
2
+
3
+ > A multi-line input with an optional character limit.
4
+
5
+ ## Examples
6
+
7
+ ### With a limit
8
+
9
+ ```vue
10
+ <script setup lang="ts">
11
+ const bio = ref("Building the web for humans.");
12
+ </script>
13
+
14
+ <template>
15
+ <div class="demo-field">
16
+ <UiTextarea v-model="bio" label="Bio" :max-length="80" :rows="3" />
17
+ </div>
18
+ </template>
19
+ ```
20
+
21
+ ## API
22
+
23
+ | Prop | Type | Default | Description |
24
+ | --- | --- | --- | --- |
25
+ | `label` | `string` | — | Visible label, linked to the control. |
26
+ | `hint` | `string` | — | Help text under the control, announced as its description. |
27
+ | `error` | `string \| boolean` | — | `true` marks the control invalid; a string also shows it as the message, replacing the hint. |
28
+ | `maxLength` | `number` | — | Character limit. Shows a live counter and flags values already over it. |
29
+ | `optional` | `boolean` | `false` | Appends the `optional` translation to the label. |
30
+ | `disabled` | `boolean` | `false` | Disables the control. |
31
+ | `rows` | `number` | `4` | Visible text lines. |
32
+ | `id` | `string` | — | Id for the control; generated with `useId()` when omitted. |
33
+ | `modelValue` | `string` | — | The value. |
34
+
35
+ | Event | Payload | Description |
36
+ | --- | --- | --- |
37
+ | `update:modelValue` | `[value: string \| undefined]` | `v-model:modelValue` update. |
38
+
39
+ ## Styling
40
+
41
+ - Parts (`[data-part="…"]`): `field`, `field-label`, `field-optional`, `textarea`, `field-footer`, `field-count`, `field-message`
42
+ - State attributes: `data-field-error`, `data-field-count-exceeded`, `data-field-tone`
43
+
44
+ ## Accessibility
45
+
46
+ - Values over the limit are flagged, not truncated.