@humanonlyweb/ui 0.0.0-stage → 0.1.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 (144) 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/button/Button.js +95 -0
  12. package/dist/components/button/Button.vue.d.ts +74 -0
  13. package/dist/components/button/IconButton.js +47 -0
  14. package/dist/components/button/IconButton.vue.d.ts +115 -0
  15. package/dist/components/checkbox/Checkbox.js +93 -0
  16. package/dist/components/checkbox/Checkbox.vue.d.ts +43 -0
  17. package/dist/components/combobox/Combobox.js +294 -0
  18. package/dist/components/combobox/Combobox.vue.d.ts +80 -0
  19. package/dist/components/context-menu/ContextMenu.js +170 -0
  20. package/dist/components/context-menu/ContextMenu.vue.d.ts +38 -0
  21. package/dist/components/dialog/ConfirmDialog.js +103 -0
  22. package/dist/components/dialog/ConfirmDialog.vue.d.ts +46 -0
  23. package/dist/components/dialog/Dialog.js +160 -0
  24. package/dist/components/dialog/Dialog.vue.d.ts +54 -0
  25. package/dist/components/field/FieldMessage.js +31 -0
  26. package/dist/components/input/Input.js +111 -0
  27. package/dist/components/input/Input.vue.d.ts +50 -0
  28. package/dist/components/kbd/Kbd.js +48 -0
  29. package/dist/components/kbd/Kbd.vue.d.ts +24 -0
  30. package/dist/components/menu/Menu.js +124 -0
  31. package/dist/components/menu/Menu.vue.d.ts +41 -0
  32. package/dist/components/otp-input/OtpInput.js +179 -0
  33. package/dist/components/otp-input/OtpInput.vue.d.ts +48 -0
  34. package/dist/components/popover/Popover.js +83 -0
  35. package/dist/components/popover/Popover.vue.d.ts +37 -0
  36. package/dist/components/radio-group/RadioGroup.js +125 -0
  37. package/dist/components/radio-group/RadioGroup.vue.d.ts +45 -0
  38. package/dist/components/segmented/Segmented.js +110 -0
  39. package/dist/components/segmented/Segmented.vue.d.ts +41 -0
  40. package/dist/components/select/Select.js +231 -0
  41. package/dist/components/select/Select.vue.d.ts +59 -0
  42. package/dist/components/slider/Slider.js +196 -0
  43. package/dist/components/slider/Slider.vue.d.ts +49 -0
  44. package/dist/components/spin-button/SpinButton.js +231 -0
  45. package/dist/components/spin-button/SpinButton.vue.d.ts +48 -0
  46. package/dist/components/split-button/SplitButton.js +69 -0
  47. package/dist/components/split-button/SplitButton.vue.d.ts +38 -0
  48. package/dist/components/switch/Switch.js +95 -0
  49. package/dist/components/switch/Switch.vue.d.ts +42 -0
  50. package/dist/components/table/Table.js +173 -0
  51. package/dist/components/table/Table.vue.d.ts +45 -0
  52. package/dist/components/tabs/Tabs.js +99 -0
  53. package/dist/components/tabs/Tabs.vue.d.ts +39 -0
  54. package/dist/components/textarea/Textarea.js +118 -0
  55. package/dist/components/textarea/Textarea.vue.d.ts +34 -0
  56. package/dist/components/toast/ToastItem.js +91 -0
  57. package/dist/components/toast/ToastItem.vue.d.ts +29 -0
  58. package/dist/components/toast/ToastViewport.js +56 -0
  59. package/dist/components/toast/ToastViewport.vue.d.ts +25 -0
  60. package/dist/components/toolbar/Toolbar.js +91 -0
  61. package/dist/components/toolbar/Toolbar.vue.d.ts +21 -0
  62. package/dist/components/tooltip/Tooltip.js +85 -0
  63. package/dist/components/tooltip/Tooltip.vue.d.ts +25 -0
  64. package/dist/composables/internal/env.js +5 -0
  65. package/dist/composables/internal/is-equal.js +14 -0
  66. package/dist/composables/internal/on-click-outside.js +18 -0
  67. package/dist/composables/internal/standard-schema.d.ts +38 -0
  68. package/dist/composables/internal/use-document-visibility.js +16 -0
  69. package/dist/composables/internal/use-event-listener.js +24 -0
  70. package/dist/composables/internal/use-interval-fn.js +21 -0
  71. package/dist/composables/internal/use-resize-observer.js +21 -0
  72. package/dist/composables/internal/use-timeout-fn.js +25 -0
  73. package/dist/composables/use-accordion.d.ts +9 -0
  74. package/dist/composables/use-accordion.js +10 -0
  75. package/dist/composables/use-combobox.d.ts +44 -0
  76. package/dist/composables/use-combobox.js +185 -0
  77. package/dist/composables/use-field.d.ts +17 -0
  78. package/dist/composables/use-field.js +27 -0
  79. package/dist/composables/use-form.d.ts +44 -0
  80. package/dist/composables/use-form.js +146 -0
  81. package/dist/composables/use-menu.d.ts +26 -0
  82. package/dist/composables/use-menu.js +117 -0
  83. package/dist/composables/use-platform.d.ts +17 -0
  84. package/dist/composables/use-platform.js +126 -0
  85. package/dist/composables/use-popover.d.ts +35 -0
  86. package/dist/composables/use-popover.js +49 -0
  87. package/dist/composables/use-roving-selection.d.ts +22 -0
  88. package/dist/composables/use-roving-selection.js +65 -0
  89. package/dist/composables/use-select.d.ts +31 -0
  90. package/dist/composables/use-select.js +169 -0
  91. package/dist/composables/use-slide-indicator.d.ts +24 -0
  92. package/dist/composables/use-slide-indicator.js +52 -0
  93. package/dist/composables/use-toast.d.ts +23 -0
  94. package/dist/composables/use-toast.js +51 -0
  95. package/dist/config.d.ts +40 -0
  96. package/dist/config.js +35 -0
  97. package/dist/docs/README.md +44 -0
  98. package/dist/docs/changelog.md +14 -0
  99. package/dist/docs/components/accordion.md +100 -0
  100. package/dist/docs/components/avatar-group.md +58 -0
  101. package/dist/docs/components/avatar.md +40 -0
  102. package/dist/docs/components/button.md +109 -0
  103. package/dist/docs/components/checkbox.md +123 -0
  104. package/dist/docs/components/combobox.md +207 -0
  105. package/dist/docs/components/confirm-dialog.md +107 -0
  106. package/dist/docs/components/context-menu.md +98 -0
  107. package/dist/docs/components/dialog.md +127 -0
  108. package/dist/docs/components/icon-button.md +47 -0
  109. package/dist/docs/components/input.md +89 -0
  110. package/dist/docs/components/kbd.md +41 -0
  111. package/dist/docs/components/menu.md +112 -0
  112. package/dist/docs/components/otp-input.md +92 -0
  113. package/dist/docs/components/popover.md +72 -0
  114. package/dist/docs/components/radio-group.md +114 -0
  115. package/dist/docs/components/segmented.md +96 -0
  116. package/dist/docs/components/select.md +129 -0
  117. package/dist/docs/components/slider.md +105 -0
  118. package/dist/docs/components/spin-button.md +73 -0
  119. package/dist/docs/components/split-button.md +64 -0
  120. package/dist/docs/components/switch.md +71 -0
  121. package/dist/docs/components/table.md +241 -0
  122. package/dist/docs/components/tabs.md +106 -0
  123. package/dist/docs/components/textarea.md +46 -0
  124. package/dist/docs/components/toast.md +135 -0
  125. package/dist/docs/components/toolbar.md +71 -0
  126. package/dist/docs/components/tooltip.md +57 -0
  127. package/dist/docs/forms.md +182 -0
  128. package/dist/docs/index.md +11 -0
  129. package/dist/docs/installation.md +73 -0
  130. package/dist/docs/localisation.md +40 -0
  131. package/dist/docs/ssr.md +24 -0
  132. package/dist/docs/styling.md +66 -0
  133. package/dist/index.d.ts +46 -0
  134. package/dist/index.js +44 -0
  135. package/dist/nuxt/module.d.ts +15 -0
  136. package/dist/nuxt/module.js +72 -0
  137. package/dist/nuxt/runtime/plugin.d.ts +4 -0
  138. package/dist/nuxt/runtime/plugin.js +24 -0
  139. package/dist/package.js +4 -0
  140. package/dist/styles/core.css +284 -0
  141. package/dist/translations.d.ts +71 -0
  142. package/dist/translations.js +55 -0
  143. package/dist/types.d.ts +61 -0
  144. package/package.json +93 -4
@@ -0,0 +1,40 @@
1
+ import { Platform } from "./types.js";
2
+ import { UiTranslations, UiTranslationsInput } from "./translations.js";
3
+ import { App, Component, ComputedRef, InjectionKey, Ref } from "vue";
4
+ //#region src/config.d.ts
5
+ export interface UiOptions {
6
+ /**
7
+ * Rendered for `<Button to="…">`. Pass `RouterLink` (vue-router) or `NuxtLink`.
8
+ * Without one, a string `to` falls back to a plain `<a href>`.
9
+ */
10
+ link?: Component;
11
+ /**
12
+ * Which key caps `<Kbd>` renders. Pass it during SSR (e.g. from the request's
13
+ * user agent) so server and client agree; the Nuxt module does this for you.
14
+ * Left out, it's detected in the browser after mount.
15
+ */
16
+ platform?: Platform | Ref<Platform | undefined>;
17
+ /**
18
+ * The components' built-in text, in your language. Pass only what you change; the
19
+ * rest stays English. A ref (e.g. a computed from your i18n locale) keeps it live.
20
+ */
21
+ translations?: UiTranslationsInput | Ref<UiTranslationsInput>;
22
+ }
23
+ export interface UiConfig {
24
+ link: Component | null;
25
+ platform: Readonly<Ref<Platform | undefined>>;
26
+ /** Your overrides of the built-in text. Assign to it to change them later. */
27
+ translations: Ref<UiTranslationsInput>;
28
+ }
29
+ export declare const UI_CONFIG_KEY: InjectionKey<UiConfig>;
30
+ /**
31
+ * `app.use(createUi({ link: RouterLink }))`. Everything it provides is scoped to the
32
+ * app instance, so state never leaks between SSR requests.
33
+ */
34
+ export declare function createUi(options?: UiOptions): {
35
+ install(app: App): void;
36
+ };
37
+ export declare function useUiConfig(): UiConfig;
38
+ /** The built-in text: English, with the app's `translations` on top. */
39
+ export declare function useTranslations(): ComputedRef<UiTranslations>;
40
+ //#endregion
package/dist/config.js ADDED
@@ -0,0 +1,35 @@
1
+ import { TOASTER_KEY, createToaster } from "./composables/use-toast.js";
2
+ import { resolveTranslations } from "./translations.js";
3
+ import { computed, inject, isRef, shallowRef } from "vue";
4
+ //#region src/config.ts
5
+ const UI_CONFIG_KEY = Symbol("humanonlyweb-ui");
6
+ const DEFAULT_CONFIG = {
7
+ link: null,
8
+ platform: shallowRef(void 0),
9
+ translations: shallowRef({})
10
+ };
11
+ /**
12
+ * `app.use(createUi({ link: RouterLink }))`. Everything it provides is scoped to the
13
+ * app instance, so state never leaks between SSR requests.
14
+ */
15
+ function createUi(options = {}) {
16
+ return { install(app) {
17
+ const { platform, translations = {} } = options;
18
+ app.provide(UI_CONFIG_KEY, {
19
+ link: options.link ?? null,
20
+ platform: isRef(platform) ? platform : shallowRef(platform),
21
+ translations: isRef(translations) ? translations : shallowRef(translations)
22
+ });
23
+ app.provide(TOASTER_KEY, createToaster());
24
+ } };
25
+ }
26
+ function useUiConfig() {
27
+ return inject(UI_CONFIG_KEY, DEFAULT_CONFIG);
28
+ }
29
+ /** The built-in text: English, with the app's `translations` on top. */
30
+ function useTranslations() {
31
+ const { translations } = useUiConfig();
32
+ return computed(() => resolveTranslations(translations.value));
33
+ }
34
+ //#endregion
35
+ export { UI_CONFIG_KEY, createUi, useTranslations, useUiConfig };
@@ -0,0 +1,44 @@
1
+ # @humanonlyweb/ui
2
+
3
+ > Headless, accessible, SSR-safe Vue 3 components. Unstyled: style the `data-part` hooks with your own CSS. Nuxt names are `Ui`-prefixed (`<UiSelect>`); in plain Vue, import `Select` from `@humanonlyweb/ui`.
4
+
5
+ ## Guides
6
+
7
+ - [Introduction](./index.md): Headless, accessible Vue 3 components.
8
+ - [Installation](./installation.md): Nuxt module or Vue plugin.
9
+ - [Styling](./styling.md): Style the data-part hooks with your own CSS.
10
+ - [SSR](./ssr.md): Setup needed for server rendering.
11
+ - [Forms](./forms.md): Form state and validation with zod, valibot or any Standard Schema library.
12
+ - [Localisation](./localisation.md): The components' built-in text, in your language.
13
+ - [Changelog](./changelog.md): What changed in each release.
14
+
15
+ ## Components
16
+
17
+ - [Accordion](./components/accordion.md): Expandable sections.
18
+ - [Avatar](./components/avatar.md): A user image with an initials fallback.
19
+ - [Avatar Group](./components/avatar-group.md): Stacked avatars with an overflow count.
20
+ - [Button](./components/button.md): A button, or a link styled as one.
21
+ - [Checkbox](./components/checkbox.md): A checkbox, alone or in a group.
22
+ - [Combobox](./components/combobox.md): A text input that filters a list of options as you type.
23
+ - [Confirm Dialog](./components/confirm-dialog.md): Asks to confirm or cancel an action.
24
+ - [Context Menu](./components/context-menu.md): A menu opened at the pointer by right-click or long-press.
25
+ - [Dialog](./components/dialog.md): A modal dialog.
26
+ - [Icon Button](./components/icon-button.md): A button with only an icon.
27
+ - [Input](./components/input.md): A text input with label, hint and error.
28
+ - [Kbd](./components/kbd.md): A keyboard shortcut, shown with the user's platform keys.
29
+ - [Menu](./components/menu.md): A list of actions opened from a button.
30
+ - [OTP Input](./components/otp-input.md): A one-time code input, with a slot per character.
31
+ - [Popover](./components/popover.md): A non-modal panel anchored to a trigger.
32
+ - [Radio Group](./components/radio-group.md): A single choice from a list.
33
+ - [Segmented](./components/segmented.md): A single choice shown as a row of buttons.
34
+ - [Select](./components/select.md): A single or multiple choice from a dropdown.
35
+ - [Slider](./components/slider.md): Pick a number, or a range, by dragging or with the keyboard.
36
+ - [Spin Button](./components/spin-button.md): A number input with step buttons.
37
+ - [Split Button](./components/split-button.md): A main action with a menu of alternatives.
38
+ - [Switch](./components/switch.md): An on/off toggle.
39
+ - [Table](./components/table.md): A data table with custom cells.
40
+ - [Tabs](./components/tabs.md): Panels switched by tabs.
41
+ - [Textarea](./components/textarea.md): A multi-line input with an optional character limit.
42
+ - [Toast](./components/toast.md): Temporary notifications.
43
+ - [Toolbar](./components/toolbar.md): A row of controls with a single tab stop.
44
+ - [Tooltip](./components/tooltip.md): A short label shown on hover and focus.
@@ -0,0 +1,14 @@
1
+ # Changelog
2
+
3
+ > What changed in each release.
4
+
5
+ ## Unreleased
6
+
7
+ - ci: update branch name formatting and paths-filter version deps: bump bun package manager to version 1.4.4
8
+ - Style: update checkbox and radio control background and border variables
9
+ - README: say modern browsers, drop the releasing section; add the docs preview launch config
10
+ - Ship the docs as Markdown in the package, for coding agents
11
+
12
+ ## 0.1.0 (2026-10-19)
13
+
14
+ First release.
@@ -0,0 +1,100 @@
1
+ # Accordion
2
+
3
+ > Expandable sections.
4
+
5
+ ## Examples
6
+
7
+ ### Single
8
+
9
+ ```vue
10
+ <script setup lang="ts">
11
+ const open = ref("shipping");
12
+ </script>
13
+
14
+ <template>
15
+ <UiAccordion v-model="open" class="demo-stack">
16
+ <UiAccordionItem value="shipping" title="How long does shipping take?">
17
+ Orders ship within two business days and arrive in three to five.
18
+ </UiAccordionItem>
19
+ <UiAccordionItem value="returns" title="Can I return an item?">
20
+ Yes — within 30 days, in its original packaging.
21
+ </UiAccordionItem>
22
+ <UiAccordionItem value="warranty" title="Is there a warranty?" disabled>
23
+ Not for this product.
24
+ </UiAccordionItem>
25
+ </UiAccordion>
26
+ </template>
27
+ ```
28
+
29
+ ### Multiple
30
+
31
+ With `multiple`, several items can be open at once.
32
+
33
+ ```vue
34
+ <script setup lang="ts">
35
+ const open = ref(["notifications"]);
36
+ </script>
37
+
38
+ <template>
39
+ <UiAccordion v-model="open" multiple class="demo-stack">
40
+ <UiAccordionItem value="notifications" title="Notifications">
41
+ Choose which updates reach your inbox.
42
+ </UiAccordionItem>
43
+ <UiAccordionItem value="privacy" title="Privacy">
44
+ Control who can see your profile.
45
+ </UiAccordionItem>
46
+ </UiAccordion>
47
+ </template>
48
+ ```
49
+
50
+ ## API
51
+
52
+ ### Accordion
53
+
54
+ | Prop | Type | Default | Description |
55
+ | --- | --- | --- | --- |
56
+ | `multiple` | `boolean` | `false` | Allow several items open at once; `v-model` is then a `string[]`. |
57
+ | `modelValue` | `string \| string[]` | — | Open item value, or values with `multiple`. |
58
+
59
+ | Event | Payload | Description |
60
+ | --- | --- | --- |
61
+ | `update:modelValue` | `[value: string \| string[] \| undefined]` | `v-model:modelValue` update. |
62
+
63
+ | Slot | Props | Description |
64
+ | --- | --- | --- |
65
+ | `default` | — | `<AccordionItem>`s. |
66
+
67
+ ### AccordionItem
68
+
69
+ | Prop | Type | Default | Description |
70
+ | --- | --- | --- | --- |
71
+ | `value` (required) | `string` | — | Identifies the item in the accordion's `v-model`. |
72
+ | `title` (required) | `string` | — | Header text. The `title` slot overrides it. |
73
+ | `disabled` | `boolean` | `false` | Prevents toggling. |
74
+ | `level` | `2 \| 3 \| 4 \| 5 \| 6` | `3` | Heading level wrapping the trigger, to fit the page's outline. |
75
+
76
+ | Slot | Props | Description |
77
+ | --- | --- | --- |
78
+ | `default` | — | Panel content. |
79
+ | `title` | `{ open: boolean; }` | Replaces the `title` text. |
80
+ | `indicator` | `{ open: boolean; }` | Replaces the chevron. |
81
+
82
+ ## Styling
83
+
84
+ - Parts (`[data-part="…"]`): `accordion`
85
+
86
+ - Parts (`[data-part="…"]`): `accordion-item`, `accordion-heading`, `accordion-trigger`, `accordion-title`, `accordion-indicator`, `accordion-panel`, `accordion-clip`, `accordion-content`
87
+ - State attributes: `data-accordion-open`
88
+
89
+ ## Keyboard
90
+
91
+ | Keys | Action |
92
+ | ----------------- | ---------------------------------- |
93
+ | `Enter` / `Space` | Toggle the focused item |
94
+ | `↓` / `↑` | Move to the next / previous header |
95
+ | `Home` / `End` | Move to the first / last header |
96
+
97
+ ## Accessibility
98
+
99
+ - Set `level` so the headers fit your page's heading order.
100
+ - Closed panels are skipped by Tab, but the browser's find-in-page still searches them and opens the one it matches.
@@ -0,0 +1,58 @@
1
+ # Avatar Group
2
+
3
+ > Stacked avatars with an overflow count.
4
+
5
+ ## Examples
6
+
7
+ ### Capped
8
+
9
+ `max` includes the “+N” chip: with `max` 4, you get three avatars and “+3”.
10
+
11
+ ```vue
12
+ <script setup lang="ts">
13
+ const people = [
14
+ { id: 1, name: "Ada Lovelace", src: "/avatars/ada.svg" },
15
+ { id: 2, name: "Grace Hopper", src: "/avatars/grace.svg" },
16
+ { id: 3, name: "Alan Turing" },
17
+ { id: 4, name: "Katherine Johnson", src: "/avatars/katherine.svg" },
18
+ { id: 5, name: "Margaret Hamilton" },
19
+ { id: 6, name: "Linus Torvalds" },
20
+ ];
21
+ </script>
22
+
23
+ <template>
24
+ <UiAvatarGroup
25
+ :items="people"
26
+ :max="4"
27
+ :overflow-label="(count) => `${count} more collaborators`"
28
+ />
29
+ </template>
30
+ ```
31
+
32
+ ## API
33
+
34
+ | Prop | Type | Default | Description |
35
+ | --- | --- | --- | --- |
36
+ | `items` | `AvatarItem[]` | `[]` | People to show, in order. |
37
+ | `max` | `number` | — | Most circles to show, counting the "+N" chip: `max` 4 shows 3 avatars and "+N". |
38
+ | `size` | `"small" \| "medium" \| "large"` | `"medium"` | Size passed to every avatar. |
39
+ | `overflowLabel` | `((count: number) => string)` | — | Spoken name of the "+N" chip, e.g. `(n) => \`${n} more recipients\``. Defaults to the `moreAvatars` translation. |
40
+
41
+ Types:
42
+
43
+ ```ts
44
+ export interface AvatarItem {
45
+ name: string;
46
+ src?: string;
47
+ id?: string | number;
48
+ }
49
+ ```
50
+
51
+ ## Styling
52
+
53
+ - Parts (`[data-part="…"]`): `avatar-group`, `avatar`, `avatar-image`
54
+ - State attributes: `data-avatar-size`, `data-avatar-overflow`
55
+
56
+ ## Accessibility
57
+
58
+ - Screen readers hear the “+N” chip as “3 more”. Use `overflow-label` to say more, e.g. “3 more people”.
@@ -0,0 +1,40 @@
1
+ # Avatar
2
+
3
+ > A user image with an initials fallback.
4
+
5
+ ## Examples
6
+
7
+ ### Image and fallback
8
+
9
+ ```vue
10
+ <template>
11
+ <div class="demo-row">
12
+ <UiAvatar name="Ada Lovelace" src="/avatars/ada.svg" size="large" />
13
+ <UiAvatar name="Grace Hopper" src="/avatars/grace.svg" />
14
+ <UiAvatar name="Alan Turing" src="/missing.png" />
15
+ <UiAvatar name="Linus" size="small" />
16
+ </div>
17
+ </template>
18
+ ```
19
+
20
+ ## API
21
+
22
+ | Prop | Type | Default | Description |
23
+ | --- | --- | --- | --- |
24
+ | `name` (required) | `string` | — | Accessible name, and the source of the initials fallback. |
25
+ | `src` | `string` | — | Image URL. Falls back to initials if it's missing or fails to load. |
26
+ | `size` | `"small" \| "medium" \| "large"` | `"medium"` | Size hook, exposed as `data-avatar-size`. |
27
+
28
+ | Slot | Props | Description |
29
+ | --- | --- | --- |
30
+ | `fallback` | `{ initials: string; }` | Shown without an image. Defaults to the initials. |
31
+
32
+ ## Styling
33
+
34
+ - Parts (`[data-part="…"]`): `avatar`, `avatar-image`
35
+ - State attributes: `data-avatar-size`
36
+
37
+ ## Accessibility
38
+
39
+ - Screen readers hear `name`.
40
+ - The initials show until the image loads, and stay if it fails.
@@ -0,0 +1,109 @@
1
+ # Button
2
+
3
+ > A button, or a link styled as one.
4
+
5
+ ## Examples
6
+
7
+ ### Variants
8
+
9
+ ```vue
10
+ <template>
11
+ <div class="demo-row">
12
+ <UiButton>Primary</UiButton>
13
+ <UiButton variant="secondary">Secondary</UiButton>
14
+ <UiButton variant="solid">Solid</UiButton>
15
+ <UiButton variant="ghost">Ghost</UiButton>
16
+ <UiButton variant="danger">Danger</UiButton>
17
+ <UiButton variant="link">Link</UiButton>
18
+ </div>
19
+ </template>
20
+ ```
21
+
22
+ ### Sizes
23
+
24
+ ```vue
25
+ <template>
26
+ <div class="demo-row">
27
+ <UiButton size="small" variant="secondary">Small</UiButton>
28
+ <UiButton variant="secondary">Medium</UiButton>
29
+ <UiButton size="large" variant="secondary">
30
+ Large
31
+ <template #trailing><Icon name="arrow-right" :size="14" /></template>
32
+ </UiButton>
33
+ </div>
34
+ </template>
35
+ ```
36
+
37
+ ### Loading
38
+
39
+ ```vue
40
+ <script setup lang="ts">
41
+ const saving = ref(false);
42
+
43
+ async function save() {
44
+ saving.value = true;
45
+ await new Promise((resolve) => setTimeout(resolve, 1500));
46
+ saving.value = false;
47
+ }
48
+ </script>
49
+
50
+ <template>
51
+ <UiButton :loading="saving" @click="save">
52
+ <template #spinner><span class="spinner" /></template>
53
+ {{ saving ? "Saving…" : "Save changes" }}
54
+ </UiButton>
55
+ </template>
56
+ ```
57
+
58
+ ### Links
59
+
60
+ `href` renders an `<a>`; `to` renders your router's link.
61
+
62
+ ```vue
63
+ <template>
64
+ <div class="demo-row">
65
+ <UiButton to="/installation" variant="secondary">Router link</UiButton>
66
+ <UiButton href="https://github.com/humanonlyweb/ui" target="_blank" variant="ghost">
67
+ External link
68
+ </UiButton>
69
+ <UiButton href="/" variant="ghost" disabled>Disabled link</UiButton>
70
+ </div>
71
+ </template>
72
+ ```
73
+
74
+ ## API
75
+
76
+ | Prop | Type | Default | Description |
77
+ | --- | --- | --- | --- |
78
+ | `variant` | `"primary" \| "secondary" \| "solid" \| "ghost" \| "danger" \| "link"` | — | Style hook, exposed as `data-button-variant`. |
79
+ | `size` | `"small" \| "medium" \| "large"` | — | Size hook, exposed as `data-button-size`. |
80
+ | `fullWidth` | `boolean` | — | Layout hook, exposed as `data-button-full-width`. |
81
+ | `loading` | `boolean` | — | Busy state: blocks clicks and sets `aria-busy`, but stays focusable. |
82
+ | `disabled` | `boolean` | — | Disables the button. A disabled link loses its `href` and leaves the tab order. |
83
+ | `type` | `"button" \| "submit" \| "reset"` | — | Native button type. |
84
+ | `href` | `string` | — | Renders an `<a>` to this URL instead of a `<button>`. |
85
+ | `to` | `string \| Record<string, unknown>` | — | Route for the router link given to `createUi({ link })`, rendering it instead of a `<button>`. |
86
+ | `target` | `"_blank" \| "_self" \| "_parent" \| "_top"` | — | Link target. |
87
+
88
+ | Slot | Props | Description |
89
+ | --- | --- | --- |
90
+ | `default` | — | Label. |
91
+ | `leading` | — | Before the label, e.g. an icon. |
92
+ | `trailing` | — | After the label, e.g. an icon. |
93
+ | `spinner` | — | Shown while `loading`. |
94
+
95
+ ## Styling
96
+
97
+ - Parts (`[data-part="…"]`): `button`, `button-spinner`, `button-label`
98
+ - State attributes: `data-button-variant`, `data-button-size`, `data-button-full-width`, `data-button-disabled`, `data-button-loading`
99
+
100
+ ## Keyboard
101
+
102
+ | Keys | Action |
103
+ | ----------------- | -------- |
104
+ | `Enter` / `Space` | Activate |
105
+
106
+ ## Accessibility
107
+
108
+ - While `loading`, clicks are ignored but the button keeps focus.
109
+ - Disabled links lose their `href` and leave the tab order.
@@ -0,0 +1,123 @@
1
+ # Checkbox
2
+
3
+ > A checkbox, alone or in a group.
4
+
5
+ ## Examples
6
+
7
+ ### Basic
8
+
9
+ ```vue
10
+ <script setup lang="ts">
11
+ const accepted = ref(false);
12
+ </script>
13
+
14
+ <template>
15
+ <div class="demo-stack">
16
+ <UiCheckbox v-model="accepted" label="Accept the terms" />
17
+ <UiCheckbox :model-value="true" label="Disabled" disabled />
18
+ </div>
19
+ </template>
20
+ ```
21
+
22
+ ### Group
23
+
24
+ Bind several checkboxes to one array: each adds its `value` when checked.
25
+
26
+ ```vue
27
+ <script setup lang="ts">
28
+ const toppings = ref(["cheese"]);
29
+ </script>
30
+
31
+ <template>
32
+ <div class="demo-stack demo-field">
33
+ <UiCheckbox v-model="toppings" value="cheese" label="Cheese" />
34
+ <UiCheckbox v-model="toppings" value="olives" label="Olives" />
35
+ <UiCheckbox v-model="toppings" value="basil" label="Basil" />
36
+ <p class="demo-note">Selected: {{ toppings.join(", ") || "none" }}</p>
37
+ </div>
38
+ </template>
39
+ ```
40
+
41
+ ### Indeterminate
42
+
43
+ ```vue
44
+ <script setup lang="ts">
45
+ const files = ref(["a.txt"]);
46
+ const all = ["a.txt", "b.txt", "c.txt"];
47
+
48
+ const allSelected = computed({
49
+ get: () => files.value.length === all.length,
50
+ set: (checked) => (files.value = checked ? [...all] : []),
51
+ });
52
+ const someSelected = computed(() => files.value.length > 0 && !allSelected.value);
53
+ </script>
54
+
55
+ <template>
56
+ <div class="demo-stack">
57
+ <UiCheckbox v-model="allSelected" :indeterminate="someSelected" label="Select all" />
58
+ <div class="demo-stack demo-indent">
59
+ <UiCheckbox v-for="file in all" :key="file" v-model="files" :value="file" :label="file" />
60
+ </div>
61
+ </div>
62
+ </template>
63
+ ```
64
+
65
+ ### Hint and error
66
+
67
+ Shown under the label and read as its description.
68
+
69
+ ```vue
70
+ <script setup lang="ts">
71
+ const accepted = ref(false);
72
+ const tried = ref(false);
73
+ </script>
74
+
75
+ <template>
76
+ <div class="demo-stack">
77
+ <UiCheckbox
78
+ v-model="accepted"
79
+ label="Accept the terms"
80
+ hint="Required to create an account."
81
+ :error="tried && !accepted ? 'Accept the terms to continue' : undefined"
82
+ />
83
+ <UiButton size="small" @click="tried = true">Create account</UiButton>
84
+ </div>
85
+ </template>
86
+ ```
87
+
88
+ ## API
89
+
90
+ | Prop | Type | Default | Description |
91
+ | --- | --- | --- | --- |
92
+ | `label` | `string` | — | Text next to the box. The default slot overrides it. |
93
+ | `disabled` | `boolean` | `false` | Disables the checkbox. |
94
+ | `indeterminate` | `boolean` | `false` | Shows the mixed state, e.g. for a "select all" with some rows picked. |
95
+ | `value` | `string \| number` | — | With an array `v-model`, this value is added/removed when toggled. |
96
+ | `hint` | `string` | — | Help text under the checkbox, announced as its description. |
97
+ | `error` | `string \| boolean` | — | `true` marks it invalid; a string also shows it as the message, replacing the hint. |
98
+ | `id` | `string` | — | Id for the input; generated with `useId()` when omitted. |
99
+ | `modelValue` | `boolean \| (string \| number)[]` | — | Checked state, or with an array, the checked `value`s. |
100
+
101
+ | Event | Payload | Description |
102
+ | --- | --- | --- |
103
+ | `update:modelValue` | `[value: boolean \| (string \| number)[] \| undefined]` | `v-model:modelValue` update. |
104
+
105
+ | Slot | Props | Description |
106
+ | --- | --- | --- |
107
+ | `default` | — | Label content, replacing `label`. |
108
+ | `indicator` | — | Inside `checkbox-control`, e.g. a check icon. |
109
+
110
+ ## Styling
111
+
112
+ - Parts (`[data-part="…"]`): `checkbox`, `checkbox-input`, `checkbox-control`, `checkbox-label`, `field-message`
113
+ - State attributes: `data-checkbox-disabled`, `data-checkbox-error`, `data-field-tone`
114
+
115
+ ## Keyboard
116
+
117
+ | Keys | Action |
118
+ | ------- | ------ |
119
+ | `Space` | Toggle |
120
+
121
+ ## Accessibility
122
+
123
+ - It's a native `<input type="checkbox">`, so it submits with forms and works with any label.