Accessibility Guide
VD3 UI's components ship with sensible roles, labels, focus styles, and motion guards. Accessibility is mostly about not undoing those defaults as you compose — and filling the gaps only you can: meaningful labels, alt text, and logical structure.
Keep focus visible
/* VD3 UI ships visible focus rings — never remove them outright */
.vd-btn:focus-visible {
outline: 2px solid var(--vd-color-primary);
outline-offset: 2px;
}Name every control
<!-- Icon-only controls need an accessible name; VdButton does not invent one. -->
<button class="vd-btn vd-btn-icon vd-btn-primary" aria-label="Close dialog">
<i class="ph ph-x" aria-hidden="true"></i>
</button>
<nav class="vd-pagination" aria-label="Pagination">…</nav>Respect reduced motion
VD3 UI respects user motion preference across all components, primitives (VdExpandTransition, VdTransition), and theme customizer controls. Users with motion sensitivities can choose between OS-driven behavior (auto), subtle opacity crossfades (reduce), or zero transitions (off):
/* All VD3 UI components and utilities automatically adapt to reduced motion */
(prefers-reduced-motion: reduce) {
:root:not([data-motion="full"]) {
--vd-duration-instant: 0ms;
--vd-duration-fast: 89ms;
--vd-duration-snappy: 89ms;
--vd-duration-normal: 89ms;
--vd-duration-moderate: 89ms;
--vd-duration-slow: 89ms;
--vd-duration-gentle: 89ms;
}
}
/* User overrides via html[data-motion]:
- data-motion="reduce": disables spatial movement, keeps 89ms opacity crossfades
- data-motion="off": disables transitions completely (0ms)
- data-motion="full": plays full animations regardless of OS preference */
html[data-motion="off"] * {
transition-duration: 0ms !important;
animation-duration: 0ms !important;
}Focus & Keyboard Composables API
@vanduo-oss/vd3 exports the same low-level accessibility composables used by its own modals, menus, lightboxes, and popovers:
| Composable | Returns | Description |
|---|---|---|
useFocusTrap(container) | { active: Ref<boolean>, activate(options?: { focus?: boolean }): void, deactivate(): void } | Traps Tab and Shift+Tab within visible focusable descendants of container. Moves focus to the first focusable element on activate() unless { focus: false } is passed. |
useKeyboardNav(container, options) | { activeIndex: Ref<number>, setItems(count: number): void } | Wires ArrowDown/ArrowRight, ArrowUp/ArrowLeft, Home, End, Enter (options.onSelect), and Escape (options.onEscape) across elements matching options.itemSelector (skipping disabled items). |
useClickOutside(refs, handler, enabled) | void | Attaches a capture-phase pointerdown listener while enabled (Ref<boolean>) is true and invokes handler() when the event target is outside every element in refs (Ref<HTMLElement | null>[]). |
import { ref } from "vue";
import {
useClickOutside,
useFocusTrap,
useKeyboardNav,
} from "@vanduo-oss/vd3";
const dialogRef = ref<HTMLElement | null>(null);
const menuRef = ref<HTMLElement | null>(null);
const triggerRef = ref<HTMLElement | null>(null);
const isOpen = ref(false);
// 1. Keep Tab / Shift+Tab inside an open dialog
const { active, activate, deactivate } = useFocusTrap(dialogRef);
// 2. Roving Arrow / Home / End / Enter / Escape navigation across items
const { activeIndex, setItems } = useKeyboardNav(menuRef, {
itemSelector: '[role="menuitem"]',
onSelect: (index) => console.log("Selected item", index),
onEscape: () => (isOpen.value = false),
});
// 3. Close when pointerdown lands outside all provided refs while enabled
useClickOutside([menuRef, triggerRef], () => {
isOpen.value = false;
}, isOpen);Don't undo this
| Component | Rule |
|---|---|
| Modal | Do not strip aria-modal or replace the dialog markup. Focus is trapped while open and should return to the trigger on close — keep that tree intact. |
| Toast | Mount VdToastContainer once so announcements go through its aria-live region. Prefer plain-text messages over HTML. |
| Focus helpers | useFocusTrap keeps Tab inside a dialog. useKeyboardNav moves a roving index. useClickOutside closes a popover when the pointer leaves it. They are exported from @vanduo-oss/vd3. |
| Tabs | Keep role="tablist" / aria-selected. Do not restyle a row of divs and drop arrow-key roving. |
| Overlays | Modals, offcanvas, and menus expect a sensible focus order. Do not tabindex="-1" the first interactive control inside. |
| Test it | This docs repo runs an axe smoke suite (pnpm run test:a11y). Run axe (or equivalent) against your app's real routes — the checklist is not a certificate. |
Accessibility checklist
| Check | What it means |
|---|---|
| Keyboard reachable | Every interactive control is focusable and operable with Tab/Enter/Space/arrows. |
| Visible focus | Keep the focus ring; use :focus-visible to scope it to keyboard users. |
| Semantic roles | Use real <button>/<a>/<nav>; components set role / aria-* for you. |
| Labels & names | Icon-only VdButton needs aria-label; decorative icons get aria-hidden; images need alt. |
| Color contrast | Check text and control contrast in light and dark themes, including your chosen primary color and translucent surfaces. |
| Reduced motion | Animated effects honour prefers-reduced-motion. |
| Live regions | Toasts and count changes use aria-live to announce updates. |
Consult the component-specific guidance where available, and verify the keyboard and screen-reader behavior of your composed interface.