-{{ product.discount }}% {{ product.category }} {{ product.name }} ({{ product.reviewsCount }}) {{ formatPrice(product.originalPrice) }} {{ formatPrice(product.price) }} Ajouter au panier Rupture de stock
` by default, `` if `href` is provided - `role="button"` + `tabindex="0"` when clickable without href - Keyboard navigation: `Enter` and `Space` trigger click - `aria-disabled="true"` when disabled - `rel="noopener noreferrer"` automatic with `target="_blank"` - `loading="lazy"` on images - Supports `prefers-contrast: high` and `prefers-reduced-motion: reduce` - Horizontal direction switches to vertical on mobile (< 640px) --- # Button Flexible button component with multiple variants, sizes and states. Supports keyboard interactions and loading states. ## Examples with icons ### Icons ```vue Add Next ``` ### Variants ```vue Primary Secondary Outline Ghost ``` ### Sizes ```vue Small Medium Large ``` ### States ```vue Normal Disabled Loading ``` ### Full width ```vue Full width button Outline full width ``` ## Link button With `to` (router link) or `href` (plain link), the button is rendered as a link, with the same look. A link to a page stays a link for screen readers, middle click or "open in a new tab". ```vue Projects Project 42 External site ``` When disabled or loading, the link loses its destination: it can no longer be reached with the keyboard and does not navigate. Without a router, `to` gives a plain ``. ## API ### Props | Prop | Type | Default | Description | |------|------|---------|-------------| | `type` | `'button' \| 'submit' \| 'reset'` | `'button'` | Native type. Use `'submit'` to submit a form | | `variant` | `'primary' \| 'secondary' \| 'outline' \| 'ghost' \| 'custom'` | `'primary'` | Visual variant: solid primary, soft secondary, neutral outline (subtle border and highlight), transparent ghost | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Size: 32/36/40px on mobile, 28/32/36px from 640px | | `radius` | `'none' \| 'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl' \| 'full'` | `undefined` | Border radius. Defaults to the control radius (`--su-radius-control`, 10px) | | `disabled` | `boolean` | `false` | Disable the button | | `loading` | `boolean` | `false` | Show loading spinner | | `block` | `boolean` | `false` | Take full available width | | `icon` | `Component` | `undefined` | Icon to display | | `iconDisplay` | `'left' \| 'right' \| 'only'` | `'left'` | Icon position | | `to` | `string \| RouteLocationRaw` | `undefined` | Router link: rendered by RouterLink (or the plugin's [`linkComponent`](https://surgeui.com/en/guide/installation.md#router-links)) | | `href` | `string` | `undefined` | Plain link: rendered by `` | | `target` | `'_blank' \| '_self' \| '_parent' \| '_top'` | `undefined` | Link target (`to` or `href`) | | `rel` | `string` | `undefined` | Link `rel`; `noopener noreferrer` by default with `target="_blank"` | | `ariaLabel` | `string` | `undefined` | Accessible label for screen readers | | `ariaDescribedBy` | `string` | `undefined` | ID of element describing the button | | `ariaExpanded` | `boolean` | `undefined` | Indicates if controlled element is expanded | | `ariaPressed` | `boolean` | `undefined` | Indicates pressed state of toggle button | | `role` | `string` | `undefined` | Custom ARIA role | | `tabIndex` | `number` | `0` | Tab order | | `loadingLabel` | `string` | - | Text read while loading (translated otherwise) | ### Events | Event | Type | Description | |-------|------|-------------| | `@click` | `(event: MouseEvent) => void` | Emitted when button is clicked | | `@focus` | `(event: FocusEvent) => void` | Emitted when button receives focus | | `@blur` | `(event: FocusEvent) => void` | Emitted when button loses focus | | `@keydown` | `(event: KeyboardEvent) => void` | Emitted when key is pressed | ### Slots | Slot | Description | |------|-------------| | `default` | Button content | ## Accessibility The Button component follows WCAG 2.1 AA standards: ### ✅ Accessibility features - **Keyboard navigation**: Support for Enter and Space keys - **Visible focus**: Clear and contrasted focus indicator - **Minimum sizes**: Respects minimum touch target sizes (44px) - **Contrast**: WCAG AA compliant contrast ratios (4.5:1 minimum) - **ARIA states**: Complete support for ARIA attributes - **Screen readers**: Accessible labels and descriptions - **Reduced motion**: Respects `prefers-reduced-motion` - **Dark mode**: Adapted contrast in dark mode - **High contrast**: Support for `prefers-contrast: high` - **Accessible icons**: Icons marked with `aria-hidden="true"` ### 🎯 Best practices ```vue Add item Save Auto-saves every 30 seconds {{ isActive ? 'Active' : 'Inactive' }} ``` ## Usage examples ### Using with Heroicons The most common Heroicons are available globally: ```vue Add Continue ``` ### Custom icon import To use other Heroicons: ```vue Settings ``` ### Button with click handler ```vue Click me ``` ### Form submission button ```vue {{ isSubmitting ? 'Submitting...' : 'Submit' }} ``` ## Global configuration You can configure default button values when installing the design system: ```js // main.js import { createApp } from 'vue' import SurgeUI from '@surgeui/vue' import '@surgeui/vue/style.css' const app = createApp(App) // Configure default values app.use(SurgeUI, { buttonRadius: 'lg', // All buttons will have large radius by default buttonVariant: 'outline', // All buttons will be outline by default buttonSize: 'lg' // All buttons will be large by default }) ``` ### Usage with global configuration ```vue Button with global config Same thing explicitly Specific variant Specific size Specific radius ``` ### Available configuration options | Option | Type | Description | |--------|------|-------------| | `buttonRadius` | `'none' \| 'sm' \| 'md' \| 'lg' \| 'xl'` | Default border radius | | `buttonVariant` | `'primary' \| 'secondary' \| 'outline' \| 'ghost'` | Default variant | | `buttonSize` | `'sm' \| 'md' \| 'lg'` | Default size | --- # ButtonGroup ButtonGroup component for organizing and aligning buttons with controlled spacing. Supports propagation of `size` and `variant` props to child buttons and special border handling for connected buttons. ## Usage examples ### Basic ButtonGroup ```vue First Second Third ``` ### Spacing (gap) ```vue Action 1 Action 2 Action 3 Action 1 Action 2 Action 3 Action 1 Action 2 Action 3 First Middle Last ``` ### Size propagation ```vue Small 1 Small 2 Small 3 Large 1 Large 2 Large 3 ``` ### Variant propagation ```vue Action 1 Action 2 Action 3 Action 1 Action 2 Action 3 ``` ### Connected buttons with variants ```vue Left Center Right ``` ## API ### Props | Prop | Type | Default | Description | |------|------|---------|-------------| | `gap` | `'sm' \| 'md' \| 'lg' \| 'none'` | `'md'` | Spacing between buttons | | `size` | `'sm' \| 'md' \| 'lg'` | `undefined` | Forced size for all buttons | | `variant` | `'primary' \| 'secondary' \| 'outline' \| 'ghost'` | `undefined` | Forced variant for all buttons | ### Accessibility attributes | Prop | Type | Default | Description | |------|------|---------|-------------| | `ariaLabel` | `string` | `undefined` | Accessible label for the group | | `ariaDescribedBy` | `string` | `undefined` | ID of the description element | | `role` | `string` | `undefined` | Custom ARIA role (e.g. 'toolbar', 'group') | ### Slots | Slot | Description | |------|-------------| | `default` | Buttons to display in the group | ## Prop behavior ### 🔄 Automatic propagation When `size` or `variant` are defined on `ButtonGroup`, they **override** the props of child buttons automatically: ```vue Button 1 Button 2 Button 3 ``` ### 🎯 Content validation The component automatically checks that only `Button` components are passed in the slot: - ✅ **Button components**: Processed and styled normally - ⚠️ **Other components**: Warning in console and element ignored - ✅ **Comments/text**: Silently ignored (normal Vue behavior) ## Spacing and borders ### 📏 Gap values - `gap="sm"` : 0.25rem (4px) - `gap="md"` : 0.5rem (8px) - **default** - `gap="lg"` : 0.75rem (12px) - `gap="none"` : 0px with connected borders ### 🔗 Gap "none" - Connected buttons When `gap="none"`, buttons are visually connected: - **Overlapping borders**: `margin-left: -1px` to avoid double borders - **Adapted border-radius**: - First button: left corners rounded only - Middle buttons: no rounded corners - Last button: right corners rounded only - Single button: all corners rounded - **Smart z-index**: Focus, hover and active have higher z-index ## Accessibility The ButtonGroup component follows WCAG 2.1 AA standards: ### ✅ Accessibility features - **ARIA roles**: Support for `toolbar`, `group`, etc. roles - **Group labels**: `aria-label` to describe the group - **Keyboard navigation**: Preserves Tab navigation between buttons - **Visible focus**: Z-index management for focus visibility - **Descriptions**: Support for `aria-describedby` for descriptions ### 🎯 Best practices ```vue B I U Page 1 Page 2 Page 3 Create Edit Delete ``` ## Advanced usage examples ### Formatting toolbar ```vue ``` ### CRUD actions ```vue Available actions Create Edit Delete ``` ### Page navigation ```vue {{ page }} ``` ## Slot content control The `ButtonGroup` component automatically checks the content of its slot: ### ✅ Accepted elements - Design system `Button` components - Vue comments (ignored) - Empty text nodes (ignored) ### ⚠️ Rejected elements - Other components or HTML elements - Warning in development console - Element ignored in render ### 🔍 Validation example ```vue Button 1 Button 2 Valid button Non-button element Another valid button ``` This approach ensures visual consistency while informing developers of potential issues. --- # Link Flexible Link component for internal and external links with icon support, variants, and full accessibility. Compatible with Vue Router and native HTML links. ## Usage Examples ### Basic Link ```vue Internal link External link Vue Router link ``` ### Variants ```vue Default link Primary link Secondary link Muted link ``` ### Sizes ```vue Small Medium Large ``` ### Underline ```vue Always underlined Underlined on hover Never underlined ``` ### With Icons ```vue Home Next GitHub ``` ### States ```vue Normal link Disabled link ``` ## API ### Props | Prop | Type | Default | Description | |------|------|---------|-------------| | `href` | `string` | `undefined` | Destination URL (native HTML links) | | `to` | `string \| RouteLocationRaw` | `undefined` | Router link: RouterLink, or the plugin's `linkComponent`; `` without a router | | `target` | `'_blank' \| '_self' \| '_parent' \| '_top'` | `undefined` | Link target | | `rel` | `string` | `undefined` | Link relationship | | `variant` | `'default' \| 'primary' \| 'secondary' \| 'muted'` | `'default'` | Visual variant of the link | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Link size | | `underline` | `'always' \| 'hover' \| 'never'` | `'hover'` | Underline behavior | | `disabled` | `boolean` | `false` | Disables the link | | `external` | `boolean` | `false` | Marks the link as external | | `externalLabel` | `string` | `"(s'ouvre dans un nouvel onglet)"` | Text read by screen readers when the link opens in a new tab | | `icon` | `Component` | `undefined` | Icon to display | | `iconDisplay` | `'top' \| 'left' \| 'right' \| 'only'` | `'left'` | Icon position | | `block` | `boolean` | - | Block link, full width | ### Accessibility Attributes | Prop | Type | Default | Description | |------|------|---------|-------------| | `ariaLabel` | `string` | `undefined` | Accessible label | | `ariaDescribedBy` | `string` | `undefined` | ID of the description element | | `role` | `string` | `undefined` | Custom ARIA role | | `tabIndex` | `number` | `0` | Tab order | ### Events | Event | Type | Description | |-------|------|-------------| | `@click` | `(event: MouseEvent) => void` | Emitted when the link is clicked | | `@focus` | `(event: FocusEvent) => void` | Emitted when the link receives focus | | `@blur` | `(event: FocusEvent) => void` | Emitted when the link loses focus | | `@keydown` | `(event: KeyboardEvent) => void` | Emitted when a key is pressed | ### Slots | Slot | Description | |------|-------------| | `default` | Link content | ## Automatic External Link Detection The component automatically detects external links and applies security best practices: ### 🔍 Detection Criteria - `external` prop set to `true` - URL starting with `http://` or `https://` - URL starting with `//` - `target` prop set to `_blank` ### 🛡️ Automatic Security For external links, the component automatically adds: - `target="_blank"` (if not defined) - `rel="noopener noreferrer"` (if not defined) - Automatic external icon (if no custom icon) ```vue Vue.js Vue.js ``` ## Global Configuration You can configure default link values when installing the design system: ```js // main.js import { createApp } from 'vue' import SurgeUI from '@surgeui/vue' import '@surgeui/vue/style.css' const app = createApp(App) // Configure default values app.use(SurgeUI, { linkVariant: 'primary', // All links will be primary by default linkSize: 'lg', // All links will be large by default linkUnderline: 'never' // All links will never be underlined by default }) ``` ### Usage with Global Configuration ```vue Link with global config Same thing explicitly Specific variant Specific size Specific underline ``` ### Available Configuration Options | Option | Type | Description | |--------|------|-------------| | `linkVariant` | `'default' \| 'primary' \| 'secondary' \| 'muted'` | Default variant | | `linkSize` | `'sm' \| 'md' \| 'lg'` | Default size | | `linkUnderline` | `'always' \| 'hover' \| 'never'` | Default underline | ## Accessibility The Link component complies with WCAG 2.1 AA standards: ### ✅ Accessibility Features - **Keyboard navigation**: Support for Enter and Space keys - **Visible focus**: Clear and contrasted focus indicator - **Contrast**: WCAG AA compliant contrast ratios (4.5:1 minimum) - **ARIA states**: Full support for ARIA attributes - **Screen readers**: Accessible labels and descriptions - **External links**: Clear indication with icon and security attributes - **Dark mode**: Automatically adapted contrast - **High contrast**: Support for `prefers-contrast: high` - **Reduced motion**: Respects `prefers-reduced-motion` ### 🎯 Best Practices ```vue Home External site Help Access help documentation Home About Contact ``` ## Usage Examples ### Main Navigation ```vue Home Profile Settings ``` ### Breadcrumb ```vue Home / Products / Laptops / MacBook Pro ``` ### Footer with External Links ```vue ``` ### Links with Event Handlers ```vue Link with handler External link with analytics ``` ## Keyboard Navigation | Key | Action | |-----|--------| | `Tab` | Navigate to/from the link | | `Enter` | Activate the link | | `Space` | Activate the link | ## Router links With `to`, the link is rendered by the router's link component: the plugin's [`linkComponent`](https://surgeui.com/en/guide/installation.md#router-links) (NuxtLink…), otherwise RouterLink when registered (Vue Router, Nuxt). Without a router, `to` gives a plain ``. ```vue Dashboard User profile Static page External site ``` When disabled, a `to` link loses its destination: it does not navigate. ## External Link Security For all external links, the component automatically applies security best practices: ### 🛡️ Security Attributes - `target="_blank"`: Opens in a new tab - `rel="noopener noreferrer"`: Prevents "tabnabbing" attacks - Automatic external icon to visually indicate redirection ### 🎯 Security Examples ```vue External site External site ``` --- # LinkGroup LinkGroup component for organizing and aligning links with controlled spacing. Supports propagation of `size`, `variant` and `underline` props to child links and special border handling for connected links. ## Usage examples ### Basic LinkGroup ```vue Home About Contact ``` ### Spacing (gap) ```vue Page 1 Page 2 Page 3 Page 1 Page 2 Page 3 Page 1 Page 2 Page 3 First Middle Last ``` ### Size propagation ```vue Small link 1 Small link 2 Small link 3 Large link 1 Large link 2 Large link 3 ``` ### Variant propagation ```vue Link 1 Link 2 Link 3 Link 1 Link 2 Link 3 ``` ### Vertical direction ```vue Dashboard Projects Team Settings ``` ## API ### Props | Prop | Type | Default | Description | |------|------|---------|-------------| | `gap` | `'sm' \| 'md' \| 'lg' \| 'none'` | `'md'` | Spacing between links | | `separator` | `'none' \| 'dot' \| 'slash' \| 'pipe' \| 'arrow'` | `'none'` | Separator between links | | `size` | `'sm' \| 'md' \| 'lg'` | `undefined` | Forced size for all links | | `variant` | `'default' \| 'primary' \| 'secondary' \| 'muted'` | `undefined` | Forced variant for all links | | `underline` | `'always' \| 'hover' \| 'never'` | `undefined` | Forced underline for all links | | `direction` | `'horizontal' \| 'vertical'` | `'horizontal'` | Group direction | ### Accessibility attributes | Prop | Type | Default | Description | |------|------|---------|-------------| | `ariaLabel` | `string` | `undefined` | Accessible label for the group | | `ariaDescribedBy` | `string` | `undefined` | ID of the description element | | `role` | `string` | `undefined` | Custom ARIA role (e.g. 'navigation', 'group') | ### Slots | Slot | Description | |------|-------------| | `default` | Links to display in the group | ## Separators Separators allow adding characters between links to improve readability: ### 🎯 Separator types - **`none`** : No separator (default) - **`dot`** : Middle dot (•) - **`slash`** : Forward slash (/) - **`pipe`** : Vertical bar (|) - **`arrow`** : Right arrow (→) ```vue Home Products Laptops Home About Contact ``` ### 📱 Responsive behavior Separators are automatically hidden in vertical mode to avoid visual clutter. ## Prop behavior ### 🔄 Automatic propagation When `size`, `variant` or `underline` are defined on `LinkGroup`, they **override** the props of child links automatically: ```vue Link 1 Link 2 Link 3 ``` ### 🎯 Content validation The component automatically checks that only `Link` components are passed in the slot: - ✅ **Link components**: Processed and styled normally - ⚠️ **Other components**: Warning in console and element ignored - ✅ **Comments/text**: Silently ignored (normal Vue behavior) ## Spacing and borders ### 📏 Gap values - `gap="sm"` : 0.25rem (4px) - `gap="md"` : 0.5rem (8px) - **default** - `gap="lg"` : 0.75rem (12px) - `gap="none"` : 0px with connected borders ### 🔗 Gap "none" - Connected links When `gap="none"`, links are visually connected: - **Overlapping borders**: `margin-left: -1px` to avoid double borders - **Adapted border-radius**: - First link: left corners rounded only - Middle links: no rounded corners - Last link: right corners rounded only - Single link: all corners rounded - **Smart z-index**: Focus, hover and active have higher z-index ## Direction ### 📐 Horizontal vs Vertical - **Horizontal** (default): Links aligned in row - **Vertical**: Links stacked in column For `gap="none"` in vertical mode: - Margins become `margin-top: -1px` - Border-radius adapts (top/bottom instead of left/right) ## Accessibility The LinkGroup component follows WCAG 2.1 AA standards: ### ✅ Accessibility features - **ARIA roles**: Support for `navigation`, `group`, etc. roles - **Group labels**: `aria-label` to describe the group - **Keyboard navigation**: Preserves Tab navigation between links - **Visible focus**: Z-index management for focus visibility - **Descriptions**: Support for `aria-describedby` for descriptions ### 🎯 Best practices ```vue Home Products About Home Products Laptops Privacy Terms Contact ``` --- # Toggle A toggleable button with two states (on/off). Accepts a text label or icon, with full accessibility via `role="switch"` and `aria-checked`. ## Description `Toggle` is an atomic component for toggling a boolean state. Unlike `Switch` which looks like a physical switch, `Toggle` appears as a button whose visual state changes when active/inactive. Ideal for toolbars (bold, italic), favorites, or filters. ## Usage ### Simple toggle with label ```vue ``` ### Toggle with icon ```vue ``` ### Variants ```vue ``` ### Sizes ```vue ``` ## API ### Props | Prop | Type | Default | Description | |------|------|---------|-------------| | `modelValue` | `boolean` | `false` | Toggle state (v-model) | | `label` | `string` | - | Text displayed in the toggle | | `icon` | `Component` | - | Icon displayed (inactive state) | | `activeIcon` | `Component` | - | Icon displayed when active (replaces `icon`) | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Size | | `variant` | `'default' \| 'outline' \| 'ghost'` | `'default'` | Visual variant: transparent with a neutral tint when on, control surface, or primary tint when on | | `radius` | `Radius` | `undefined` | Border radius. Defaults to the control radius (10px) | | `disabled` | `boolean` | `false` | Disables the toggle | ### Events | Event | Payload | Description | |-------|---------|-------------| | `update:modelValue` | `boolean` | Emitted on state change (v-model) | | `change` | `boolean` | Emitted on state change with new value | ### Accessibility - `role="switch"` with `aria-checked` to indicate state - Keyboard navigation: `Tab` for focus, `Enter` / `Space` to toggle - `aria-label` automatically derived from `label` if not explicitly provided - Screen reader compatible --- # ToggleGroup A group of toggles with exclusive or multi-selection. Supports connected mode, vertical/horizontal orientation, and ARIA roles adapted to the selection mode. ## Description `ToggleGroup` displays a list of `Toggle` components and manages selection. In `exclusive` mode, only one toggle can be active at a time (similar to a radio group). In `multi` mode, multiple toggles can be active simultaneously. The connected mode (`gap="none"`) visually merges the toggles into a single block. ## Usage ### Multi-selection (default) ```vue ``` ### Exclusive selection ```vue ``` ### Connected mode (gap=none) ```vue ``` ### Vertical orientation ```vue ``` ## API ### Props | Prop | Type | Default | Description | |------|------|---------|-------------| | `modelValue` | `(string \| number)[]` | `[]` | Active values (v-model) | | `items` | `ToggleGroupItem[]` | **required** | List of toggles | | `mode` | `'exclusive' \| 'multi'` | `'multi'` | Selection mode | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Toggle size | | `variant` | `'default' \| 'outline' \| 'ghost'` | `'default'` | Visual variant | | `radius` | `Radius` | `'md'` | Border radius | | `gap` | `'none' \| 'sm' \| 'md' \| 'lg'` | `'md'` | Spacing (none = connected) | | `orientation` | `'horizontal' \| 'vertical'` | `'horizontal'` | Group orientation | | `disabled` | `boolean` | `false` | Disables the entire group | ### ToggleGroupItem | Property | Type | Description | |----------|------|-------------| | `value` | `string \| number` | Unique identifier (required) | | `label` | `string` | Displayed text | | `icon` | `Component` | Icon (inactive state) | | `activeIcon` | `Component` | Icon (active state) | | `disabled` | `boolean` | Disables this item | ### Events | Event | Payload | Description | |-------|---------|-------------| | `update:modelValue` | `(string \| number)[]` | Emitted on change (v-model) | | `change` | `(string \| number)[]` | New list of active values | | `select` | `string \| number, boolean` | Selected item and its new state | ### Accessibility - `role="radiogroup"` in exclusive mode, `role="group"` in multi mode - Each toggle uses `role="switch"` with `aria-checked` - Keyboard navigation: `Tab` between toggles, `Enter` / `Space` to toggle - `aria-label` on the container to describe the group --- # FloatButton FloatButton component for placing a floating button in the screen corner with support for slots, badges, tooltips and complete accessibility according to W3C standards. ## Usage examples ### Basic FloatButton ```vue ``` ### With badge ```vue ``` ### As external link ```vue ``` ### With ButtonGroup ```vue ``` ## API ### Props | Prop | Type | Default | Description | |------|------|---------|-------------| | `position` | `'start' \| 'end'` | `'end'` | Button side: `end` is right in LTR, left in RTL; `left` and `right` are aliases | | `offset` | `{ x?: number, y?: number }` | `{ x: 24, y: 24 }` | Custom offset in pixels | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Floating button size | | `icon` | `Component` | `undefined` | Button icon | | `label` | `string` | `undefined` | Button label (displayed in tooltip) | | `href` | `string` | `undefined` | Destination URL (transforms to link) | | `target` | `'_blank' \| '_self' \| '_parent' \| '_top'` | `undefined` | Link target | | `rel` | `string` | `undefined` | Link relation | | `badge` | `string` | `undefined` | Badge text displayed in top right | | `variant` | `'primary' \| 'secondary' \| 'outline' \| 'ghost'` | `'primary'` | Button variant | | `disabled` | `boolean` | `false` | Disable the button | | `loading` | `boolean` | `false` | Loading state | | `zIndex` | `number` | `1000` | Button z-index | | `hideOnScroll` | `boolean` | `false` | Hide when scrolling down | | `showTooltip` | `boolean` | `true` | Show tooltip on hover | | `tooltipPosition` | `'top' \| 'bottom' \| 'left' \| 'right'` | `'left'` | Tooltip position | ### Events | Event | Type | Description | |-------|------|-------------| | `@click` | `(event: MouseEvent) => void` | Emitted when button is clicked | | `@focus` | `(event: FocusEvent) => void` | Emitted when button receives focus | | `@blur` | `(event: FocusEvent) => void` | Emitted when button loses focus | ### Slots | Slot | Description | |------|-------------| | `default` | Content displayed above the button (LinkGroup or ButtonGroup) | ## Advanced features ### 🎯 Smart positioning The component automatically handles: - **Fixed position**: Stays visible during scroll - **Custom offset**: Precise position adjustment - **Safe areas**: iPhone notch support (safe-area-inset) - **Responsive**: Automatic mobile adjustment ### 🏷️ Notification badge The badge provides visual feedback for: - **Notifications**: Number of unread messages - **Alerts**: Status indicators - **Counters**: Pending items - **Animation**: Pulse to attract attention ### 💬 Smart tooltip The tooltip automatically adapts: - **Position**: Adjusts based on button position - **Content**: Uses `label` as text - **Accessibility**: The `label` already names the button, so the tooltip is hidden from screen readers - **Keyboard**: Shown on focus, dismissed with Escape ### 📱 Responsive behavior - **Position**: The `offset` prop applies at every screen width (pass a smaller offset on mobile if needed) - **Safe areas**: Support for notches and navigation bars - **Slot**: Maximum width adapted to screen ## Accessibility The FloatButton component follows WCAG 2.1 AA standards: ### ✅ Accessibility features - **Keyboard navigation**: Support for Enter and Space keys - **Visible focus**: Clear and contrasted focus indicator - **Accessible labels**: Automatic or custom `aria-label` - **Tooltip**: Shown on hover and focus, dismissed with Escape (WCAG 1.4.13) - **Accessible badges**: The badge value is appended to the button name (e.g. "Messages (3)") - **Contrast**: WCAG AA compliant contrast ratios (4.5:1 minimum) - **Minimum sizes**: Respects minimum touch target sizes (44px) - **Dark mode**: Automatically adapted contrast - **High contrast**: Support for `prefers-contrast: more` - **Reduced motion**: Respects `prefers-reduced-motion` ### 🎯 Best practices ```vue You have 5 unread messages Action 1 Action 2 ``` ## Keyboard navigation | Key | Action | |-----|--------| | `Tab` | Navigate to/from floating button | | `Enter` | Activate button or follow link | | `Space` | Activate button | | `Escape` | Close slot (if open) | ## Common use cases ### 💬 Support and help - **Live chat**: Quick access to customer support - **Help center**: Link to documentation - **Contact**: Phone, email, form ### ➕ Primary actions - **Add**: Create a new element - **Compose**: Write a message, article - **Create**: New project, document ### 🔧 Tools and settings - **Settings**: Quick access to preferences - **Tools**: Advanced features - **Shortcuts**: Frequent actions ### 📱 Mobile navigation - **Menu**: Main navigation on mobile - **Back to top**: Scroll to top of page - **Share**: Quick content sharing ## Best practices ### ✅ Do - Use descriptive `label` for accessibility - Limit to 1-2 floating buttons per page - Place primary actions on the right (more accessible) - Use badges for important notifications - Test on mobile and with screen readers ### ❌ Don't - Hide essential features in the slot - Use too many floating buttons (visual pollution) - Forget the `label` for accessibility - Place button over important content - Use excessive animations ## Performance ### 🚀 Built-in optimizations - **Passive events**: Optimized scroll listeners - **CSS transitions**: Hardware-accelerated animations - **Lazy rendering**: Slot rendered only when needed - **Automatic cleanup**: Event listener removal ### 📊 Minimal impact - **Generated CSS**: ~2KB gzipped - **JavaScript**: Lightweight and optimized logic - **Rendering**: No impact on page performance - **Accessibility**: No performance compromises --- # Dropdown Dropdown component that looks like a button but displays a list of options when clicked. Each option can be a link (if it contains an href) or trigger an action. Compliant with W3C accessibility standards with complete keyboard and screen reader support. ## Usage examples ### Basic Dropdown ```vue ``` ### With mixed links and actions ```vue ``` ### Icon only With an icon only, `label` is not displayed: it becomes the button's accessible name (`aria-label`). `ariaLabel` still wins when provided. ```vue ``` ### Custom trigger The `trigger` slot replaces the built-in button: an avatar, a button with a counter… Bind `props` to your button: it receives the `id`, the ARIA attributes (`aria-haspopup`, `aria-expanded`, `aria-controls`), the click and keyboard handlers. The menu is positioned against it and focus returns to it on close. ```vue ``` The trigger must be a button (`` or `SuButton`): it is reachable with the keyboard and activated with Enter and Space. Without a bound `id`, the first element of the slot is used as the trigger. ### Checkable options `type: 'checkbox'` or `type: 'radio'` (exclusive choice) adds a check mark and the `checked` state (`menuitemcheckbox` and `menuitemradio` roles, `aria-checked`). The Dropdown does not keep the state: update `checked` on `select`. Separators delimit radio groups. ```vue ``` ## API ### Props | Prop | Type | Default | Description | |------|------|---------|-------------| | `options` | `DropdownOption[]` | `[]` | List of dropdown options | | `trigger` | `'click' \| 'hover'` | `'click'` | Opening trigger | | `placement` | `'bottom-start' \| 'bottom-end' \| 'top-start' \| 'top-end' \| 'left-start' \| 'left-end' \| 'right-start' \| 'right-end'` | `'bottom-start'` | Menu position | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Button size | | `variant` | `'primary' \| 'secondary' \| 'outline' \| 'ghost'` | `'outline'` | Button variant | | `disabled` | `boolean` | `false` | Disable the dropdown | | `loading` | `boolean` | `false` | Loading state | | `icon` | `Component` | `undefined` | Button icon | | `iconDisplay` | `'left' \| 'right' \| 'only'` | `'left'` | Icon position | | `label` | `string` | `undefined` | Button label; accessible name with an icon only | | `closeOnSelect` | `boolean` | `true` | Close after selection | | `maxHeight` | `string` | `'300px'` | Maximum menu height | | `loadingLabel` | `string` | - | Text read while loading (translated otherwise) | Attributes not declared as props (`id`, `aria-*`, `data-*`, listeners) go on the trigger button; `class` and `style` stay on the container. An `id` therefore appears only once, on the button the menu refers to (`aria-labelledby`). ### Option types #### DropdownOption ```typescript interface DropdownOption { value: string | number label: string type?: 'item' | 'checkbox' | 'radio' // Checkable option (menuitemcheckbox, menuitemradio) checked?: boolean // Checked state of a checkbox or radio option href?: string // If present, option becomes a link to?: string | RouteLocationRaw // Router link (RouterLink); disabled, the option does not navigate target?: '_blank' | '_self' | '_parent' | '_top' rel?: string disabled?: boolean icon?: Component description?: string separatorBefore?: boolean // Draws a separator before the option } // Separator alone (value and label optional) type DropdownSeparatorOption = { type: 'separator' } ``` ### Events | Event | Type | Description | |-------|------|-------------| | `@select` | `(option: DropdownOption) => void` | Emitted when an option is selected | | `@open` | `() => void` | Emitted when menu opens | | `@close` | `() => void` | Emitted when menu closes | | `@focus` | `(event: FocusEvent) => void` | Emitted when button receives focus | | `@blur` | `(event: FocusEvent) => void` | Emitted when button loses focus | ### Slots | Slot | Props | Description | |------|-------|-------------| | `trigger` | `{ props, isOpen }` | Trigger replacing the built-in button; bind `props` (id, ARIA, click, keyboard) to your button | ## Difference between links and actions The Dropdown component automatically handles two types of options: ### 🔗 Options with links (href) Options with an `href` property become links: - Automatic navigation to URL - External link support with `target="_blank"` - Automatic security attributes (`rel="noopener noreferrer"`) - Automatic external icon for external links ```vue { value: 'docs', label: 'Documentation', href: '/docs' } { value: 'github', label: 'GitHub', href: 'https://github.com', target: '_blank' } ``` ### ⚡ Options with actions Options without `href` trigger the `@select` event: - Event emission with complete option - Automatic menu closure (if `closeOnSelect` is true) - Custom handling in parent component ```vue { value: 'delete', label: 'Delete', icon: TrashIcon } ``` ## Separators Separators group options visually (`role="separator"`). Two forms: ```ts const options = [ { value: 'edit', label: 'Edit' }, { value: 'duplicate', label: 'Duplicate' }, { type: 'separator' }, // separator alone { value: 'archive', label: 'Archive' }, { value: 'delete', label: 'Delete', separatorBefore: true } // separator before the option ] ``` `separatorBefore` is ignored on the first option and right after a separator (no double line). ## Accessibility The Dropdown component follows WCAG 2.1 AA standards: ### ✅ Accessibility features - **Menu button pattern (WAI-ARIA)**: button with `aria-haspopup="menu"`, `role="menu"` menu named by the button, `role="menuitem"` items - **Roving focus**: one item at a time receives focus; arrows move it in a loop, disabled items are skipped - **Typeahead**: typing a letter moves focus to the next item starting with it - **Closing**: Escape (focus returns to the button), pointer down outside or focus leaving the menu; Tab leaves the menu to the next element on the page - **ARIA states**: `aria-expanded`, `aria-haspopup`, `aria-controls` - **Accessible labels**: Support for `aria-label` and `aria-describedby` - **Visible focus**: Clear and contrasted focus indicators - **Color contrast**: WCAG AA compliant ratios - **Minimum sizes**: Respects minimum touch target sizes - **Dark mode**: Automatically adapted contrast - **High contrast**: Support for `prefers-contrast: high` - **Reduced motion**: Respects `prefers-reduced-motion` ### 🎯 Best practices ```vue Menu of available actions for this item ``` ## Keyboard navigation | Key | Action | |-----|--------| | `Enter` / `Space` | On the button: open the menu on the first item. On an item: activate it | | `Arrow Down` | On the button: open the menu on the first item. In the menu: next item (looping) | | `Arrow Up` | On the button: open the menu on the last item. In the menu: previous item (looping) | | `Home` / `End` | First / last item | | `A-Z` | Typeahead: next item starting with these letters | | `Escape` | Close the menu, focus returns to the button | | `Tab` | Close the menu and move to the next element on the page | --- # Breadcrumb Shows where the page sits in the site hierarchy and lets users go back up a level. The last item is the current page. ## Usage ### Basic usage ```vue ``` ### Separators ```vue ``` ### Collapsed path Beyond `maxItems` items, the middle of the path collapses behind a "…" button that expands it. ```vue ``` ### Home as an icon With `iconOnly`, the label is still read by screen readers. ```vue ``` ### With Vue Router The `item` slot replaces an item's rendering, for instance with a `RouterLink`. ```vue {{ item.label }} {{ item.label }} ``` ## API ### Props | Prop | Type | Default | Description | |------|------|---------|-------------| | `items` | `BreadcrumbItem[]` | `[]` | Path items, from the root to the current page | | `separator` | `'chevron' \| 'slash' \| 'dot'` | `'chevron'` | Separator (or `separator` slot) | | `maxItems` | `number` | - | Beyond this, the middle of the path collapses | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Text size | | `ariaLabel` | `string` | `'Breadcrumb'` (locale) | Navigation name | | `expandLabel` | `string` | `'Show full path'` (locale) | Name of the "…" button | ### BreadcrumbItem | Property | Type | Description | |----------|------|-------------| | `label` | `string` | Label | | `href` | `string` | Link (without a link: plain text) | | `to` | `string \| RouteLocationRaw` | Router link (RouterLink or the plugin's `linkComponent`) | | `target` | `'_blank' \| '_self' \| '_parent' \| '_top'` | Link target | | `icon` | `Component` | Icon before the label | | `iconOnly` | `boolean` | Visually hides the label | ### Slots | Slot | Props | Description | |------|-------|-------------| | `item` | `{ item, index, current }` | Item rendering | | `separator` | - | Custom separator | ## Accessibility - `` containing an ordered list. - The current page (last item) has `aria-current="page"`. - Separators are hidden from screen readers (`aria-hidden`). - The "…" button is named; once the path expands, focus moves to the first revealed item. - In RTL, the chevron is mirrored. --- # Pagination Navigation between the pages of a list or a table. The number of buttons stays constant (ellipses replace distant pages), so the bar keeps the same width from one page to the next. ## Usage ### Basic usage From the total number of items (`total`) and the page size (`pageSize`, 10 by default), or directly with `pageCount`. ```vue ``` ### First and last page ```vue ``` ### Siblings and boundaries `siblings` sets the number of pages on each side of the current page, `boundaries` the number of pages always shown at the start and end. ```vue ``` ### Sizes ```vue ``` ## API ### Props | Prop | Type | Default | Description | |------|------|---------|-------------| | `modelValue` | `number` | `1` | Current page, from 1 to n (v-model) | | `total` | `number` | - | Total number of items | | `pageSize` | `number` | `10` | Items per page | | `pageCount` | `number` | - | Number of pages, takes precedence over `total` / `pageSize` | | `siblings` | `number` | `1` | Pages on each side of the current page | | `boundaries` | `number` | `1` | Pages always shown at the start and end | | `showEdges` | `boolean` | `false` | First / last page buttons | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Size | | `disabled` | `boolean` | `false` | Disables the pagination | | `ariaLabel` | `string` | `'Pagination'` (locale) | Navigation name | | `previousLabel` / `nextLabel` | `string` | `'Previous page'` / `'Next page'` (locale) | Previous / next button names | | `firstLabel` / `lastLabel` | `string` | `'First page'` / `'Last page'` (locale) | Edge button names | | `pageLabel` | `(page: number) => string` | `'Page {page}'` | Page button name | ### Events | Event | Payload | Description | |-------|---------|-------------| | `update:modelValue` | `number` | New page (v-model) | | `change` | `number` | Page changed by the user | The page computation is exported on its own, for a custom pagination: `import { getPaginationItems } from '@surgeui/vue'`, then `getPaginationItems({ page, count, siblings, boundaries })` returns the numbers and ellipses (`'ellipsis-start'`, `'ellipsis-end'`). ## Accessibility - `` containing a list; the current page has `aria-current="page"`. - Each page button is named "Page 3": the name contains the visible number (WCAG 2.5.3). - On the first or last page, previous and next stay focusable with `aria-disabled="true"`, so focus is not lost when the button becomes inactive. - Ellipses are hidden from screen readers. - In RTL, the chevrons are mirrored. --- # Stepper Progress through a multi-step flow (checkout, sign-up, setup wizard). ## Usage ### Horizontal With `clickable`, completed steps become buttons to go back. ```vue ``` ### Vertical with content The `content` slot shows under the current step. ```vue Content of the “{{ step.label }}” step. Continue ``` ### Step with an error ```vue ``` ## API ### Props | Prop | Type | Default | Description | |------|------|---------|-------------| | `modelValue` | `number` | `0` | Current step, from 0 (v-model) | | `steps` | `StepItem[]` | `[]` | Steps | | `orientation` | `'horizontal' \| 'vertical'` | `'horizontal'` | Orientation | | `clickable` | `boolean` | `false` | Completed steps are clickable | | `linear` | `boolean` | `true` | `false`: with `clickable`, upcoming steps are clickable too | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Size | | `ariaLabel` | `string` | `'Steps'` (locale) | List name | ### StepItem | Property | Type | Description | |----------|------|-------------| | `label` | `string` | Label | | `description` | `string` | Secondary text | | `error` | `boolean` | Step that needs attention | | `disabled` | `boolean` | Step that cannot be clicked | | `icon` | `Component` | Icon instead of the number | ### Events | Event | Payload | Description | |-------|---------|-------------| | `update:modelValue` | `number` | New step (v-model) | | `change` | `number` | Step picked with a click | ### Slots | Slot | Props | Description | |------|-------|-------------| | `content` | `{ step, index }` | Content under the current step (vertical) | ## Accessibility - Named ordered list ("Steps"): the position ("2 of 4") comes from the list. - The current step has `aria-current="step"`. - The status is read after the label: "Cart, completed", "Shipping, needs attention". - Clickable steps are real buttons; the others are not focusable. - On mobile (horizontal), only the current step label stays visible; the others are still read. --- # CommandPalette Search and run commands with the keyboard, opened with `Ctrl` + `K` (`⌘` + `K` on Mac): navigation, actions, preferences. ## Usage ### Basic usage ```vue ``` The demo on this page disables the shortcut (`:hotkey="false"`) so it does not interfere with the documentation search. ## API ### Props | Prop | Type | Default | Description | |------|------|---------|-------------| | `open` | `boolean` | `false` | Open state (`v-model:open`) | | `commands` | `CommandItem[]` | `[]` | Commands | | `placeholder` | `string` | `'Search for a command…'` (locale) | Field placeholder | | `hotkey` | `string \| false` | `'k'` | Shortcut key with `Ctrl` / `⌘`; `false`: none | | `emptyText` | `string` | `'No results'` (locale) | Text without results | | `ariaLabel` | `string` | `'Command palette'` (locale) | Dialog and list name | | `teleport` | `string \| HTMLElement \| boolean` | `'body'` | Where to render the ``; `false` to keep it in place. See [SuDialog](https://surgeui.com/en/components/dialog.md#rendering-in-body) | ### CommandItem | Property | Type | Description | |----------|------|-------------| | `id` | `string` | Identifier | | `label` | `string` | Label | | `group` | `string` | Display group | | `description` | `string` | Secondary text (also searched) | | `icon` | `Component` | Icon | | `shortcut` | `string[]` | Displayed shortcut (`SuKbd`) | | `keywords` | `string[]` | Extra search terms | | `disabled` | `boolean` | Unavailable command | | `onSelect` | `() => void` | Action, called after closing | | `to` | `string \| RouteLocationRaw` | Page opened on selection (`router.push`, otherwise a page load) | ### Events | Event | Payload | Description | |-------|---------|-------------| | `update:open` | `boolean` | Opened or closed | | `select` | `CommandItem` | Command run | ## Accessibility - Native modal `SuDialog` named "Command palette"; focus goes to the search field and returns to the trigger when closing. - `role="combobox"` field linked to a `role="listbox"` list whose groups (`role="group"`) are named. - Focus stays in the field: `↑` / `↓` browse results (`aria-activedescendant`, unavailable commands skipped), `Enter` runs, `Escape` closes. - Accent- and case-insensitive search; results ranked (label start, label, then description and keywords). The number of results is announced. --- # NavMenu Side navigation of an application: titled groups, icons, counters, one level of expandable sub-items, active item from the route, icons-only collapsed mode. Put it in the sidebar of [AppShell](https://surgeui.com/en/components/appshell.md). ## Usage ### Basic usage ```vue ``` ### Active item The active item has `aria-current="page"`. It comes, in this order: 1. from the item's `active` property; 2. from `v-model`, compared with the items' `value` (navigation handled by the application); 3. from the current Vue Router (or Nuxt) route, compared with the items' `to`. `match="prefix"` keeps an item active on every page of its section: `/projects` stays active on `/projects/42`. The parent of the active item opens by itself. ```vue ``` ### Collapsed to icons ```vue ``` Labels are still read by screen readers and show in a tooltip on hover and focus. An item without an icon shows its initial. A parent expands the menu (`update:collapsed`) and opens. ## API ### Props | Prop | Type | Default | Description | |------|------|---------|-------------| | `items` | `NavMenuEntry[]` | - | Items and groups | | `v-model` | `string \| number` | - | Active item (`value`) | | `v-model:collapsed` | `boolean` | `false` | Icons only | | `match` | `'exact' \| 'prefix'` | `'exact'` | Comparison with the current route | | `label` | `string` | `'Main navigation'` | Navigation name | ### NavMenuItem | Property | Type | Description | |----------|------|-------------| | `label` | `string` | Label | | `value` | `string \| number` | Identifier (`v-model`) | | `to` | `string \| RouteLocationRaw` | Router link (RouterLink or the plugin `linkComponent`) | | `href` | `string` | Link | | `target`, `rel` | `string` | Link target and relationship | | `icon` | `Component` | Icon | | `badge` | `string \| number` | Counter or short label | | `badgeVariant` | `BadgeVariant` | Counter variant | | `badgeLabel` | `string` | Text read instead of the counter ("4 unread messages") | | `active` | `boolean` | Forces the active state | | `disabled` | `boolean` | Disabled: no link, no selection | | `items` | `NavMenuItem[]` | Sub-items: the item becomes a button that expands them | | `defaultOpen` | `boolean` | Sub-items expanded on first render | A group is written `{ type: 'group', label, items }`. Without a link (`to`, `href`), an item is a button: navigation then goes through `v-model` or the `select` event. ### Events | Event | Payload | Description | |-------|---------|-------------| | `select` | `(item: NavMenuItem, event: MouseEvent)` | Chosen item | | `update:modelValue` | `string \| number` | Active item | | `update:collapsed` | `boolean` | A parent was chosen in collapsed mode | ## Accessibility - "Disclosure navigation" pattern: a named `` landmark with lists of links. No `role="menu"`: these are navigation links, not actions. - Each group is a list named by its title (`aria-labelledby`). - A parent is an `aria-expanded` button tied to its sub-list (`aria-controls`); Enter or Space expands it, Tab moves through the links. - `badgeLabel` replaces the counter for screen readers: "4 unread messages" rather than "4". - Collapsed mode: the label stays in the link (visually hidden); the tooltip is visual only and does not repeat the name. --- # ThemeToggle Switches between light and dark modes, or picks light, dark or system. The component drives [useTheme](https://surgeui.com/en/composables/usetheme.md): the state is shared by the whole application and saved in the browser when `persist` is on. ## Usage ### Toggle button ```vue ``` The button is named "Dark mode" and reports its state with `aria-pressed`: pressed in dark mode. From system mode, it switches to the opposite of the applied mode. ### Light, dark or system ```vue ``` ### Sizes ```vue ``` ## API ### Props | Prop | Type | Default | Description | |------|------|---------|-------------| | `variant` | `'button' \| 'segmented'` | `'button'` | Toggle button, or three options | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Size | | `label` | `string` | `'Dark mode'` / `'Appearance'` | Name of the button, or of the group (`segmented` variant) | | `lightLabel` | `string` | `'Light'` | Light option | | `darkLabel` | `string` | `'Dark'` | Dark option | | `systemLabel` | `string` | `'System'` | System option (follows `prefers-color-scheme`) | ### Events | Event | Payload | Description | |-------|---------|-------------| | `change` | `ThemeMode` | Chosen mode: `'light'`, `'dark'` or `'system'` | ## Accessibility - `button` variant: toggle button named "Dark mode", state reported by `aria-pressed`; the icon (sun or moon) is decorative. - `segmented` variant: group named "Appearance" (`role="group"`) of three `aria-pressed` buttons with visible labels. - Server rendering: the saved preference is only read after mount, with no hydration mismatch. --- # SkipLink Skip link: the first element reached with the keyboard, it leads straight to the main content without going through the header and the navigation again (WCAG 2.4.1). It stays hidden until it gets keyboard focus. `SuAppShell` and `SuHolyGrailLayout` already include it: use `SuSkipLink` on its own in a custom layout. ## Usage ### Basic usage Click inside the frame, then press Tab: the link shows up at the top left of the window. ```vue … … … ``` The link moves focus to the target programmatically (adding `tabindex="-1"` when it is not focusable): it works even when the application router intercepts `#` anchors. ## API ### Props | Prop | Type | Default | Description | |------|------|---------|-------------| | `target` | `string` | `'main-content'` | `id` of the element reached | | `label` | `string` | `'Skip to main content'` | Link text | ### Slots | Slot | Description | |------|-------------| | `default` | Link text | ## Accessibility - Put the link first in the page, before the header. - Visually hidden (not `display: none`): it stays reachable with the keyboard and shows up on focus, above sticky bars. - The target gets focus: reading and tabbing resume at the start of the main content. --- # CopyButton Copies text to the clipboard. The label switches to "Copied" for a few seconds and the result is announced to screen readers. ## Usage ### Basic usage ```vue ``` ### Icon only ```vue ``` With `icon-only`, the label stays the button name: name it after what it copies ("Copy the key", "Copy the link"). ## API ### Props | Prop | Type | Default | Description | |------|------|---------|-------------| | `value` | `string` | - | Copied text | | `label` | `string` | `'Copy'` | Button name | | `copiedLabel` | `string` | `'Copied'` | Label shown after copying | | `iconOnly` | `boolean` | `false` | Icon only (the name is still read) | | `variant` | `'primary' \| 'secondary' \| 'outline' \| 'ghost'` | `'ghost'` | Button variant | | `size` | `'sm' \| 'md' \| 'lg'` | `'sm'` | Size | | `timeout` | `number` | `2000` | How long the "copied" state lasts (ms) | ### Events | Event | Payload | Description | |-------|---------|-------------| | `copy` | `string` | Successful copy | | `error` | `unknown` | Copy failed (permission denied, browser) | ## Accessibility - The button name does not change: a name change while focused is not read reliably. - The result is announced through a live region ([useAnnouncer](https://surgeui.com/en/composables/useannouncer.md)): "Copied to clipboard", or "Could not copy" (assertive). - The confirmation check mark is decorative; the visible label switches to "Copied". --- # Input Flexible input component with complete HTML type support, prefixes/suffixes, text alignment, RTL/LTR direction and accessibility according to W3C standards. ## Description `SuInput` is an enhanced input field component that extends the capabilities of the native HTML `` element. It offers advanced support for text/icon prefixes/suffixes, text alignment, and complete accessibility management. ## Usage examples ### Basic usage ```vue ``` ### with FormField ```vue ``` Find out more about how to use [SuFormField](https://surgeui.com/en/components/formfield.md). ### Input types ```vue ``` ### Prefixes and suffixes ```vue ``` ### Prefixes and suffixes with icons ```vue ``` ### Sizes ```vue ``` ### States and validation ```vue ``` ### Text alignment ```vue ``` ### RTL support (right-to-left) ```vue ``` ### Disabled and readonly states ```vue ``` ## API ### Props | Prop | Type | Default | Description | |------|------|---------|-------------| | `type` | `InputType` | `'text'` | HTML input type | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Input size | | `state` | `'default' \| 'error' \| 'success' \| 'warning'` | `'default'` | Input visual state | | `disabled` | `boolean` | `false` | Disable the input | | `readonly` | `boolean` | `false` | Read-only input | | `required` | `boolean` | `false` | Required field | | `placeholder` | `string` | `undefined` | Placeholder text | | `modelValue` | `string \| number` | `undefined` | v-model value | | `prefix` | `string` | `undefined` | Text prefix | | `suffix` | `string` | `undefined` | Text suffix | | `prefixIcon` | `Component` | `undefined` | Prefix icon (Heroicons component) | | `suffixIcon` | `Component` | `undefined` | Suffix icon (Heroicons component) | | `textAlign` | `'left' \| 'center' \| 'right'` | `'left'` | Text alignment | | `name` | `string` | - | Field name, for native form submission | | `prefixLabel` | `string` | - | Accessible name of the text prefix when it is clickable (`@prefix-click`) | | `prefixIconLabel` | `string` | - | Accessible name of the prefix icon when it is clickable (`@prefix-icon-click`) | | `suffixLabel` | `string` | - | Accessible name of the text suffix when it is clickable (`@suffix-click`) | | `suffixIconLabel` | `string` | - | Accessible name of the suffix icon when it is clickable (`@suffix-icon-click`) | | `autocomplete` | `string` | - | Native `autocomplete` attribute (`email`, `current-password`, `off`…) | | `min` | `string \| number` | - | Minimum value (`number`, `date`… types) | | `max` | `string \| number` | - | Maximum value (`number`, `date`… types) | | `step` | `string \| number` | - | Step between two values (`number`, `date`… types) | | `minLength` | `number` | - | Minimum number of characters (native validation) | | `maxLength` | `number` | - | Maximum number of characters | | `pattern` | `string` | - | Native validation regular expression | ### Accessibility attributes | Prop | Type | Default | Description | |------|------|---------|-------------| | `ariaLabel` | `string` | `undefined` | Accessible label for screen readers | | `ariaDescribedBy` | `string` | `undefined` | ID of description element | | `ariaInvalid` | `boolean` | `undefined` | Indicates if value is invalid | | `ariaRequired` | `boolean` | `undefined` | Indicates if field is required | ### HTML validation attributes | Prop | Type | Default | Description | |------|------|---------|-------------| | `autocomplete` | `string` | `undefined` | HTML autocomplete attribute | | `min` | `number \| string` | `undefined` | Minimum value (number, date types) | | `max` | `number \| string` | `undefined` | Maximum value (number, date types) | | `step` | `number \| string` | `undefined` | Step for numbers | | `minLength` | `number` | `undefined` | Minimum text length | | `maxLength` | `number` | `undefined` | Maximum text length | | `pattern` | `string` | `undefined` | Validation regular expression | ### Events | Event | Type | Description | |-------|------|-------------| | `@update:modelValue` | `(value: string \| number) => void` | Emitted when value changes (v-model) | | `@input` | `(event: Event) => void` | Emitted on input | | `@change` | `(event: Event) => void` | Emitted on change | | `@focus` | `(event: FocusEvent) => void` | Emitted on focus | | `@blur` | `(event: FocusEvent) => void` | Emitted on blur | | `@keydown` | `(event: KeyboardEvent) => void` | Emitted on key press | | `@keyup` | `(event: KeyboardEvent) => void` | Emitted on key release | ### Exposed methods | Method | Type | Description | |---------|------|-------------| | `focus()` | `() => void` | Focuses the input | | `select()` | `() => void` | Selects input text | | `blur()` | `() => void` | Removes focus from input | | `inputRef` | `Ref` | Reference to native input element | ## Accessibility The Input component follows WCAG 2.1 AA standards and W3C best practices: ### ✅ Accessibility features - **ARIA attributes**: Complete support for ARIA attributes (`aria-label`, `aria-describedby`, `aria-invalid`, etc.) - **Color contrast**: WCAG AA compliant contrast ratios (4.5:1 minimum) - **Visible focus**: Clear and contrasted focus indicator with outline - **Minimum sizes**: Respects minimum touch target sizes (44x44px minimum) - **RTL support**: Automatic handling of right-to-left languages - **Dark mode**: Adapted contrast in dark mode - **High contrast**: Support for `prefers-contrast: high` - **Reduced motion**: Respects `prefers-reduced-motion` - **Clear states**: Distinct visual states for error, success, warning ### 🎯 Best practices ```vue ``` ## Supported types The Input component supports all HTML5 input types: - `text` - Free text - `email` - Email address with validation - `password` - Masked password - `number` - Number with controls - `tel` - Phone number - `url` - URL with validation - `search` - Search field - `date` - Date picker - `time` - Time picker - `datetime-local` - Local date and time - `month` - Month picker - `week` - Week picker - `color` - Color picker - `file` - File selection ## Advanced usage examples ### Search input with icon ```vue ``` ### Price field with formatting ```vue ``` ### Input with real-time validation ```vue ``` ### International phone input ```vue ``` ### Input with suffix actions ```vue ``` ## Usage with SuFormField For a complete experience with label, message and validation, use `SuInput` with `SuFormField`: ```vue ``` ## Implementation notes - The component automatically handles text direction (LTR/RTL) based on context - Prefixes and suffixes are positioned responsively - Icons are automatically sized according to input size - Focus ring is always visible for keyboard accessibility - Validation states are communicated visually and via ARIA --- # Textarea Flexible **Textarea** component with character counter, automatic height adjustment and W3C accessibility standards compliance. ## Description `SuTextarea` is an enhanced text area component that extends the capabilities of a native `` element. It offers advanced features such as character counter, automatic height adjustment, and complete accessibility management. ## Usage examples ### Simple usage (without SuFormField) ```vue ``` ### With character counter ```vue ``` ### Automatic height adjustment ```vue ``` ### Sizes ```vue ``` ### States ```vue ``` ## Usage with SuFormField The `SuTextarea` component can be used with `SuFormField` to benefit from a complete form structure with label, message and state management. ### Basic usage with SuFormField ```vue ``` ### With slot props destructuring ```vue ``` ### Validation with states ```vue ``` ### With character counter and FormField ```vue ``` ### Auto-resize with FormField ```vue ``` ### Custom label and message ```vue {{ label }} * ⚠️ Content is too short Write your article (minimum 100 characters) ``` ### Character limit with feedback ```vue ``` ### Disabled or readonly field ```vue ``` ## API ### Props | Prop | Type | Default | Description | |------|------|---------|-------------| | `modelValue` | `string` | `undefined` | Textarea value (v-model) | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Textarea size | | `state` | `'default' \| 'error' \| 'success' \| 'warning'` | `'default'` | Visual state | | `disabled` | `boolean` | `false` | Disable the textarea | | `readonly` | `boolean` | `false` | Read-only textarea | | `required` | `boolean` | `false` | Required field | | `placeholder` | `string` | `undefined` | Placeholder text | | `rows` | `number` | `3` | Default number of rows | | `minRows` | `number` | `2` | Minimum rows (auto-resize) | | `maxRows` | `number` | `10` | Maximum rows (auto-resize) | | `maxLength` | `number` | `undefined` | Maximum character count | | `showCounter` | `boolean` | `false` | Display character counter | | `autoResize` | `boolean` | `false` | Automatic height adjustment | | `spellcheck` | `boolean` | `true` | Spell checking | | `wrap` | `'soft' \| 'hard' \| 'off'` | `'soft'` | Line wrap mode | ### Accessibility props (inherited from SuFormField) When used with `SuFormField`, the component automatically receives: | Prop | Type | Description | |------|------|-------------| | `id` | `string` | Unique field ID (fieldId) | | `aria-describedby` | `string` | Associated message ID (messageId) | | `state` | `string` | Validation state | | `disabled` | `boolean` | Disabled state | | `autocomplete` | `string` | - | Native `autocomplete` attribute (`email`, `current-password`, `off`…) | ### Additional accessibility attributes | Prop | Type | Default | Description | |------|------|---------|-------------| | `ariaLabel` | `string` | `undefined` | Accessible label | | `ariaInvalid` | `boolean` | `undefined` | Indicates if value is invalid | | `ariaRequired` | `boolean` | `undefined` | Indicates if field is required | | `autocomplete` | `string` | `undefined` | HTML autocomplete attribute | ### Events | Event | Type | Description | |-------|------|-------------| | `@update:modelValue` | `(value: string) => void` | Emitted when value changes (v-model) | | `@input` | `(event: Event) => void` | Emitted on input | | `@change` | `(event: Event) => void` | Emitted on change | | `@focus` | `(event: FocusEvent) => void` | Emitted on focus | | `@blur` | `(event: FocusEvent) => void` | Emitted on blur | | `@keydown` | `(event: KeyboardEvent) => void` | Emitted on key press | | `@keyup` | `(event: KeyboardEvent) => void` | Emitted on key release | ### Exposed methods | Method | Type | Description | |---------|------|-------------| | `focus()` | `() => void` | Focuses the textarea | | `select()` | `() => void` | Selects the text | | `blur()` | `() => void` | Removes focus | | `textareaRef` | `Ref` | Reference to native textarea element | ## Accessibility The Textarea component follows WCAG 2.1 AA standards and W3C best practices: ### ✅ Accessibility features - **ARIA attributes**: Complete support (`aria-label`, `aria-describedby`, `aria-invalid`, etc.) - **Accessible counter**: Voice announcements for character limits - **State messages**: Via aria-describedby (messageId) with `aria-live` - **Color contrast**: WCAG AA compliant ratios (4.5:1) - **Visible focus**: Clear focus indicator with outline - **Minimum sizes**: Touch target respected - **Dark mode**: Adapted contrast - **Reduced motion**: Respects `prefers-reduced-motion` ### 🎯 Usage best practices ```vue Comment Share your thoughts (minimum 10 characters) ``` ## Advanced features ### 🔄 Smart auto-resize The textarea automatically adjusts its height to content: - **Minimum height**: Defined by `minRows` - **Maximum height**: Defined by `maxRows` (scrolls beyond it) - **Native when possible**: CSS `field-sizing: content`, no JavaScript - **Fallback**: JS measurement based on the actual line height for older browsers ### 📊 Character counter The counter provides visual and vocal feedback: - **Dynamic display**: `chars_entered/max_limit` - **Visual states**: Normal, near limit, exceeded - **Voice announcements**: Messages for screen readers - **Adapted colors**: Green, orange, red depending on state ## Keyboard navigation | Key | Action | |--------|--------| | `Tab` | Navigate to/from textarea | | `Shift + Tab` | Reverse navigation | | `Ctrl/Cmd + A` | Select all text | | `Ctrl/Cmd + Z` | Undo | | `Ctrl/Cmd + Y` | Redo | ## Advanced usage examples ### Complete contact form ```vue Contact Us Send ``` ### Editor with statistics ```vue {{ stats.words }} words {{ stats.chars }} characters ~{{ stats.readTime }} min ``` ## SuTextareaField Component For even simpler usage, you can use the `SuTextareaField` component which automatically combines `SuFormField` and `SuTextarea`: ```vue ``` The `SuTextareaField` component accepts all props from both `SuFormField` and `SuTextarea` combined, offering a more concise syntax while retaining all features. See the [complete SuTextareaField documentation](./SuTextareaField.md) for more details. --- # NumberInput A numeric field: input in the language's format ("1,234.5" in English), − / + buttons, bounds, step and display format (currency, unit, percent). ## Usage ### Basic usage ```vue ``` ### Display format `formatOptions` takes `Intl.NumberFormat` options. The format applies when leaving the field; while typing, the number is shown without symbols. ```vue ``` ### Without buttons ```vue ``` ### With a label: NumberInputField `SuNumberInputField` adds the label, message and validation state (FormField pattern). A `SuNumberInput` placed in a `SuFormField` also links itself. ```vue ``` ## API ### Props | Prop | Type | Default | Description | |------|------|---------|-------------| | `modelValue` | `number \| null` | `null` | Value (v-model), `null` when the field is empty | | `min` / `max` | `number` | - | Bounds | | `step` | `number` | `1` | Arrow and button step | | `largeStep` | `number` | `10 × step` | Page Up / Page Down step | | `precision` | `number` | decimals of the step and format | Kept decimals | | `formatOptions` | `Intl.NumberFormatOptions` | - | Display format (currency, unit, percent…) | | `locale` | `string` | component locale | Format language | | `controls` | `boolean` | `true` | − / + buttons | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Size | | `state` | `'default' \| 'error' \| 'success' \| 'warning'` | `'default'` | Validation state | | `disabled` / `readonly` / `required` | `boolean` | `false` | Field states | | `name` / `placeholder` | `string` | - | Field attributes | | `incrementLabel` / `decrementLabel` | `string` | `'Increase'` / `'Decrease'` (locale) | Button names | ### Props (NumberInputField) `SuNumberInputField` takes the props above, plus the field props: | Prop | Type | Default | Description | |------|------|---------|-------------| | `label` | `string` | - | Field label | | `message` | `string` | - | Help or error message, linked through `aria-describedby` | | `requiredText` | `string` | - | Screen reader text of the "required" asterisk (translated otherwise) | | `fieldId` | `string` | - | Control id, linked to the label (generated otherwise) | ### Events | Event | Payload | Description | |-------|---------|-------------| | `update:modelValue` | `number \| null` | New (committed) value | | `change` | `number \| null` | Value changed by the user | | `focus` / `blur` | `FocusEvent` | Field focus | ### Exposed methods | Method | Description | |--------|-------------| | `focus()` | Focuses the field | | `increment()` / `decrement()` | Adds or removes one step | ## Accessibility - `role="spinbutton"` with `aria-valuenow`, `aria-valuemin`, `aria-valuemax` and `aria-valuetext` (formatted value, e.g. "€12.50"). - Keyboard: `↑` / `↓` ± step, `Page Up` / `Page Down` ± large step, `Home` / `End` = min / max, `Enter` commits. - Input is committed when leaving the field or with `Enter`: clamped and rounded; unreadable text restores the previous value. - The − / + buttons are out of the tab order (the keyboard is enough) but remain usable by screen readers; they are marked `aria-disabled` at the bounds. - On mobile, the numeric keyboard opens (`inputmode`) when values are positive. --- # Autocomplete A free-text field with suggestions: the input stays free, picking a suggestion replaces it. Suggestions can be filtered locally or come from a server. To pick from a closed list, use [SelectBox](https://surgeui.com/en/components/selectbox.md) (with `searchable`). ## Usage ### Basic usage The filter ignores accents and case: "ev" finds "Évreux". ```vue ``` ### Detailed suggestions A suggestion can have a value, a description, an icon, or be disabled. ```vue ``` ### Server suggestions With `:filter="false"`, options are shown as given; `loading` shows the searching state. ```vue ``` ## API ### Props | Prop | Type | Default | Description | |------|------|---------|-------------| | `modelValue` | `string` | `''` | Typed text (v-model) | | `options` | `(string \| AutocompleteOption)[]` | `[]` | Suggestions | | `filter` | `boolean \| (option, query) => boolean` | `true` | Local filter; `false` for pre-filtered suggestions | | `minChars` | `number` | `0` | Characters typed before the list opens | | `openOnFocus` | `boolean` | `false` | Opens the list on focus | | `loading` | `boolean` | `false` | Search in progress | | `clearable` | `boolean` | `false` | Button and `Escape` to clear | | `maxHeight` | `string` | `'16rem'` | Maximum list height | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Size | | `state` | `'default' \| 'error' \| 'success' \| 'warning'` | `'default'` | Validation state | | `disabled` / `readonly` / `required` | `boolean` | `false` | Field states | | `name` / `placeholder` | `string` | - | Field attributes | | `noResultsText` / `loadingText` / `clearLabel` | `string` | locale | Texts | ### AutocompleteOption | Property | Type | Description | |----------|------|-------------| | `label` | `string` | Text shown and inserted in the field | | `value` | `string \| number` | Associated value (received with `select`) | | `description` | `string` | Secondary text | | `icon` | `Component` | Icon | | `disabled` | `boolean` | Suggestion that cannot be picked | ### Events | Event | Payload | Description | |-------|---------|-------------| | `update:modelValue` | `string` | Text changed (typing or picking) | | `select` | `AutocompleteOption` | Suggestion picked | | `focus` / `blur` | `FocusEvent` | Field focus | ### Slots | Slot | Props | Description | |------|-------|-------------| | `option` | `{ option, query, active }` | Suggestion rendering | ## Accessibility - `role="combobox"` with `aria-autocomplete="list"`, `aria-expanded` and `aria-controls` pointing to the list (`role="listbox"`). - Focus stays in the field; the active suggestion is conveyed by `aria-activedescendant`. - Keyboard: `↓` / `↑` open and browse the list (disabled suggestions are skipped), `Alt + ↓` opens without activating, `Enter` picks, `Escape` closes then clears (`clearable`), `Tab` closes and keeps the text. - The number of suggestions is announced after a typing pause ("3 suggestions", "No suggestions"). - In a `SuFormField`, the field and the list are named by the label. --- # DatePicker A date field: type the date in the language's format ("mm/dd/yyyy" in US English) or pick it in a calendar. ## Usage ### In a FormField ```vue ``` ### Initial value and maximum date ```vue ``` ## API ### Props | Prop | Type | Default | Description | |------|------|---------|-------------| | `modelValue` | `Date \| null` | `null` | Date (v-model) | | `min` / `max` | `Date` | - | Accepted dates | | `isDateDisabled` | `(date: Date) => boolean` | - | Refused days | | `locale` | `string` | component locale | Format and calendar language | | `weekStartsOn` | `number` | from the language | First day of the week | | `placeholder` | `string` | expected format (`dd/mm/yyyy`, `mm/dd/yyyy`…) | Placeholder | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Size | | `state` | `'default' \| 'error' \| 'success' \| 'warning'` | `'default'` | Validation state | | `disabled` / `readonly` / `required` | `boolean` | `false` | Field states (`readonly` hides the calendar) | | `name` | `string` | - | Field name | | `openLabel` | `string` | `'Choose a date'` (locale) | Calendar button name | ### Events | Event | Payload | Description | |-------|---------|-------------| | `update:modelValue` | `Date \| null` | New (committed) date | | `change` | `Date \| null` | Date changed by the user | | `focus` / `blur` | `FocusEvent` | Field focus | ### Exposed methods | Method | Description | |--------|-------------| | `focus()` | Focuses the field | | `open()` / `close()` | Opens or closes the calendar | ## Accessibility - The text field stays the main path: the date is committed when leaving the field or with `Enter`. An unreadable, non-existent (02/31) or out-of-range date restores the previous value. - The button is named with the selected date ("Change date, November 5, 2026") and announces a dialog (`aria-haspopup="dialog"`, `aria-expanded`). - Calendar in a `role="dialog"`: focus on the active day when opening, `Tab` trapped, `Escape` or an outside press closes; picking a day closes and returns focus to the button. `Alt` + `↓` opens the calendar from the field. - The month and year in the calendar title open month and year selection (handy for a date of birth); `Escape` first goes back to the days, then closes the calendar. - Calendar keyboard: see [Calendar](https://surgeui.com/en/components/calendar.md). --- # Calendar A month grid to pick a day, usable on its own or inside a [DatePicker](https://surgeui.com/en/components/datepicker.md). The first day of the week and the names follow the language. ## Usage ### Basic usage ```vue ``` ### Bounds and excluded days `min` and `max` limit selection and navigation; `isDateDisabled` excludes days (weekends, holidays). ```vue ``` ### Picking the month or year The month and year in the title are buttons. The year opens a page of 12 years, scrolled with the title arrows; picking a year shows its months, and picking a month goes back to the days. Nothing is selected until a day is clicked, and `Escape` goes back to the month shown before. ```vue ``` ## API ### Props | Prop | Type | Default | Description | |------|------|---------|-------------| | `modelValue` | `Date \| null` | `null` | Selected day (v-model) | | `min` / `max` | `Date` | - | First and last selectable days | | `isDateDisabled` | `(date: Date) => boolean` | - | Days that cannot be picked | | `locale` | `string` | component locale | Language of month and day names | | `weekStartsOn` | `number` | from the language | First day of the week (0 = Sunday) | | `previousMonthLabel` / `nextMonthLabel` | `string` | `'Previous month'` / `'Next month'` (locale) | Month button names (days view) | ### Events | Event | Payload | Description | |-------|---------|-------------| | `update:modelValue` | `Date` | Selected day (v-model) | | `select` | `Date` | Day picked by the user | ### Exposed methods | Method | Description | |--------|-------------| | `focus()` | Focuses the active day | ## Accessibility - `role="grid"` named by the month; weekday headers read in full ("Monday"). - A single tab stop: the selected day, otherwise today. Each day is named with the full date ("Thursday, November 5, 2026"), with `aria-selected` and `aria-current="date"` for today. - Keyboard: arrows ±1 day / ±1 week (reversed in RTL), `Home` / `End` start / end of week, `Page Up` / `Page Down` ±1 month, `Shift` + `Page` ±1 year, `Enter` / `Space` to pick. - Excluded days stay focusable (`aria-disabled`) but cannot be picked. - The title buttons are named by their text and action ("November, choose month", "2026, choose year"); they open a grid (`role="grid"`) of the 12 months or of 12 years, named by the year or the period ("2016–2027"), and move focus into it. - In these grids: arrows ±1 cell / ±1 row (3 columns, reversed in RTL), `Home` / `End` start / end of row, `Page Up` / `Page Down` previous / next year or page of years, `Enter` / `Space` to pick, `Escape` to go back to the days. Months and years out of bounds are `aria-disabled`. - The previous / next buttons keep focus and announce the new period (month, year or page of years). --- # SuSelectBox Custom SelectBox component with multiple selection support, integrated search, option groups and complete accessibility according to W3C standards. ## Description `SuSelectBox` is an enhanced selection component that extends the capabilities of a native `` element. It offers advanced features such as search, multiple selection with tags, options with icons and descriptions, and complete keyboard accessibility. ## Usage examples ### Simple usage (without SuFormField) ```vue ``` ### Multiple selection ```vue ``` ### Integrated search ```vue ``` ### Sizes ```vue ``` ### States ```vue ``` ## Usage with SuFormField The `SuSelectBox` component can be used with `SuFormField` to benefit from a complete form structure with label, message and state management. ### Basic usage with SuFormField ```vue ``` ::: tip Accessible name The trigger is a `combobox` (not an ``), so `` does not name it. Link the label with `aria-labelledby="labelId"`, or use `SuSelectBoxField`, which does it for you. ::: ### With slot props destructuring ```vue ``` ### Validation with states ```vue ``` ### Multiple selection with FormField ```vue ``` ### Custom label and message ```vue {{ label }} * ⚠️ Please select a role Select the role that matches your function ``` ### Options with icons and descriptions ```vue ``` ### Grouped options ```vue ``` ### Disabled field ```vue ``` ## API ### Props | Prop | Type | Default | Description | |------|------|---------|-------------| | `options` | `SelectOption[]` | `[]` | List of available options | | `groups` | `SelectGroup[]` | `[]` | Options organized in groups | | `modelValue` | `string \| number \| (string \| number)[]` | `undefined` | Selected value (v-model) | | `multiple` | `boolean` | `false` | Multiple selection | | `searchable` | `boolean` | `false` | Integrated search | | `clearable` | `boolean` | `false` | Clear button | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | SelectBox size | | `state` | `'default' \| 'error' \| 'success' \| 'warning'` | `'default'` | Visual state | | `disabled` | `boolean` | `false` | Disable the SelectBox | | `readonly` | `boolean` | `false` | Read-only SelectBox | | `required` | `boolean` | `false` | Required field | | `placeholder` | `string` | `'Select...'` | Placeholder text | | `searchPlaceholder` | `string` | `'Search...'` | Search placeholder | | `noOptionsText` | `string` | `'No options available'` | No options text | | `noResultsText` | `string` | `'No results found'` | No results text | | `maxHeight` | `string` | `'200px'` | Max dropdown height | | `textAlign` | `'left' \| 'center' \| 'right'` | `'left'` | Text alignment | | `loading` | `boolean` | `false` | Loading state | | `closeOnSelect` | `boolean` | `true` | Close after selection | | `maxSelectedItems` | `number` | `undefined` | Multiple selection limit | ### Accessibility props (inherited from SuFormField) When used with `SuFormField`, the component automatically receives: | Prop | Type | Description | |------|------|-------------| | `id` | `string` | Unique field ID (fieldId) | | `aria-labelledby` | `string` | Label ID (labelId): names the combobox and the list | | `aria-describedby` | `string` | Associated message ID (messageId) | | `state` | `string` | Validation state | | `disabled` | `boolean` | Disabled state | ### Option types #### SelectOption ```typescript interface SelectOption { value: string | number label: string disabled?: boolean group?: string icon?: Component description?: string } ``` #### SelectGroup ```typescript interface SelectGroup { label: string options: SelectOption[] } ``` ### Events | Event | Type | Description | |-------|------|-------------| | `@update:modelValue` | `(value: string \| number \| (string \| number)[]) => void` | Emitted when value changes (v-model) | | `@change` | `(value: string \| number \| (string \| number)[]) => void` | Emitted on change | | `@open` | `() => void` | Emitted when dropdown opens | | `@close` | `() => void` | Emitted when dropdown closes | | `@search` | `(query: string) => void` | Emitted on search | | `@focus` | `(event: FocusEvent) => void` | Emitted on focus | | `@blur` | `(event: FocusEvent) => void` | Emitted on blur | ### Exposed methods | Method | Type | Description | |---------|------|-------------| | `focus()` | `() => void` | Focuses the SelectBox | | `open()` | `() => void` | Opens the dropdown | | `close()` | `() => void` | Closes the dropdown | | `clear()` | `() => void` | Clears the selection | | `selectRef` | `Ref` | Container reference | ## Accessibility The SelectBox component follows WCAG 2.1 AA standards and W3C best practices: ### ✅ Accessibility features - **Combobox + listbox pattern (WAI-ARIA)**: the trigger (`role="combobox"`, `aria-expanded`, `aria-controls`) drives a `role="listbox"` list (`aria-multiselectable` for multiple selection) whose options carry `aria-selected` and `aria-disabled` - **Focus stays put**: focus remains on the trigger (or the search field); the highlighted option is announced through `aria-activedescendant` and scrolled into view - **Named groups**: each option group is a `role="group"` linked to its title - **Typeahead**: typing a letter highlights the next option starting with it; with `searchable`, the letter opens the list and starts the search - **Voice announcements**: multiple selection, tag removal, limit reached - **Associated labels**: through `aria-labelledby` (SuFormField labelId, automatic with SuSelectBoxField) - **Positioning**: the list uses `position: fixed`, flips above when space runs out and is never clipped by an `overflow: hidden` parent - **State messages**: Via aria-describedby (messageId) - **Color contrast**: WCAG AA compliant ratios (4.5:1) - **Visible focus**: Clear and contrasted indicators - **RTL support**: Right-to-left languages - **Dark mode**: Adapted contrast - **Reduced motion**: Respects `prefers-reduced-motion` ### 🎯 Usage best practices ```vue Select your country of residence ``` ## Keyboard navigation | Key | Action | |--------|--------| | `Tab` | Navigate to/from SelectBox (closes the list) | | `Enter` / `Space` | Open the list, select the highlighted option | | `Arrow down` | Open the list or next option (disabled options are skipped) | | `Arrow up` | Open the list or previous option | | `Alt` + `Arrow up` | Select the highlighted option | | `Home` / `End` | First / last option (in the search field: moves the caret) | | `Escape` | Close the list without changing the value (focus returns to the trigger) | | `A-Z` | Typeahead: highlights the next option starting with these letters | | `Backspace` | Multiple selection: removes the last tag (trigger or empty search) | ## Advanced usage examples ### Complete form with validation ```vue Submit ``` ### Dynamic loading with search ```vue ``` ## SuSelectBoxField Component For even simpler usage, you can use the `SuSelectBoxField` component which automatically combines `SuFormField` and `SuSelectBox`: ```vue ``` The `SuSelectBoxField` component accepts all props from both `SuFormField` and `SuSelectBox` combined, offering a more concise syntax while retaining all features. See the complete [SelectBoxField](./SuSelectBoxField.md) documentation for more details. --- # RadioGroup RadioGroup component for single selection with two display styles: classic or cards. Complete accessibility support according to W3C standards. ## Description `SuRadioGroup` is an enhanced single-selection component that allows choosing one option among several. It offers different display styles (classic, inline cards, block cards), supports icons and descriptions, and complies with all accessibility standards. ## Usage examples ### Simple usage (without SuFormField) ```vue ``` ### Block card style ```vue ``` ### Inline cards ```vue ``` ### With icons ```vue ``` ### Sizes ```vue ``` ### States ```vue ``` ### Horizontal direction ```vue ``` ## Usage with SuFormField The `SuRadioGroup` component can be used with `SuFormField` to benefit from a complete form structure with label, message and state management. ### Basic usage with SuFormField ```vue ``` ### With slot props destructuring ```vue ``` ### Validation with states ```vue ``` ### Cards with FormField ```vue ``` ### Custom label and message ```vue {{ label }} * ⚠️ Please select a method Choose how you want to pay ``` ### With icons and descriptions ```vue ``` ### Scroll with limited height ```vue ``` ### With before and after slots ```vue 🎯 Choose the plan that best fits your needs. Compare all plans → ``` ### Disabled field ```vue ``` ## API ### Props | Prop | Type | Default | Description | |------|------|---------|-------------| | `options` | `RadioOption[]` | `[]` | List of radio options | | `modelValue` | `string \| number` | `undefined` | Selected value (v-model) | | `name` | `string` | `undefined` | Radio group name (auto-generated if not provided) | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Element size | | `state` | `'default' \| 'error' \| 'success' \| 'warning'` | `'default'` | Visual state | | `disabled` | `boolean` | `false` | Disable entire group | | `required` | `boolean` | `false` | Required field | | `displayType` | `'default' \| 'inline-card' \| 'block-card'` | `'default'` | Display type | | `direction` | `'horizontal' \| 'vertical'` | `'vertical'` | Group direction | | `maxHeight` | `string` | `null` | Maximum height with scroll | ### Accessibility props (inherited from SuFormField) When used with `SuFormField`, the component automatically receives: | Prop | Type | Description | |------|------|-------------| | `id` | `string` | Unique field ID (fieldId) | | `aria-describedby` | `string` | Associated message ID (messageId) | | `state` | `string` | Validation state | | `disabled` | `boolean` | Disabled state | ### Option types #### RadioOption ```typescript interface RadioOption { value: string | number label: string description?: string disabled?: boolean icon?: Component } ``` ### Events | Event | Type | Description | |-------|------|-------------| | `@update:modelValue` | `(value: string \| number) => void` | Emitted when value changes (v-model) | | `@change` | `(value: string \| number) => void` | Emitted on change | | `@focus` | `(event: FocusEvent) => void` | Emitted on focus | | `@blur` | `(event: FocusEvent) => void` | Emitted on blur | ### Slots | Slot | Description | |------|-------------| | `before` | Content displayed before options | | `after` | Content displayed after options | ## Accessibility The RadioGroup component follows WCAG 2.1 AA standards and W3C best practices: ### ✅ Accessibility features - **Fieldset and Legend**: Semantic structure with `` and `` - **ARIA attributes**: `role="radiogroup"`, `aria-required`, `aria-invalid` - **Keyboard navigation**: Arrow keys, Tab, Space - **Associated labels**: Each radio has a properly associated label - **State messages**: Via aria-describedby (messageId) with `aria-live` - **Visible focus**: Clear and contrasted indicators - **Color contrast**: WCAG AA compliant ratios (4.5:1) - **Logical grouping**: Options semantically grouped ### 🎯 Usage best practices ```vue Payment method ``` ## Keyboard navigation | Key | Action | |--------|--------| | `Tab` | Navigate to/from group | | `Arrows ↑/↓` | Navigate between options (vertical) | | `Arrows ←/→` | Navigate between options (horizontal) | | `Space` | Select focused option | ## Advanced usage examples ### Complete configuration form ```vue Settings Save ``` ### Plan selector with pricing ```vue Total: ${{ totalPrice }}/month ``` ## SuRadioGroupField Component For even simpler usage, you can use the `SuRadioGroupField` component which automatically combines `SuFormField` and `SuRadioGroup`: ```vue ``` The `SuRadioGroupField` component accepts all props from both `SuFormField` and `SuRadioGroup` combined, offering a more concise syntax while retaining all features. See the [complete SuRadioGroupField documentation](./SuRadioGroupField.md) for more details. --- # Checkbox A single checkbox built on a native ``. It supports a label, a description and a mixed state for "select all" checkboxes, and links itself to a parent `SuFormField`. For a list of options, use [CheckboxGroup](https://surgeui.com/en/components/checkbox-group.md). ## Usage ### Basic checkbox ```vue ``` ### With a description The description is linked to the checkbox with `aria-describedby`. ```vue ``` ### Mixed state (select all) `v-model:indeterminate` shows a dash and is announced as "partially checked". The first click clears it. ```vue ``` ### Cards ```vue ``` ### Sizes and states ```vue ``` ### In a FormField The checkbox takes the field's id, message, state and required flag. ```vue ``` ## API ### Props | Prop | Type | Default | Description | |------|------|---------|-------------| | `modelValue` | `boolean` | `false` | Checked state (v-model) | | `indeterminate` | `boolean` | `false` | Mixed state (`v-model:indeterminate`), cleared on first click | | `label` | `string` | - | Label (or default slot) | | `description` | `string` | - | Help text linked with `aria-describedby` (or `description` slot) | | `value` | `string \| number` | - | Value submitted with the form when checked | | `name` | `string` | - | Form field name | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Size | | `state` | `'default' \| 'error' \| 'success' \| 'warning'` | `'default'` | Validation state | | `displayType` | `'default' \| 'inline-card' \| 'block-card'` | `'default'` | Plain or card display | | `disabled` | `boolean` | `false` | Disables the checkbox | | `required` | `boolean` | `false` | Required checkbox | | `ariaLabel` | `string` | - | Accessible name of a checkbox without a label | ### Events | Event | Payload | Description | |-------|---------|-------------| | `update:modelValue` | `boolean` | New value (v-model) | | `update:indeterminate` | `boolean` | End of the mixed state | | `change` | `boolean` | Changed by the user | | `focus` / `blur` | `FocusEvent` | Checkbox focus | ### Slots | Slot | Description | |------|-------------| | `default` | Label | | `description` | Help text | ### Exposed methods | Method | Description | |--------|-------------| | `focus()` | Focuses the checkbox | ## Accessibility - Native input, visually hidden but focusable: `Tab` to focus, `Space` to toggle. - The mixed state uses the native `indeterminate` property, read as "partially checked" by screen readers. - The description is linked with `aria-describedby`, like the parent `SuFormField` message. - A checkbox without a visible label needs an `aria-label`. - `error` state: `aria-invalid="true"`. --- # CheckboxGroup CheckboxGroup component for multiple selection with two display styles: classic or cards. Complete accessibility support according to W3C standards. ## Description `CheckboxGroup` is an enhanced multiple-selection component that allows choosing several options simultaneously. It offers different display styles (classic, inline cards, block cards), supports icons and descriptions, selection limit, and complies with all accessibility standards. ## Usage examples ### Simple usage (without SuFormField) ```vue ``` ### Block card style ```vue ``` ### Inline cards ```vue ``` ### With icons ```vue ``` ### Selection limit ```vue ``` ### Sizes ```vue ``` ### States ```vue ``` ### Horizontal direction ```vue ``` ## Usage with SuFormField The `SuCheckboxGroup` component can be used with `SuFormField` to benefit from a complete form structure with label, message and state management. ### Basic usage with SuFormField ```vue ``` ### With slot props destructuring ```vue ``` ### Validation with states ```vue ``` ### Selection limit with FormField ```vue ``` ### Cards with FormField ```vue ``` ### Custom label and message ```vue {{ label }} * ⚠️ Please select at least one option Choose how you want to be notified ``` ### With icons and descriptions ```vue ``` ### Scroll with limited height ```vue ``` ### With before and after slots ```vue 💡 Select the features you want to enable. Select all Select none ``` ### Disabled field ```vue ``` ## API ### Props | Prop | Type | Default | Description | |------|------|---------|-------------| | `options` | `CheckboxOption[]` | `[]` | List of checkbox options | | `modelValue` | `(string \| number)[]` | `[]` | Selected values (v-model) | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Element size | | `state` | `'default' \| 'error' \| 'success' \| 'warning'` | `'default'` | Visual state | | `disabled` | `boolean` | `false` | Disable entire group | | `required` | `boolean` | `false` | At least one selection required | | `displayType` | `'default' \| 'inline-card' \| 'block-card'` | `'default'` | Display type | | `direction` | `'horizontal' \| 'vertical'` | `'vertical'` | Group direction | | `maxSelections` | `number` | `undefined` | Maximum number of selections | | `maxHeight` | `string` | `null` | Maximum height with scroll | ### Accessibility props (inherited from SuFormField) When used with `SuFormField`, the component automatically receives: | Prop | Type | Description | |------|------|-------------| | `id` | `string` | Unique field ID (fieldId) | | `aria-describedby` | `string` | Associated message ID (messageId) | | `state` | `string` | Validation state | | `disabled` | `boolean` | Disabled state | | `name` | `string` | - | Field name, for native form submission | ### Option types #### CheckboxOption ```typescript interface CheckboxOption { value: string | number label: string description?: string disabled?: boolean icon?: Component } ``` ### Events | Event | Type | Description | |-------|------|-------------| | `@update:modelValue` | `(value: (string \| number)[]) => void` | Emitted when value changes (v-model) | | `@change` | `(value: (string \| number)[]) => void` | Emitted on change | | `@focus` | `(event: FocusEvent) => void` | Emitted on focus | | `@blur` | `(event: FocusEvent) => void` | Emitted on blur | ### Slots | Slot | Description | |------|-------------| | `before` | Content displayed before options | | `after` | Content displayed after options | ## Accessibility The CheckboxGroup component follows WCAG 2.1 AA standards and W3C best practices: ### ✅ Accessibility features - **Fieldset and Legend**: Semantic structure with `` and `` - **ARIA attributes**: `role="group"`, `aria-required`, `aria-invalid` - **Keyboard navigation**: Tab and Space - **Associated labels**: Each checkbox has a properly associated label - **State messages**: Via aria-describedby (messageId) with `aria-live` - **Voice announcements**: Feedback on selections/deselections - **Visible focus**: Clear and contrasted indicators - **Color contrast**: WCAG AA compliant ratios (4.5:1) - **Logical grouping**: Options semantically grouped ### 🎯 Usage best practices ```vue Notifications ``` ## Keyboard navigation | Key | Action | |--------|--------| | `Tab` | Navigate between checkboxes | | `Shift + Tab` | Reverse navigation | | `Space` | Check/uncheck focused checkbox | ## Advanced usage examples ### Complete preferences form ```vue Preferences Save ``` ### Selection with limit and counter ```vue ``` ## SuCheckboxGroupField Component For even simpler usage, you can use the `SuCheckboxGroupField` component which automatically combines `SuFormField` and `SuCheckboxGroup`: ```vue ``` The `SuCheckboxGroupField` component accepts all props from both `SuFormField` and `SuCheckboxGroup` combined, offering a more concise syntax while retaining all features. See the [complete SuCheckboxGroupField documentation](./SuCheckboxGroupField.md) for more details. --- # Switch Switch (toggle) component for on/off actions. W3C compliant with complete accessibility support and intelligent label positioning. ## Description `Switch` is an enhanced toggle component that allows switching between two states (on/off). It offers different label positioning options (left, right, inside), supports custom icons, and complies with all accessibility standards. ## Usage examples ### Simple usage (without SuFormField) ```vue ``` ### With right label ```vue ``` ### With labels on both sides ```vue ``` ### With icons ```vue ``` ### Sizes ```vue ``` ### States ```vue ``` ### Basic usage ```vue ``` ### With validation ```vue ``` ### Settings panel ```vue Settings ``` ## API ### Props | Prop | Type | Default | Description | |------|------|---------|-------------| | `modelValue` | `boolean` | `false` | Switch state (v-model) | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Switch size | | `state` | `'default' \| 'error' \| 'success' \| 'warning'` | `'default'` | Visual state | | `disabled` | `boolean` | `false` | Disable the switch | | `readonly` | `boolean` | `false` | Read-only switch | | `required` | `boolean` | `false` | Required field | | `leftLabel` | `string` | `undefined` | Left label | | `rightLabel` | `string` | `undefined` | Right label | | `leftIcon` | `Component` | `undefined` | Icon shown in the thumb when the switch is off (none by default) | | `rightIcon` | `Component` | `undefined` | Icon shown in the thumb when the switch is on (none by default) | | `padded` | `boolean` | `true` | Gap between the thumb and the track edge. `false`: the thumb sits flush with the edge | ### Accessibility props (inherited from SuFormField) When used with `SuFormField`, automatically receives: | Prop | Type | Description | |------|------|-------------| | `id` | `string` | Unique field ID (fieldId) | | `aria-describedby` | `string` | Associated message ID (messageId) | | `state` | `string` | Validation state | | `disabled` | `boolean` | Disabled state | ### Events | Event | Type | Description | |-------|------|-------------| | `@update:modelValue` | `(value: boolean) => void` | Emitted on change (v-model) | | `@change` | `(value: boolean) => void` | Emitted on change | | `@focus` | `(event: FocusEvent) => void` | Emitted on focus | | `@blur` | `(event: FocusEvent) => void` | Emitted on blur | ## Label positioning Automatic positioning based on provided labels: - **No side labels**: Switch alone - **One label** (`leftLabel` OR `rightLabel`): Switch aligned next to label - **Two labels** (`leftLabel` AND `rightLabel`): Switch centered between labels ## Accessibility WCAG 2.1 AA compliant with W3C best practices: ### ✅ Accessibility features - **ARIA role**: `role="switch"` with `aria-checked` - **Keyboard navigation**: Space and Enter keys - **Associated labels**: Via aria-describedby (messageId) - **State messages**: With `aria-live` - **Color contrast**: WCAG AA ratios (4.5:1) - **Visible focus**: Clear outline indicator - **Minimum sizes**: 44px touch target minimum - **Reduced motion**: Respects `prefers-reduced-motion` ### 🎯 Best practices ```vue ``` ## Keyboard navigation | Key | Action | |-----|--------| | `Tab` | Navigate to/from switch | | `Space` | Toggle state | | `Enter` | Toggle state | ## Advanced examples ### Conditional validation ```vue Consents Continue ``` ## SuSwitchField Component For simpler usage, use `SuSwitchField` which combines `SuFormField` and `SuSwitch`: ```vue ``` See the [complete SuSwitchField documentation](./SuSwitchField.md) for more details. --- # Slider Slider component for selecting numeric values with automatic dual-range support, vertical/horizontal orientation, tooltips, custom marks, and full W3C accessibility compliance. ## Simple Usage The `SuSlider` component can be used standalone without the `SuFormField` wrapper. ### Basic Slider ```vue ``` ### Dual-range (Value Range) ```vue ``` ## Usage with SuFormField For better form structuring, use `SuSlider` with the `SuFormField` component. ### Slider with Label and Message ```vue ``` ### Dual-range with Validation ```vue ``` ### With Tooltips ```vue ``` ### Validation States ```vue ``` ## Usage with SuSliderField For simplicity, you can also use the `SuSliderField` component which combines `SuFormField` and `SuSlider` into a single component: ```vue ``` This approach is equivalent to: ```vue ``` ## API ### Props | Prop | Type | Default | Description | |------|------|---------|-------------| | `v-model` | `number \| [number, number]` | `min` | Slider value (single number or array for dual-range) | | `min` | `number` | `0` | Minimum value | | `max` | `number` | `100` | Maximum value | | `step` | `number` | `1` | Increment step | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Slider size | | `disabled` | `boolean` | `false` | Disable the slider | | `readonly` | `boolean` | `false` | Read-only slider | | `orientation` | `'horizontal' \| 'vertical'` | `'horizontal'` | Slider orientation | | `tooltip` | `'none' \| 'top' \| 'bottom'` | `'none'` | Tooltip position on hover | | `marks` | `number[]` | `[]` | Marks to display on slider | | `showValue` | `boolean` | `true` | Show current value | | `showTicks` | `boolean` | `false` | Show tick marks | | `showLabels` | `boolean` | `false` | Show min/max labels | | `formatValue` | `(value: number) => string` | `undefined` | Value formatting function | | `state` | `'default' \| 'success' \| 'warning' \| 'error'` | `'default'` | Validation state (message color) | | `required` | `boolean` | `false` | Required field (`aria-required`) | | `message` | `string` | - | Help or error message under the slider, linked through `aria-describedby` | ### Accessibility Attributes | Prop | Type | Default | Description | |------|------|---------|-------------| | `ariaLabel` | `string` | `undefined` | Accessible label | | `ariaDescribedBy` | `string` | `undefined` | Description element ID | | `ariaInvalid` | `boolean` | `undefined` | Indicates invalid value | | `ariaRequired` | `boolean` | `undefined` | Indicates required field | | `ariaValueText` | `string` | `undefined` | Textual value description | ### Events | Event | Type | Description | |-------|------|-------------| | `@update:modelValue` | `(value: number \| [number, number]) => void` | Emitted on value change (v-model) | | `@change` | `(value: number \| [number, number]) => void` | Emitted on change | | `@input` | `(value: number \| [number, number]) => void` | Emitted during sliding | | `@focus` | `(event: FocusEvent) => void` | Emitted on focus | | `@blur` | `(event: FocusEvent) => void` | Emitted on blur | | `@keydown` | `(event: KeyboardEvent) => void` | Emitted on key press | ### Slots | Slot | Description | |------|-------------| | `before` | Content displayed before the slider | | `after` | Content displayed after the slider | ### Exposed Methods | Method | Type | Description | |---------|------|-------------| | `focus()` | `() => void` | Focus the slider | | `sliderRef` | `Ref` | Container reference | | `thumb1Ref` | `Ref` | First thumb reference | | `thumb2Ref` | `Ref` | Second thumb reference (dual) | ## Keyboard Navigation | Key | Action | |-----|--------| | `Tab` | Navigate to/from slider | | `Arrows` | Adjust value by step | | `Page Up` | Increase by 10% of range | | `Page Down` | Decrease by 10% of range | | `Home` | Go to minimum value | | `End` | Go to maximum value | ## Advanced Features ### 🎯 Smart Dual-range In dual-range mode (array value), the component automatically handles: - **Thumb Collision**: Min/max values cannot cross - **Smart Selection**: Click on track selects the nearest thumb - **Keyboard Navigation**: Each thumb is independently focusable ### 💬 Interactive Tooltips Tooltips provide immediate visual feedback: - **Hover Display**: Smooth appearance on hover - **Focus Display**: Visible during keyboard navigation - **Drag Display**: Stays visible during sliding - **Custom Formatting**: Uses the `formatValue` function ### 📊 Custom Marks Marks allow highlighting important values: - **Precise Positioning**: Automatic position calculation - **Formatted Labels**: Display with `formatValue` function - **Automatic Filtering**: Only valid marks are displayed - **Adaptive Styling**: Adapts to orientation and direction ### 🎨 Flexible Formatting The `formatValue` function allows: - **Custom Units**: €, %, °C, km, etc. - **Complex Formatting**: Stars, progress bars, etc. - **Localization**: Adaptation to different languages ## Advanced Usage Examples ### Search Filters ```vue Search Filters ``` ### Audio/Video Controls ```vue Audio Controls 🔇 🔊 ``` ### Temperature Slider with Zones ```vue Temperature Control Zone: {{ temperatureZone.name }} ``` ### Brightness Control with Presets ```vue Screen Brightness {{ preset.icon }} {{ preset.label }} ``` ## Accessibility The Slider component follows WCAG 2.1 AA standards and W3C best practices: ### ✅ Accessibility Features - **ARIA Role**: `role="slider"` with `aria-valuemin`, `aria-valuemax`, `aria-valuenow` - **Keyboard Navigation**: Support for arrow keys, Page Up/Down, Home/End - **ARIA Orientation**: `aria-orientation` for screen readers - **Voice Announcements**: Messages for screen readers on changes - **Associated Labels**: Each slider properly associated via SuFormField - **State Messages**: Messages with `aria-live` for screen readers - **Color Contrast**: Ratios compliant with WCAG AA (4.5:1 minimum) - **Visible Focus**: Clear and contrasted focus indicators - **Minimum Sizes**: 44px thumbs minimum for touch accessibility - **Dark Mode**: Automatically adapted contrast - **High Contrast**: Support for `prefers-contrast: high` - **Reduced Motion**: Respect for `prefers-reduced-motion` ### 🎯 Best Practices ```vue ``` ## Migration Guide If you're migrating from `SuSliderField` to the separated components: ### Before (SuSliderField) ```vue ``` ### After (SuFormField + SuSlider) ```vue ``` ### Benefits of Separation - **Flexibility**: Use SuSlider standalone when no label is needed - **Consistency**: Same structure for all form fields - **Reusability**: SuFormField works with any input component - **Maintainability**: Easier to update individual components - **Customization**: More control over layout and styling ### When to Use Each Approach **Use `SuSlider` alone** when: - You don't need a label or help message - You're building a custom layout - The slider is part of a more complex UI **Use `SuFormField + SuSlider`** when: - You need labels and help messages - You want consistent form styling - You need validation states - You're building standard forms **Use `SuSliderField`** when: - You want the simplest API - You're doing quick prototyping - You don't need advanced customization --- # Password Password component that inherits from the Input component with complexity validation, strength progress bar and visibility toggle. Compliant with W3C accessibility standards with voice feedback for screen readers. ## Usage examples ### Basic Password ```vue ``` ### With icon and custom rules ```vue ``` ## API ### Props | Prop | Type | Default | Description | |------|------|---------|-------------| | `rules` | `PasswordRules` | `{ minLength: 8, minUppercase: 1, minLowercase: 1, minDigits: 1, minSpecialChars: 1 }` | Password validation rules | | `showProgress` | `boolean` | `false` | Show strength progress bar | | `showToggle` | `boolean` | `true` | Show visibility toggle button | | `name` | `string` | - | Field name, for native form submission | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Field size | | `required` | `boolean` | `false` | Required field | | `placeholder` | `string` | - | Placeholder text | | `max` | `string \| number` | - | Maximum value (`number`, `date`… types) | | `disabled` | `boolean` | `false` | Disabled field | | `min` | `string \| number` | - | Minimum value (`number`, `date`… types) | | `state` | `'default' \| 'success' \| 'warning' \| 'error'` | `'default'` | Validation state | | `prefix` | `string` | - | Text before the input | | `suffix` | `string` | - | Text after the input | | `autocomplete` | `string` | - | Native `autocomplete` attribute (`email`, `current-password`, `off`…) | | `readonly` | `boolean` | `false` | Read-only | | `prefixIcon` | `Component` | - | Icon before the input | | `prefixLabel` | `string` | - | Accessible name of the text prefix when it is clickable (`@prefix-click`) | | `prefixIconLabel` | `string` | - | Accessible name of the prefix icon when it is clickable (`@prefix-icon-click`) | | `suffixLabel` | `string` | - | Accessible name of the text suffix when it is clickable (`@suffix-click`) | | `suffixIconLabel` | `string` | - | Accessible name of the suffix icon when it is clickable (`@suffix-icon-click`) | | `textAlign` | `'default' \| 'left' \| 'right' \| 'center'` | - | Alignment of the typed text | | `step` | `string \| number` | - | Step between two values (`number`, `date`… types) | | `minLength` | `number` | - | Minimum number of characters (native validation) | | `maxLength` | `number` | - | Maximum number of characters | | `pattern` | `string` | - | Native validation regular expression | | `v-model` | `string` | `''` | Typed password | **Inherits all props from Input component**: `size`, `state`, `disabled`, `readonly`, `required`, `placeholder`, `label`, `message`, etc. ### Types #### PasswordRules ```typescript interface PasswordRules { minLength?: number // Minimum length minUppercase?: number // Minimum uppercase letters minLowercase?: number // Minimum lowercase letters minDigits?: number // Minimum digits minSpecialChars?: number // Minimum special characters } ``` #### PasswordValidation ```typescript interface PasswordValidation { isValid: boolean // All rules are satisfied score: number // Score from 0 to 100 satisfied: string[] // Satisfied rules unsatisfied: string[] // Unsatisfied rules details: { // Details for each rule length: { required: number; current: number; satisfied: boolean } uppercase: { required: number; current: number; satisfied: boolean } lowercase: { required: number; current: number; satisfied: boolean } digits: { required: number; current: number; satisfied: boolean } specialChars: { required: number; current: number; satisfied: boolean } } } ``` ### Props (PasswordField) `SuPasswordField` takes the props above, plus the field props: | Prop | Type | Default | Description | |------|------|---------|-------------| | `label` | `string` | - | Field label | | `message` | `string` | - | Help or error message, linked through `aria-describedby` | | `requiredText` | `string` | - | Screen reader text of the "required" asterisk (translated otherwise) | | `fieldId` | `string` | - | Control id, linked to the label (generated otherwise) | ### Events | Event | Type | Description | |-------|------|-------------| | `@validation` | `(validation: PasswordValidation) => void` | Emitted on every change with validation state | | `@toggle-visibility` | `(visible: boolean) => void` | Emitted when visibility is toggled | **Inherits all events from Input component**: `@input`, `@change`, `@focus`, `@blur`, `@keydown`, `@keyup` ### Slots | Slot | Props | Description | |------|-------|-------------| | `default` | `{ validation, isValid, score, satisfied, unsatisfied, details }` | Custom message based on validation | ## Automatic validation The component performs real-time password validation: ### 🔍 Validation criteria - **Length**: Total number of characters - **Uppercase**: Letters A-Z - **Lowercase**: Letters a-z - **Digits**: Numbers 0-9 - **Special characters**: All other characters (!@#$%^&*, etc.) ### 📊 Score calculation The score (0-100%) is calculated based on the percentage of satisfied rules: - **0-24%**: Weak (red) - **25-49%**: Fair (orange) - **50-74%**: Good (yellow) - **75-100%**: Strong (green) ### 🎯 Automatic state If no `state` is forced, the component automatically adapts its state: - **default**: No password or indeterminate score - **error**: Score < 25% - **warning**: Score 25-74% - **success**: Score ≥ 75% and all rules satisfied ## Visibility toggle ### 👁️ Features - **Adaptive icon**: Open/closed eye based on state - **Accessibility**: Voice label "Show/Hide password" - **Keyboard navigation**: Support for Enter and Space - **States**: Disabled if field is disabled/readonly ### 🔒 Security - **No easier copying**: Visible text is not more easily copyable - **Visual feedback**: User controls visibility - **Reversible**: Can be hidden again immediately ## Progress bar ### 📈 Visual display - **Adaptive color**: Red → Orange → Yellow → Green - **Smooth animation**: Smooth transition during changes - **Strength label**: "Weak", "Fair", "Good", "Strong" - **Responsive**: Adapts to container width ### ♿ Accessibility - **Progressbar role**: `role="progressbar"` with ARIA values - **Voice announcements**: Changes announced to screen readers - **Contrast**: WCAG AA compliant colors - **Reduced motion**: Respects `prefers-reduced-motion` ## Accessibility The Password component follows WCAG 2.1 AA standards: ### ✅ Accessibility features - **Input inheritance**: All accessibility features from Input component - **Accessible toggle**: Button with appropriate voice label - **Voice validation**: State change announcements for screen readers - **Progress bar**: Complete ARIA attributes (`aria-valuenow`, `aria-valuemin`, `aria-valuemax`) - **State messages**: Real-time voice feedback with `aria-live` - **Color contrast**: WCAG AA compliant ratios for all states - **Keyboard navigation**: Complete keyboard support for all interactions ### 🎯 Best practices ```vue Required criteria: At least {{ details.length.required }} characters At least {{ details.uppercase.required }} uppercase letter ``` ## Keyboard navigation | Key | Action | |-----|--------| | `Tab` | Navigate to/from field | | `Enter` / `Space` | Activate visibility toggle (on icon) | | `Ctrl/Cmd + A` | Select all text | ## Security best practices ### ✅ Recommendations - **Autocomplete**: Use `autocomplete="new-password"` for new passwords - **Server validation**: Always validate server-side as well - **Adapted rules**: Adjust rules based on context (personal vs enterprise) - **Positive feedback**: Encourage good passwords with positive messages - **No storage**: Never store passwords in plain text ### 🔒 Security - **No logging**: Component never logs passwords - **Local validation**: Validation happens client-side only - **No transmission**: Rules and validations remain local - **Memory cleanup**: Values are automatically cleaned up --- # OtpInput OTP (One-Time Password) input component for verification codes. Supports multiple visual variants, configurable grouping, flexible validation, and auto-submit. WCAG compliant with full keyboard and screen reader support. ## Usage ### Basic ```vue ``` ### Visual variants ```vue ``` ### Sizes ```vue ``` ### Grouping ```vue ``` ### Input types ```vue ``` ### Custom validation ```vue ``` ### Masked ```vue ``` ### Validation states ```vue ``` ### Auto-submit ```vue ``` ```vue ``` ### With FormField (OtpInputField) ```vue ``` ### 4 digits (SMS code) ```vue ``` ## API ### Props (OtpInput) | Prop | Type | Default | Description | |------|------|---------|-------------| | `modelValue` | `string` | `''` | OTP code value (v-model) | | `length` | `number` | `6` | Number of characters | | `variant` | `'boxes' \| 'underline' \| 'seamless'` | `'boxes'` | Visual variant | | `inputType` | `'numeric' \| 'alphanumeric' \| 'alphabetic'` | `'numeric'` | Accepted character type | | `pattern` | `string` | — | Custom regex pattern (overrides inputType) | | `validate` | `(char: string, index: number) => boolean` | — | Per-character validation function | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Size | | `state` | `State` | `'default'` | Validation state | | `disabled` | `boolean` | `false` | Disabled | | `readonly` | `boolean` | `false` | Read-only | | `required` | `boolean` | `false` | Required | | `masked` | `boolean` | `false` | Mask characters | | `grouping` | `number[]` | — | Grouping pattern (e.g., [3, 3]) | | `separator` | `string` | `'-'` | Separator character between groups | | `autoSubmit` | `boolean` | `false` | Emit `complete` when all fields are filled | | `placeholder` | `string` | `''` | Placeholder per field | | `autoFocus` | `boolean` | `false` | Auto-focus on mount | ### Props (OtpInputField) Inherits from `FormFieldProps` + `OtpInputProps`. Additional props: | Prop | Type | Default | Description | |------|------|---------|-------------| | `label` | `string` | — | Field label | | `message` | `string` | — | Help or error message | | `fieldId` | `string` | — | Custom ID | | `requiredText` | `string` | `'requis'` | Required indicator text | ### Events | Event | Payload | Description | |-------|---------|-------------| | `update:modelValue` | `string` | v-model update | | `complete` | `string` | All fields are filled (if `autoSubmit`) | | `change` | `string` | Value changed | | `focus` | `FocusEvent, number` | Focus on a field (with index) | | `blur` | `FocusEvent, number` | Blur from a field (with index) | ### Slots | Slot | Description | |------|-------------| | `separator` | Custom separator content between groups | ### Exposed methods | Method | Description | |--------|-------------| | `focus()` | Focus the first field | | `clear()` | Clear all fields and focus the first one | ## Accessibility - `role="group"` with descriptive `aria-label` on the container - Each field has an individual `aria-label` ("Character X of Y") - `aria-live="polite"` region to announce progress - Keyboard navigation: left/right arrows, Home, End, Backspace, Delete - `autocomplete="one-time-code"` for mobile auto-fill - `inputmode="numeric"` to show numeric keyboard on mobile - Paste support with automatic character distribution - Supports `prefers-contrast: high` and `prefers-reduced-motion: reduce` --- # Rating Star rating: keyboard and pointer input, or read-only display (decimal values allowed). ## Usage ### Input ```vue ``` With the keyboard: Tab enters the group, arrow keys change the rating. With `clearable`, choosing the current rating again resets it to zero. ### Read only ```vue ``` ### In a form ```vue ``` The stars are real radio buttons: with `name`, the rating is submitted with the form. ## API ### Props | Prop | Type | Default | Description | |------|------|---------|-------------| | `v-model` | `number` | `0` | Rating (0: none) | | `max` | `number` | `5` | Number of stars | | `readonly` | `boolean` | `false` | Read only (decimal values allowed) | | `clearable` | `boolean` | `false` | Choosing the rating again resets it to zero | | `name` | `string` | generated id | Radio button name | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Size | | `state` | `'default' \| 'success' \| 'warning' \| 'error'` | `'default'` | State (`error`: `aria-invalid`) | | `disabled` | `boolean` | `false` | Disabled | | `required` | `boolean` | `false` | Required | | `ariaLabel` | `string` | `'Rating'` | Group name outside `SuFormField` | ### Events | Event | Payload | Description | |-------|---------|-------------| | `update:modelValue` | `number` | Chosen rating | | `change` | `number` | Chosen rating | ## Accessibility - Input: group of native radio buttons (`role="radiogroup"`), each star named ("3 stars out of 5"); the rating is announced as a checked option. - Named by the `SuFormField` label (`aria-labelledby`), otherwise "Rating"; message tied with `aria-describedby`. - Read only: an image named "Rated 4.5 out of 5"; the stars are decorative. - The hover preview does not change the rating; it goes away when the pointer leaves the stars. --- # SuFormField Container component for form fields with label, help messages, validation states management and accessibility according to W3C standards. ## Description `SuFormField` is a wrapper component that provides a consistent structure for all form fields. It manages the label, help messages, validation states (error, success, warning) and ensures accessibility by properly associating labels and messages with fields through props exposed in the default slot. ## Usage examples ### Basic usage ```vue Default slot here ``` ### Automatic control linking SurgeUI controls (SuInput, SuTextarea, SuSelectBox, SuRadioGroup, SuCheckboxGroup, SuSwitch, SuSlider, SuFileUpload, SuOtpInput) placed in the slot link themselves to the field through [useFormField](https://surgeui.com/en/composables/useformfield.md): - the control **id** = the label target; - **aria-describedby** completed with the message; - **aria-labelledby** pointing to the label for controls a `` cannot target (SelectBox, checkbox/radio groups, Slider, OtpInput); clicking the label focuses them; - **state**, **size**, **required** and **disabled** inherited from the field; an explicit value on the control still wins. ```vue ``` For a custom control, use the [useFormField](https://surgeui.com/en/composables/useformfield.md) composable. ### Props exposed in default slot The default slot automatically exposes the following props to facilitate accessibility: ```vue ``` ### Validation states ```vue ``` ### Required field ```vue ``` ### Sizes ```vue ``` ### Customization with named slots ```vue {{ label }} * Enter your username (minimum 4 characters) ⚠️ Invalid email format ✓ Valid email Enter your email address ``` ### Disabled field ```vue ``` ### RTL support (right-to-left) ```vue ``` ## API ### Props | Prop | Type | Default | Description | |------|------|---------|-------------| | `label` | `string` | `undefined` | Form field label | | `message` | `string` | `undefined` | Help or validation message | | `state` | `'default' \| 'error' \| 'success' \| 'warning'` | `'default'` | Field visual state | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Field size | | `required` | `boolean` | `false` | Indicates if field is required | | `disabled` | `boolean` | `false` | Disables the field | | `fieldId` | `string` | - | Control id, linked to the label (generated otherwise) | | `requiredText` | `string` | - | Screen reader text of the "required" asterisk (translated otherwise) | ### Slots #### Default slot The default slot automatically receives the following props: | Prop | Type | Description | |------|------|-------------| | `fieldId` | `string` | Unique generated ID for the field | | `messageId` | `string` | Unique generated ID for the message | | `state` | `'default' \| 'error' \| 'success' \| 'warning'` | Current field state | | `disabled` | `boolean` | Indicates if field is disabled | ```vue ``` #### Label slot Allows complete customization of the label rendering. | Prop | Type | Description | |------|------|-------------| | `label` | `string` | Label text | | `required` | `boolean` | Indicates if field is required | | `fieldId` | `string` | Associated field ID (same value as `fieldId`) | ```vue {{ label }} * ``` #### Message slot Allows complete customization of the message rendering. | Prop | Type | Description | |------|------|-------------| | `message` | `string` | Message text | | `state` | `'default' \| 'error' \| 'success' \| 'warning'` | Current field state | | `messageId` | `string` | Message ID (for aria-describedby) | ```vue {{ message }} ``` ### Generated CSS classes The component automatically generates IDs and CSS classes to facilitate styling and accessibility: - `su-form-field` : Component root class - `su-form-field--{size}` : Size modifier (`sm`, `md`, `lg`) - `su-form-field--{state}` : State modifier (`default`, `error`, `success`, `warning`) - `su-form-field--required` : Applied when `required` is `true` - `su-form-field--disabled` : Applied when `disabled` is `true` - `su-form-field__label` : Label class - `su-form-field__message` : Message class - `su-form-field__content` : Content container class ## Accessibility The SuFormField component follows WCAG 2.1 AA standards and W3C best practices: ### ✅ Accessibility features - **Label/field association**: Label is automatically associated with field via `for`/`id` (provided via `fieldId`) - **Descriptive messages**: Messages are linked to field via `aria-describedby` (provided via `messageId`) - **Required field indicator**: Visual and semantic display with `aria-required` - **Validation states**: Clear state communication via colors, icons and ARIA - **RTL support**: Complete support for right-to-left languages - **Color contrast**: WCAG AA compliant ratios (4.5:1 minimum) - **Live messages**: State change announcements with `aria-live="polite"` - **Visible focus**: Clear focus indicator on label and field ### 🎯 Usage best practices ```vue {{ label }} * ``` ## Advanced usage examples ### Form validation with dynamic states ```vue ``` ### Complex form with multiple fields ```vue ``` ### Integration with different control types ```vue Select... United States United Kingdom Male Female Other ``` ## Design system integration The `SuFormField` component is designed to be used with all form controls in your design system: ```vue ``` --- # FormFieldGroup FormFieldGroup component for organizing and aligning form fields with controlled spacing. Supports propagation of the `size` prop to child fields and section management with `head` and `footer` slots. ## Usage examples ### Basic FormFieldGroup ```vue ``` ### Field spacing (gap) ```vue ``` ### Size propagation ```vue ``` ### Horizontal direction ```vue ``` ## API ### Props | Prop | Type | Default | Description | |------|------|---------|-------------| | `gap` | `'sm' \| 'md' \| 'lg' \| 'xl'` | `'md'` | Spacing between form fields | | `sectionGap` | `'sm' \| 'md' \| 'lg' \| 'xl'` | `'lg'` | Spacing between sections (head, content, footer) | | `size` | `'sm' \| 'md' \| 'lg'` | `undefined` | Forced size for all fields | | `direction` | `'horizontal' \| 'vertical'` | `'vertical'` | Display direction of fields | ### Accessibility attributes | Prop | Type | Default | Description | |------|------|---------|-------------| | `ariaLabel` | `string` | `undefined` | Accessible label for the group | | `ariaDescribedBy` | `string` | `undefined` | ID of the description element | | `role` | `string` | `undefined` | Custom ARIA role (e.g. 'form', 'group') | ### Slots | Slot | Description | |------|-------------| | `head` | Content displayed before fields (header) | | `default` | Form fields to display | | `footer` | Content displayed after fields (footer) | ## Prop behavior ### 🔄 Automatic propagation When `size` is defined on `FormFieldGroup`, it **overrides** the props of child fields automatically: ```vue ``` ### 🎯 Content validation The component automatically checks that only form field components are passed in the slot: - ✅ **Form field components**: `InputField`, `SelectBoxField`, `RadioGroupField`, `CheckboxGroupField`, `SwitchField`, `FileUploadField`, `TextareaField`, `SliderField` - ⚠️ **Other components**: Warning in console and element ignored - ✅ **Comments/text**: Silently ignored (normal Vue behavior) ## Spacing and structure ### 📏 Gap values (between fields) - `gap="sm"` : 0.75rem (12px) - `gap="md"` : 1rem (16px) - **default** - `gap="lg"` : 1.5rem (24px) - `gap="xl"` : 2rem (32px) ### 📐 SectionGap values (between head, content, footer) - `sectionGap="sm"` : 1rem (16px) - `sectionGap="md"` : 1.5rem (24px) - `sectionGap="lg"` : 2rem (32px) - **default** - `sectionGap="xl"` : 2.5rem (40px) ### 📱 Responsive In horizontal mode, the component automatically switches to vertical on mobile (≤768px) for better user experience. ## Direction ### 📐 Vertical vs Horizontal - **Vertical** (default): Fields stacked in column - **Horizontal**: Fields aligned in row with equal width ```vue ``` ## Accessibility The FormFieldGroup component follows WCAG 2.1 AA standards: ### ✅ Accessibility features - **ARIA roles**: Support for `form`, `group`, etc. roles - **Group labels**: `aria-label` to describe the form - **Keyboard navigation**: Preserves Tab navigation between fields - **Semantic structure**: Logical organization of sections - **Descriptions**: Support for `aria-describedby` for descriptions - **Responsive**: Automatic adaptation on mobile ### 🎯 Best practices ```vue Configure your notification preferences ``` ## Advanced usage examples ### Contact form ```vue Contact us Our team will respond as soon as possible ``` ## Slot content control The `FormFieldGroup` component automatically checks the content of its slot: ### ✅ Accepted elements - Design system form field components: `InputField`, `SelectBoxField`, `RadioGroupField`, `CheckboxGroupField`, `SwitchField`, `FileUploadField`, `TextareaField`, `SliderField` - Vue comments (ignored) - Empty text nodes (ignored) ### ⚠️ Rejected elements - Other components or HTML elements - Warning in development console - Element ignored in render ### 🔍 Validation example ```vue Non-field element ``` This approach ensures visual and functional consistency while informing developers of potential issues. --- # Layouts Layouts (the *templates* layer of Atomic Design) structure a page or a section: they place areas, exposed as **slots**, and draw nothing else. Colors, cards and typography belong to the components you put inside them. ## Choosing a layout | Page type | Use case | Component | |-----------|----------|-----------| | Single column | Articles, blogs, forms, mobile | [SingleColumnLayout](https://surgeui.com/en/components/singlecolumnlayout.md) | | Two column | Docs, dashboards, admin | [SidebarLayout](https://surgeui.com/en/components/sidebarlayout.md) | | Split screen | Image + pitch, A vs B | [SplitLayout](https://surgeui.com/en/components/splitlayout.md) | | Asymmetrical | Portfolios, bold campaigns | [SplitLayout](https://surgeui.com/en/components/splitlayout.md#asymmetrical) with `ratio="3:2"` or `"2:1"` | | Holy Grail | Apps: nav, content, extras | [HolyGrailLayout](https://surgeui.com/en/components/holygraillayout.md) | | Magazine | News sites ranking stories | [MagazineLayout](https://surgeui.com/en/components/magazinelayout.md) | | Grid | Product lists, galleries, dashboards | [GridLayout](https://surgeui.com/en/components/gridlayout.md) | | Masonry | Mixed-height media feeds | [MasonryLayout](https://surgeui.com/en/components/masonrylayout.md) | | Hero | Product launches, signups | [HeroLayout](https://surgeui.com/en/components/herolayout.md) | | Full screen | Stories, one idea per screen | [FullScreenLayout](https://surgeui.com/en/components/fullscreenlayout.md) | | Application | Sidebar, top bar, drawer on mobile | [AppShell](https://surgeui.com/en/components/appshell.md) | ### What about F and Z patterns? They are **reading patterns**, not structures: you build them with the layouts above. - **F-pattern** (pages people scan): a [SingleColumnLayout](https://surgeui.com/en/components/singlecolumnlayout.md) whose headings, subheadings and lists put key information at the start of lines. - **Z-pattern** (landing page with one CTA): a [HeroLayout](https://surgeui.com/en/components/herolayout.md), then [SplitLayout](https://surgeui.com/en/components/splitlayout.md#z-pattern) rows alternating `reverse` so the eye moves from side to side. ## Shared principles ### Mobile first Every layout starts stacked in a single column, then adds columns when there is room. Nothing is needed for mobile. ### Driven by container width Columns appear based on the width of **the layout itself** (*container queries*), not the screen. A layout placed in a narrow panel or a dashboard column stays stacked, even on a large screen. | Threshold | Container width | |-----------|-----------------| | `sm` | 640px | | `md` | 768px | | `lg` | 1024px | | `xl` | 1280px | Demos on these pages sit in a frame that simulates a 375px (Mobile), 768px (Tablet) or 1024px (Desktop) container. The frame is scaled down on screen to fit the page, without changing the width the layouts see. ### Reading order DOM order follows visual order: screen reader reading and keyboard navigation stay consistent. The one documented exception is SplitLayout's `reverse`, which only flips the column display. ### Gaps Every layout accepts `gap`: `none`, `sm` (8px), `md` (16px), `lg` (24px) or `xl` (32px). The value is also exposed in CSS as `--su-layout-gap`, reusable in your own grids. ### Nesting Layouts combine: a `SidebarLayout` inside a `HolyGrailLayout` content area, a `MasonryLayout` inside a `SplitLayout` pane… Each one adapts to the space it gets. ```vue … … Table of contents Article ``` --- # SingleColumnLayout A single centered column with a comfortable line length: articles, blogs, forms, mobile pages. On mobile the column spans the full width with side gutters; beyond that it centers and stops at its maximum width. ## Usage ### Article ```vue Article title Published on October 25 · 4 min read Article content… ``` ### Widths `prose` (default) limits lines to about 65 characters, the recommended reading length. Other widths suit forms (`narrow`), mixed content (`medium`, `wide`) or full width (`full`). ```vue ``` ## API ### Props | Prop | Type | Default | Description | |------|------|---------|-------------| | `width` | `'prose' \| 'narrow' \| 'medium' \| 'wide' \| 'full'` | `'prose'` | Maximum width: prose ≈ 65 characters, narrow 36rem, medium 48rem, wide 72rem, full unlimited | | `gap` | `'none' \| 'sm' \| 'md' \| 'lg' \| 'xl'` | `'lg'` | Gap between header, content and footer | | `padded` | `boolean` | `true` | Side gutters: 16px, then 24px from a 768px container | | `as` | `string` | `'div'` | Root element (`article`, `main`, `section`…) | ### Slots | Slot | Description | |------|-------------| | `header` | Title, lead, breadcrumb | | `default` | Main content | | `footer` | Author, sharing, article navigation | ## Responsive behavior | Container width | Rendering | |-----------------|-----------| | < 768px | Full width, 16px gutters | | ≥ 768px | 24px gutters, column centered once the container exceeds the maximum width | The maximum width excludes gutters: a `prose` column keeps its 65 characters of text. ## Accessibility - **Line length**: `prose` follows the readability guideline (WCAG 1.4.8, 80 characters at most). - **Semantics**: pick the root element with `as` (`article` for a post, `main` for the page's main content). The `header` and `footer` areas are plain containers: put your own `` or `