@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,52 @@
1
+ import { useResizeObserver } from "./internal/use-resize-observer.js";
2
+ import { computed, onMounted, ref, watch } from "vue";
3
+ //#region src/composables/use-slide-indicator.ts
4
+ /**
5
+ * Measures the active item so an indicator can slide between items. The result is
6
+ * exposed as CSS custom properties, not positioning, so stylesheets decide how
7
+ * (and whether) to use each one: `--ui-indicator-x`, `-width`, `-top`, `-height`.
8
+ */
9
+ function useSlideIndicator({ container, items, activeIndex }) {
10
+ const rect = ref({
11
+ x: 0,
12
+ width: 0,
13
+ top: 0,
14
+ height: 0
15
+ });
16
+ const isMeasured = ref(false);
17
+ const canAnimate = ref(false);
18
+ function measure() {
19
+ const el = items()?.[activeIndex()];
20
+ if (!el) {
21
+ isMeasured.value = false;
22
+ return;
23
+ }
24
+ rect.value = {
25
+ x: el.offsetLeft,
26
+ width: el.offsetWidth,
27
+ top: el.offsetTop,
28
+ height: el.offsetHeight
29
+ };
30
+ isMeasured.value = true;
31
+ }
32
+ watch([activeIndex, () => items()?.length], measure, { flush: "post" });
33
+ useResizeObserver(container, measure);
34
+ onMounted(() => {
35
+ measure();
36
+ requestAnimationFrame(() => {
37
+ canAnimate.value = true;
38
+ });
39
+ });
40
+ return {
41
+ style: computed(() => ({
42
+ "--ui-indicator-x": `${rect.value.x}px`,
43
+ "--ui-indicator-width": `${rect.value.width}px`,
44
+ "--ui-indicator-top": `${rect.value.top}px`,
45
+ "--ui-indicator-height": `${rect.value.height}px`
46
+ })),
47
+ isMeasured,
48
+ canAnimate
49
+ };
50
+ }
51
+ //#endregion
52
+ export { useSlideIndicator };
@@ -0,0 +1,23 @@
1
+ import { Toast, ToastAction, ToastTone } from "../types.js";
2
+ import { InjectionKey, Ref } from "vue";
3
+ //#region src/composables/use-toast.d.ts
4
+ export interface ToastOptions {
5
+ tone?: ToastTone;
6
+ duration?: number;
7
+ /** A button in the toast, e.g. `{ label: "Undo", onClick: restore }`. */
8
+ action?: ToastAction;
9
+ }
10
+ export interface Toaster {
11
+ items: Readonly<Ref<readonly Toast[]>>;
12
+ push: (message: string, options?: ToastOptions) => number;
13
+ dismiss: (id: number) => void;
14
+ clear: () => void;
15
+ success: (message: string, options?: Omit<ToastOptions, "tone">) => number;
16
+ error: (message: string, options?: Omit<ToastOptions, "tone">) => number;
17
+ info: (message: string, options?: Omit<ToastOptions, "tone">) => number;
18
+ }
19
+ export declare const TOASTER_KEY: InjectionKey<Toaster>;
20
+ /** One queue per app instance — never module-level, or SSR requests would share it. */
21
+ export declare function createToaster(): Toaster;
22
+ export declare function useToast(): Toaster;
23
+ //#endregion
@@ -0,0 +1,51 @@
1
+ import { isClient } from "./internal/env.js";
2
+ import { inject, readonly, shallowRef } from "vue";
3
+ //#region src/composables/use-toast.ts
4
+ const DEFAULT_DURATION = 4500;
5
+ const TOASTER_KEY = Symbol("humanonlyweb-ui-toaster");
6
+ /** One queue per app instance — never module-level, or SSR requests would share it. */
7
+ function createToaster() {
8
+ const items = shallowRef([]);
9
+ let nextId = 0;
10
+ function push(message, { tone = "info", duration = DEFAULT_DURATION, action } = {}) {
11
+ if (!isClient()) return -1;
12
+ const id = ++nextId;
13
+ items.value = [...items.value, {
14
+ id,
15
+ message,
16
+ tone,
17
+ duration,
18
+ action
19
+ }].slice(-5);
20
+ return id;
21
+ }
22
+ return {
23
+ items: readonly(items),
24
+ push,
25
+ dismiss: (id) => {
26
+ items.value = items.value.filter((toast) => toast.id !== id);
27
+ },
28
+ clear: () => {
29
+ items.value = [];
30
+ },
31
+ success: (message, options) => push(message, {
32
+ ...options,
33
+ tone: "success"
34
+ }),
35
+ error: (message, options) => push(message, {
36
+ ...options,
37
+ tone: "danger"
38
+ }),
39
+ info: (message, options) => push(message, {
40
+ ...options,
41
+ tone: "info"
42
+ })
43
+ };
44
+ }
45
+ function useToast() {
46
+ const toaster = inject(TOASTER_KEY, null);
47
+ if (!toaster) throw new Error("[@humanonlyweb/ui] useToast() needs app.use(createUi()) or the Nuxt module.");
48
+ return toaster;
49
+ }
50
+ //#endregion
51
+ export { TOASTER_KEY, createToaster, useToast };
@@ -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,52 @@
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
+ - [Breadcrumbs](./components/breadcrumbs.md): Where the current page sits in the hierarchy.
21
+ - [Button](./components/button.md): A button, or a link styled as one.
22
+ - [Checkbox](./components/checkbox.md): A checkbox, alone or in a group.
23
+ - [Checkbox Group](./components/checkbox-group.md): Several checkboxes bound to one array.
24
+ - [Combobox](./components/combobox.md): A text input that filters a list of options as you type.
25
+ - [Confirm Dialog](./components/confirm-dialog.md): Asks to confirm or cancel an action.
26
+ - [Context Menu](./components/context-menu.md): A menu opened at the pointer by right-click or long-press.
27
+ - [Dialog](./components/dialog.md): A modal dialog.
28
+ - [Fieldset](./components/fieldset.md): Groups related controls under one legend.
29
+ - [Icon Button](./components/icon-button.md): A button with only an icon.
30
+ - [Input](./components/input.md): A text input with label, hint and error.
31
+ - [Kbd](./components/kbd.md): A keyboard shortcut, shown with the user's platform keys.
32
+ - [Menu](./components/menu.md): A list of actions opened from a button.
33
+ - [OTP Input](./components/otp-input.md): A one-time code input, with a slot per character.
34
+ - [Pagination](./components/pagination.md): Move between pages of results.
35
+ - [Password Input](./components/password-input.md): A password field with a show/hide toggle.
36
+ - [Popover](./components/popover.md): A non-modal panel anchored to a trigger.
37
+ - [Progress](./components/progress.md): A bar showing how far a task has got.
38
+ - [Radio Group](./components/radio-group.md): A single choice from a list.
39
+ - [Segmented](./components/segmented.md): A single choice shown as a row of buttons.
40
+ - [Select](./components/select.md): A single or multiple choice from a dropdown.
41
+ - [Slider](./components/slider.md): Pick a number, or a range, by dragging or with the keyboard.
42
+ - [Spin Button](./components/spin-button.md): A number input with step buttons.
43
+ - [Split Button](./components/split-button.md): A main action with a menu of alternatives.
44
+ - [Switch](./components/switch.md): An on/off toggle.
45
+ - [Table](./components/table.md): A data table with custom cells.
46
+ - [Tabs](./components/tabs.md): Panels switched by tabs.
47
+ - [Tag Input](./components/tag-input.md): Free-form tags typed as chips.
48
+ - [Textarea](./components/textarea.md): A multi-line input with an optional character limit.
49
+ - [Toast](./components/toast.md): Temporary notifications.
50
+ - [Toolbar](./components/toolbar.md): A row of controls with a single tab stop.
51
+ - [Tooltip](./components/tooltip.md): A short label shown on hover and focus.
52
+ - [Visually Hidden](./components/visually-hidden.md): Text for assistive technology only.
@@ -0,0 +1,21 @@
1
+ # Changelog
2
+
3
+ > What changed in each release.
4
+
5
+ ## 0.2.0 (2026-11-01)
6
+
7
+ - Bump version to 0.2.0 in package.json
8
+
9
+ ## 0.1.1 (2026-11-01)
10
+
11
+ - Add tests for new components and enhance existing ones (#1)
12
+ - Bump version to 0.1.1 in package.json
13
+ - Enhance SSR support for Segmented and Tabs components; add hydration tests
14
+ - ci: update branch name formatting and paths-filter version deps: bump bun package manager to version 1.4.4
15
+ - Style: update checkbox and radio control background and border variables
16
+ - README: say modern browsers, drop the releasing section; add the docs preview launch config
17
+ - Ship the docs as Markdown in the package, for coding agents
18
+
19
+ ## 0.1.0 (2026-10-19)
20
+
21
+ 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,81 @@
1
+ # Breadcrumbs
2
+
3
+ > Where the current page sits in the hierarchy.
4
+
5
+ ## Examples
6
+
7
+ ### Basic
8
+
9
+ Each crumb is a `to` router link, an `href`, or plain text for the current page. In Nuxt, the `to` crumbs render through `NuxtLink` (the module installs it as the configured link component); in a plain Vue app, pass `RouterLink` to `createUi({ link })`. Use `href` for plain or external URLs.
10
+
11
+ ```vue
12
+ <script setup lang="ts">
13
+ const items = [
14
+ { label: "Docs", to: "/" },
15
+ { label: "Components", to: "/components/button" },
16
+ { label: "Breadcrumbs" },
17
+ ];
18
+ </script>
19
+
20
+ <template>
21
+ <div class="demo-stack">
22
+ <UiBreadcrumbs :items="items" />
23
+ </div>
24
+ </template>
25
+ ```
26
+
27
+ ### Separator
28
+
29
+ `separator` is the text between crumbs, hidden from assistive technology. Leave it empty to draw a separator in CSS instead.
30
+
31
+ ```vue
32
+ <script setup lang="ts">
33
+ const items = [
34
+ { label: "Docs", to: "/" },
35
+ { label: "Components", to: "/components/button" },
36
+ { label: "Breadcrumbs" },
37
+ ];
38
+ </script>
39
+
40
+ <template>
41
+ <div class="demo-stack">
42
+ <UiBreadcrumbs :items="items" separator="›" />
43
+ </div>
44
+ </template>
45
+ ```
46
+
47
+ ## API
48
+
49
+ | Prop | Type | Default | Description |
50
+ | --- | --- | --- | --- |
51
+ | `items` | `BreadcrumbItem[]` | `[]` | Crumbs, in order. The last one is the current page. |
52
+ | `label` | `string` | — | Accessible name for the navigation landmark, when the `breadcrumbs` translation isn't wanted. |
53
+ | `separator` | `string` | `"/"` | Text between crumbs, hidden from assistive technology. Leave it empty to style a separator with CSS instead. |
54
+
55
+ Types:
56
+
57
+ ```ts
58
+ export interface BreadcrumbItem {
59
+ /** Text of the crumb. */
60
+ label: string;
61
+ /** Route for the configured router link (`createUi({ link })`), rendered instead of an anchor. */
62
+ to?: LinkTo;
63
+ /** Plain URL, for crumbs without a router location. */
64
+ href?: string;
65
+ }
66
+
67
+ /** Whatever the app's router link accepts (`RouteLocationRaw` for vue-router). */
68
+ export type LinkTo = string | Record<string, unknown>;
69
+ ```
70
+
71
+ ## Styling
72
+
73
+ - Parts (`[data-part="…"]`): `breadcrumbs`, `breadcrumbs-list`, `breadcrumbs-item`, `breadcrumbs-separator`, `breadcrumbs-link`, `breadcrumbs-label`
74
+ - State attributes: `data-breadcrumbs-current`
75
+
76
+ ## Accessibility
77
+
78
+ - The trail is a `<nav>` landmark, named by `label` or the `breadcrumbs` translation.
79
+ - The crumbs are an ordered list, so assistive technology can announce each crumb's position.
80
+ - The last crumb is the current page and has `aria-current="page"`.
81
+ - Separators are `aria-hidden`, so they aren't read out.
@@ -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.