# Accordion ::docs-component-example{name="a-accordion"} :: ## Features ::docs-highlights --- features: - Full keyboard navigation. - Supports horizontal/vertical orientation. - Supports Right to Left direction. - Can expand one or multiple items. - Can be controlled or uncontrolled. --- :: ## Anatomy Import all parts and piece them together. ```vue ``` ## Pohon ::docs-akar-to-pohon --- to: https://akar.vinicunca.dev/docs/pohon/components/accordion --- :: ## API Reference ### Root Contains all the parts of an Accordion ::docs-component-meta{name="a-accordion-root"} :: ::docs-data-attributes-table --- data: - attribute: "[data-orientation]" values: - vertical - horizontal --- :: ### Item Contains all the parts of a collapsible section. ::docs-component-meta{name="a-accordion-item"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - open - closed - attribute: "[data-disabled]" values: Present when disabled - attribute: "[data-orientation]" values: - vertical - horizontal --- :: ### Header Wraps an `AAccordionTrigger`. Use the `asChild` prop to update it to the appropriate heading level for your page. ::docs-component-meta{name="a-accordion-header"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - open - closed - attribute: "[data-disabled]" values: Present when disabled - attribute: "[data-orientation]" values: - vertical - horizontal --- :: ### Trigger Toggles the collapsed state of its associated item. It should be nested inside of an `AAccordionHeader`. ::docs-component-meta{name="a-accordion-trigger"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - open - closed - attribute: "[data-disabled]" values: Present when disabled - attribute: "[data-orientation]" values: - vertical - horizontal --- :: ### Content Contains the collapsible content for an item. ::docs-component-meta{name="a-accordion-content"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - open - closed - attribute: "[data-disabled]" values: Present when disabled - attribute: "[data-orientation]" values: - vertical - horizontal --- :: ::docs-css-variables-table --- data: - cssVariable: --akar-accordion-content-width description: The width of the content when it opens/closes - cssVariable: --akar-accordion-content-height description: The height of the content when it opens/closes --- :: ## Examples ### Expanded by default Use the `defaultValue` prop to define the open item by default. ```vue {4} ``` ### Allow collapsing all items Use the `collapsible` prop to allow all items to close. ```vue {4} ``` ### Multiple items open at the same time Set the `type` prop to `multiple` to enable opening multiple items at once. ```vue {2} ``` ### Rotated icon when open You can add extra decorative elements, such as chevrons, and rotate it when the item is open. ```vue {16} // index.vue ``` ### Horizontal orientation Use the `orientation` prop to create a horizontal Accordion ```vue {2} ``` ### Animating content size Use the `--akar-accordion-content-width` and/or `--akar-accordion-content-height` CSS variables to animate the size of the content when it opens/closes: ```vue {11} // index.vue ``` ```css {17,23} /* styles.css */ .AAccordionContent { overflow: hidden; } .AAccordionContent[data-state='open'] { animation: accordion-down 300ms ease-out; } .AAccordionContent[data-state='closed'] { animation: accordion-up 300ms ease-out; } @keyframes accordion-down { from { height: 0; } to { height: var(--akar-accordion-content-height); } } @keyframes accordion-up { from { height: var(--akar-accordion-content-height); } to { height: 0; } } ``` #### UnoCSS Preset ::tip By installing the [Vinicunca Preset](https://vinicunca.dev/unocss-preset/pohon-ui){rel="nofollow"}, you gain immediate access to pre-defined animation keyframes. This means the utility classes `animate-accordion-up` and `animate-accordion-down` are available right out of the box, saving you the step of manually creating them. :: ### Render content even when closed By default hidden content will be removed, use `:unmountOnHide="false"` to keep the content always available. This will also allow browser to search the hidden text, and open the accordion. ```vue {2} ``` ## Accessibility Adheres to the [Accordion WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/accordion){rel="nofollow"}. ### Keyboard Interactions ::docs-keyboard-table --- data: - keys: - Space description: When focus is on an AAccordionTrigger of a collapsed section, expands the section. - keys: - Enter description: When focus is on an AAccordionTrigger of a collapsed section, expands the section. - keys: - Tab description: Moves focus to the next focusable element. - keys: - Shift + Tab description: Moves focus to the previous focusable element. - keys: - ArrowDown description: Moves focus to the next AAccordionTrigger when orientation is vertical. - keys: - ArrowUp description: Moves focus to the previous AAccordionTrigger when orientation is vertical. - keys: - ArrowRight description: Moves focus to the next AAccordionTrigger when orientation is horizontal. - keys: - ArrowLeft description: Moves focus to the previous AAccordionTrigger when orientation is horizontal. - keys: - Home description: When focus is on an AAccordionTrigger, moves focus to the start AAccordionTrigger. - keys: - End description: When focus is on an AAccordionTrigger, moves focus to the last AAccordionTrigger. name: keyboard-a-accordion --- :: # Alert Dialog ::docs-component-example{name="a-alert-dialog"} :: ## Features ::docs-highlights --- features: - Focus is automatically trapped. - Can be controlled or uncontrolled. - Manages screen reader announcements with Title and Description components. - Esc closes the component automatically. --- :: ## Anatomy Import all parts and piece them together. ```vue ``` ## API Reference ### Root Contains all the parts of an alert dialog. ::docs-component-meta{name="a-alert-dialog-root"} :: ### Trigger A button that opens the dialog. ::docs-component-meta{name="a-alert-dialog-trigger"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - open - closed --- :: ### Portal When used, portals your overlay and content parts into the `body`. ::docs-component-meta{name="a-alert-dialog-portal"} :: ### Overlay A layer that covers the inert portion of the view when the dialog is open. ::docs-component-meta{name="a-alert-dialog-overlay"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - open - closed --- :: ### Content Contains content to be rendered when the dialog is open. ::docs-component-meta{name="a-alert-dialog-content"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - open - closed --- :: ### Cancel A button that closes the dialog. This button should be distinguished visually from `AAlertDialogAction` buttons. ::docs-component-meta{name="a-alert-dialog-cancel"} :: ### Action A button that closes the dialog. These buttons should be distinguished visually from the `AAlertDialogCancel` button. ::docs-component-meta{name="a-alert-dialog-action"} :: ### Title An accessible name to be announced when the dialog is opened. Alternatively, you can provide `aria-label` or `aria-labelledby` to `AAlertDialogContent` and exclude this component. ::docs-component-meta{name="a-alert-dialog-title"} :: ### Description An accessible description to be announced when the dialog is opened. Alternatively, you can provide `aria-describedby` to `AAlertDialogContent` and exclude this component. ::docs-component-meta{name="a-alert-dialog-description"} :: ## Examples ### Close after asynchronous form submission Use the controlled props to programmatically close the Alert Dialog after an async operation has completed. ```vue {14-15,19,25-29} ``` :br ### Custom portal container Customise the element that your alert dialog portals into. ```vue {4,17} ``` ## Accessibility Adheres to the [Alert and Message Dialogs WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/alertdialog){rel="nofollow"}. ### Keyboard Interactions ::docs-keyboard-table --- data: - keys: - Space description: Opens/closes the dialog. - keys: - Enter description: Opens/closes the dialog. - keys: - Tab description: Moves focus to the next focusable element. - keys: - Shift + Tab description: Moves focus to the previous focusable element. - keys: - Esc description: Closes the dialog and moves focus to `AAlertDialogTrigger`. name: keyboard-a-alert-dialog --- :: # Avatar ::docs-component-example{name="a-avatar"} :: ## Features ::docs-highlights --- features: - Automatic and manual control over when the image renders. - Fallback part accepts any children. - Optionally delay fallback rendering to avoid content flashing. --- :: ## Anatomy Import all parts and piece them together. ```vue ``` ## Pohon ::docs-akar-to-pohon --- to: https://akar.vinicunca.dev/docs/pohon/components/avatar --- :: ## API Reference ### Root Contains all the parts of an avatar ::docs-component-meta{name="a-avatar-root"} :: ### Image The image to render. By default it will only render when it has loaded. You can use the `@loadingStatusChange` handler if you need more control. ::docs-component-meta{name="a-avatar-image"} :: ### Fallback An element that renders when the image hasn't loaded. This means whilst it's loading, or if there was an error. If you notice a flash during loading, you can provide a `delayMs` prop to delay its rendering so it only renders for those with slower connections. For more control, use the `@loadingStatusChange` emit on `AAvatarImage`. ::docs-component-meta{name="a-avatar-fallback"} :: ## Examples ### Clickable Avatar with tooltip You can compose the Avatar with a [Tooltip](https://akar.vinicunca.dev/docs/akar/components/tooltip) to display extra information. ```vue {6-7,9,11-15} ``` # Calendar ::docs-component-example{name="a-calendar"} :: ## Features ::docs-highlights --- features: - Automatic and manual control over when the image renders. - Fallback part accepts any children. - Optionally delay fallback rendering to avoid content flashing. - Full keyboard navigation - Can be controlled or uncontrolled - Focus is fully managed - Localization support - Highly composable --- :: ## Preface The component depends on the [@internationalized/date](https://react-spectrum.adobe.com/internationalized/date/index.html){rel="nofollow"} package, which solves a lot of the problems that come with working with dates and times in JavaScript. We highly recommend reading through the documentation for the package to get a solid feel for how it works, and you'll need to install it in your project to use the date-related components. ## Anatomy Import all parts and piece them together. ```vue ``` ## Pohon ::docs-akar-to-pohon --- to: https://akar.vinicunca.dev/docs/pohon/components/calendar --- :: ## API Reference ### Root Contains all the parts of a calendar ::docs-component-meta{name="a-calendar-root"} :: ::docs-data-attributes-table --- data: - attribute: "[data-readonly]" values: Present when readonly - attribute: "[data-disabled]" values: Present when disabled - attribute: "[data-invalid]" values: Present when invalid --- :: ### Header Contains the navigation buttons and the heading segments. ::docs-component-meta{name="a-calendar-header"} :: ### Prev Button Calendar navigation button. It navigates the calendar one month/year/decade in the past based on the current calendar view. ::docs-component-meta{name="a-calendar-prev"} :: ::docs-data-attributes-table --- data: - attribute: "[data-disabled]" values: Present when disabled --- :: ### Next Button Calendar navigation button. It navigates the calendar one month/year/decade in the future based on the current calendar view. ::docs-component-meta{name="a-calendar-next"} :: ::docs-data-attributes-table --- data: - attribute: "[data-disabled]" values: Present when disabled --- :: ### Heading Heading for displaying the current month and year ::docs-component-meta{name="a-calendar-heading"} :: ::docs-data-attributes-table --- data: - attribute: "[data-disabled]" values: Present when disabled --- :: ### Grid Container for wrapping the calendar grid. ::docs-component-meta{name="a-calendar-grid"} :: ::docs-data-attributes-table --- data: - attribute: "[data-readonly]" values: Present when readonly - attribute: "[data-disabled]" values: Present when disabled --- :: ### Grid Head Container for wrapping the grid head. ::docs-component-meta{name="a-calendar-grid-head"} :: ### Grid Body Container for wrapping the grid body. ::docs-component-meta{name="a-calendar-grid-body"} :: ### Grid Row Container for wrapping the grid row. ::docs-component-meta{name="a-calendar-grid-row"} :: ### Head Cell Container for wrapping the head cell. Used for displaying the week days. ::docs-component-meta{name="a-calendar-head-cell"} :: ### Cell Container for wrapping the calendar cells. ::docs-component-meta{name="a-calendar-cell"} :: ::docs-data-attributes-table --- data: - attribute: "[data-disabled]" values: Present when disabled --- :: ### Cell Trigger Interactable container for displaying the cell dates. Clicking it selects the date. ::docs-component-meta{name="a-calendar-cell-trigger"} :: ::docs-data-attributes-table --- data: - attribute: "[data-selected]" values: Present when selected - attribute: "[data-value]" values: The ISO string value of the date. - attribute: "[data-disabled]" values: Present when disabled - attribute: "[data-unavailable]" values: Present when unavailable - attribute: "[data-today]" values: Present when today - attribute: "[data-outside-view]" values: Present when the date is outside the current month it is displayed in. - attribute: "[data-outside-visible-view]" values: Present when the date is outside the months that are visible on the calendar. - attribute: "[data-focused]" values: Present when focused --- :: ## Examples ### Calendar with Year Incrementation This example showcases a calendar which allows incrementing the year. ::docs-component-example{name="a-calendar-year-increment"} :: ### Calendar with Locale and Calendar System Selection This example showcases some of the available locales and how the calendar systems are displayed. ::docs-component-example{name="a-calendar-select"} :: ### Calendar swipe gesture navigation This component demonstrates intuitive calendar navigation using touch-based swipe gestures, user-friendly way to browse through months. ::docs-component-example{name="a-calendar-swipe"} :: ### Calendar week numbers This example showcases usage of the CalendarWeek component used to display the number of the week. ::docs-component-example{name="a-calendar-weeks"} :: ## Accessibility ### Keyboard Interactions ::docs-keyboard-table --- data: - keys: - Tab description: When focus moves onto the calendar, focuses the first navigation button. - keys: - Space description: When the focus is on either `CalendarNext` or `CalendarPrev`, it navigates the calendar. Otherwise, it selects the date. - keys: - Enter description: When the focus is on either `CalendarNext` or `CalendarPrev`, it navigates the calendar. Otherwise, it selects the date. - keys: - ArrowLeft - ArrowRight - ArrowUp - ArrowDown description: When the focus is on `CalendarCellTrigger`, it navigates the dates, changing the month/year/decade if necessary. name: keyboard-a-calendar --- :: # Checkbox ::docs-component-example{name="a-checkbox"} :: ## Features ::docs-highlights --- features: - Supports indeterminate state. - Full keyboard navigation. - Can be controlled or uncontrolled. --- :: ## Anatomy Import all parts and piece them together. ```vue ``` ## Pohon ::docs-akar-to-pohon --- to: https://akar.vinicunca.dev/docs/pohon/components/checkbox --- :: ## API Reference ### Root Contains all the parts of a checkbox. An `input` will also render when used within a `form` to ensure events propagate correctly. ::docs-component-meta{name="a-checkbox-root"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - checked - unchecked - indeterminate - attribute: "[data-disabled]" values: Present when disabled --- :: ### Indicator Renders when the checkbox is in a checked or indeterminate state. You can style this element directly, or you can use it as a wrapper to put an icon into, or both. ::docs-presence-tip :: ::docs-component-meta{name="a-checkbox-indicator"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - checked - unchecked - indeterminate - attribute: "[data-disabled]" values: Present when disabled --- :: ### Group Root Wrapper around `CheckboxRoot` to support array of `modelValue` ::docs-component-meta{name="a-checkbox-group-root"} :: ## Examples ### Indeterminate You can set the checkbox to `indeterminate` by taking control of its state. ```vue {5,9-14,16-18} ``` ## Accessibility Adheres to the [tri-state Checkbox WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/checkbox){rel="nofollow"}. ### Keyboard Interactions ::docs-keyboard-table --- data: - keys: - Space description: Checks/unchecks the checkbox name: keyboard-a-checkbox --- :: # Collapsible ::docs-component-example{name="a-collapsible"} :: ## Features ::docs-highlights --- features: - Full keyboard navigation. - Can be controlled or uncontrolled. --- :: ## Anatomy Import the components and piece the parts together. ```vue ``` ## Pohon ::docs-akar-to-pohon --- to: https://akar.vinicunca.dev/docs/pohon/components/collapsible --- :: ## API Reference ### Root Contains all the parts of a collapsible ::docs-component-meta{name="a-collapsible-root"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - open - closed - attribute: "[data-disabled]" values: Present when disabled --- :: ### Trigger The button that toggles the collapsible ::docs-component-meta{name="a-collapsible-trigger"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - open - closed - attribute: "[data-disabled]" values: Present when disabled --- :: ### Content The component that contains the collapsible content. ::docs-presence-tip :: ::docs-component-meta{name="a-collapsible-content"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - open - closed - attribute: "[data-disabled]" values: Present when disabled --- :: ::docs-css-variables-table --- data: - cssVariable: --akar-collapsible-content-width description: The width of the content when it opens/closes - cssVariable: --akar-collapsible-content-height description: The height of the content when it opens/closes --- :: ## Examples ### Animating content size Use the `--akar-collapsible-content-width` and/or `--akar-collapsible-content-height` CSS variables to animate the size of the content when it opens/closes. Here's a demo: ```vue {10} // index.vue ``` ```css {17,23} /* styles.css */ .ACollapsibleContent { overflow: hidden; } .ACollapsibleContent[data-state='open'] { animation: collapsible-down 300ms ease-out; } .ACollapsibleContent[data-state='closed'] { animation: collapsible-up 300ms ease-out; } @keyframes collapsible-down { from { height: 0; } to { height: var(--akar-collapsible-content-height); } } @keyframes collapsible-up { from { height: var(--akar-collapsible-content-height); } to { height: 0; } } ``` #### UnoCSS Preset ::tip By installing the [Vinicunca Preset](https://vinicunca.dev/unocss-preset/pohon-ui){rel="nofollow"}, you gain immediate access to pre-defined animation keyframes. This means the utility classes `animate-collapsible-up` and `animate-collapsible-down` are available right out of the box, saving you the step of manually creating them. :: ### Render content even when collapsed By default hidden content will be removed, use `:unmountOnHide="false"` to keep the content always available. This will also allow browser to search the hidden text, and open the collapsible. ```vue {6} ``` ## Accessibility Adheres to the [Disclosure WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/disclosure){rel="nofollow"}. ### Keyboard Interactions ::docs-keyboard-table --- data: - keys: - Space description: Opens/closes the collapsible - keys: - Enter description: Opens/closes the collapsible name: keyboard-a-collapsible --- :: # Combobox ::docs-component-example{name="a-combobox"} :: ## Features ::docs-highlights --- features: - Can be controlled or uncontrolled. - Offers 2 positioning modes. - Supports items, labels, groups of items. - Focus is fully managed. - Full keyboard navigation. - Supports custom placeholder. - Supports Right to Left direction. --- :: ## Anatomy Import all parts and piece them together. ```vue ``` ## Pohon ::docs-akar-to-pohon --- to: https://akar.vinicunca.dev/docs/pohon/components/input-menu --- :: ## API Reference ### Root Contains all the parts of a Combobox ::docs-component-meta{name="a-combobox-root"} :: ### Anchor Used as an anchor if you set `AComboboxContent`'s position to `popper`. ::docs-component-meta{name="a-combobox-anchor"} :: ### Input The input component to search through the combobox items. ::docs-component-meta{name="a-combobox-input"} :: ### Trigger The button that toggles the Combobox Content. ::docs-component-meta{name="a-combobox-trigger"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - open - closed - attribute: "[data-disabled]" values: Present when disabled --- :: ### Cancel The button that clears the search term. ::docs-component-meta{name="a-combobox-cancel"} :: ### Empty Shown when none of the items match the query. ::docs-component-meta{name="a-combobox-empty"} :: ### Portal When used, portals the content part into the `body`. You need to set `position="popper"` for `AComboboxContent` to make sure the position was automatically computed similar to `Popover` or `DropdownMenu`. ::docs-component-meta{name="a-combobox-portal"} :: ### Content The component that pops out when the combobox is open. ::docs-presence-tip :: ::docs-component-meta{name="a-combobox-content"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - open - closed - attribute: "[data-side]" values: - left - right - bottom - top - attribute: "[data-align]" values: - start - end - center --- :: ::docs-css-variables-table --- data: - cssVariable: --akar-combobox-content-transform-origin description: The `transform-origin` computed from the content and arrow positions/offsets. Only present when `position="popper"` - cssVariable: --akar-combobox-content-available-width description: The remaining width between the trigger and the boundary edge. Only present when `position="popper"` - cssVariable: --akar-combobox-content-available-height description: The remaining height between the trigger and the boundary edge. Only present when `position="popper"` - cssVariable: --akar-combobox-trigger-width description: The width of the trigger. Only present when `position="popper"` - cssVariable: --akar-combobox-trigger-height description: The height of the trigger. Only present when `position="popper"` --- :: ### Viewport The scrolling viewport that contains all of the items. ::docs-component-meta{name="a-combobox-viewport"} :: ### Item The component that contains the combobox items. ::docs-component-meta{name="a-combobox-item"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - checked - unchecked - attribute: "[data-highlighted]" values: Present when highlighted - attribute: "[data-disabled]" values: Present when disabled --- :: ### ItemIndicator Renders when the item is selected. You can style this element directly, or you can use it as a wrapper to put an icon into, or both. ::docs-component-meta{name="aa-combobo-item-indicator"} :: ### Group Used to group multiple items. use in conjunction with `AComboboxLabel` to ensure good accessibility via automatic labelling. ::docs-component-meta{name="a-combobox-group"} :: ### Label Used to render the label of a group. It won't be focusable using arrow keys. ::docs-component-meta{name="a-combobox-label"} :: ### Separator Used to visually separate items in the Combobox ::docs-component-meta{name="a-combobox-separator"} :: ### Arrow An optional arrow element to render alongside the content. This can be used to help visually link the trigger with the `AComboboxContent`. Must be rendered inside `AComboboxContent`. Only available when `position` is set to `popper`. ::docs-component-meta{name="a-combobox-arrow"} :: ### Virtualizer Virtual container to achieve list virtualization. ::warning Combobox items **must** be filtered manually before passing them over to the virtualizer. See [example below](https://akar.vinicunca.dev/#virtualized-combobox-with-working-filtering). :: See the [virtualization guide](https://akar.vinicunca.dev/../guides/virtualization) for more general info on virtualization. ::docs-component-meta{name="a-combobox-virtualizer"} :: ## Examples ### Binding objects as values Unlike native HTML form controls which only allow you to provide strings as values, `akar` supports binding complex objects as well. Make sure to set the `displayValue` prop to set the input value on item selection. ```vue {12,17,23} ``` ### Selecting multiple values The `Combobox` component allows you to select multiple values. You can enable this by providing an array of values instead of a single value. ```vue {12,17-18} ``` ### Custom filtering Internally, `AComboboxRoot` will filter the item based on the rendered text. However, you may also provide your own custom filtering logic together with setting `ignoreFilter="true"`. ```vue {15-16,22,28} ``` ### Custom label By default the `Combobox` will use the input contents as the label for screenreaders. If you'd like more control over what is announced to assistive technologies, use the [Label](https://akar.vinicunca.dev/docs/akar/components/label) component. ```vue {8,10} ``` ### With disabled items You can add special styles to disabled items via the `data-disabled` attribute. ```vue {19} ``` ```css {2} /* styles.css */ .AComboboxItem[data-disabled] { color: 'gainsboro'; } ``` ### With separators Use the `Separator` part to add a separator between items. ```vue {21} ``` ### With grouped items Use the `Group` and `Label` parts to group items in a section. ```vue {19-20,24} ``` ### With complex items You can use custom content in your items. ```vue {21} ``` ### Prevent select behavior By default, selecting `AComboboxItem` would close the content, and update the `modelValue` with the provided value. You can prevent this behavior by preventing default `@select.prevent`. ```vue {11} ``` ### Virtualized combobox with working filtering ACombobox items **must** be filtered manually before passing them over to the virtualizer. See the [virtualization guide](https://akar.vinicunca.dev/../guides/virtualization) for more general info on virtualization. ```vue {9-10,17,19-28} ``` ## Accessibility Adheres to the [ACombobox WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/Acombobox/){rel="nofollow"}. See the W3C [ACombobox Autocomplete List](https://www.w3.org/WAI/ARIA/apg/patterns/Acombobox/examples/Acombobox-autocomplete-list/){rel="nofollow"} example for more information. ### Keyboard Interactions ::docs-keyboard-table --- data: - keys: - Enter description: When focus is on `AComboboxItem`, selects the focused item. - keys: - ArrowDown description: " When focus is on `AComboboxInput`, opens the ACombobox content.
When focus is on an item, moves focus to the next item." - keys: - ArrowUp description: " When focus is on `AComboboxInput`, opens the ACombobox content.
When focus is on an item, moves focus to the previous item." - keys: - Esc description: " Closes ACombobox and restores the selected item in the `AComboboxInput` field." name: keyboard-a-combobox --- :: ## Custom APIs Create your own API by abstracting the primitive parts into your own component. ### Command Menu ACombobox can be use to build your own Command Menu. #### Usage ```vue ``` #### Implementation ```ts // your-command.ts export { default as Command } from 'Command.vue'; export { default as CommandItem } from 'CommandItem.vue'; ``` ```vue ``` ```vue ``` # Context Menu ::docs-component-example{name="a-context-menu"} :: ## Features ::docs-highlights --- features: - Supports submenus with configurable reading direction. - Supports items, labels, groups of items. - Supports checkable items (single or multiple) with optional indeterminate state. - Supports modal and non-modal modes. - Customize side, alignment, offsets, collision handling. - Focus is fully managed. - Full keyboard navigation. - Typeahead support. - Dismissing and layering behavior is highly customizable. - Triggers with a long-press on touch devices --- :: ## Anatomy Import all parts and piece them together. ```vue ``` ## Pohon ::docs-akar-to-pohon --- to: https://akar.vinicunca.dev/docs/pohon/components/context-menu --- :: ## API Reference Adheres to the [Menu WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/menu){rel="nofollow"} and uses [roving tabindex](https://www.w3.org/TR/wai-aria-practices-1.2/examples/menu-button/menu-button-actions.html){rel="nofollow"} to manage focus movement among menu items. ### Root Contains all the parts of a context menu. ::docs-component-meta{name="a-context-menu-root"} :: ### Trigger The area that opens the context menu. Wrap it around the target you want the context menu to open from when right-clicking (or using the relevant keyboard shortcuts). ::docs-component-meta{name="a-context-menu-trigger"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - open - closed --- :: ### Portal When used, portals the content part into the `body`. ::docs-component-meta{name="a-context-menu-portal"} :: ### Content The component that pops out in an open context menu. ::docs-component-meta{name="a-context-menu-content"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - open - closed - attribute: "[data-side]" values: - left - right - bottom - top - attribute: "[data-align]" values: - start - end - center --- :: ::docs-css-variables-table --- data: - cssVariable: --akar-context-menu-content-transform-origin description: The `transform-origin` computed from the content and arrow positions/offsets - cssVariable: --akar-context-menu-content-available-width description: The remaining width between the trigger and the boundary edge - cssVariable: --akar-context-menu-content-available-height description: The remaining height between the trigger and the boundary edge - cssVariable: --akar-context-menu-trigger-width description: The width of the trigger - cssVariable: --akar-context-menu-trigger-height description: The height of the trigger --- :: ### Arrow An optional arrow element to render alongside a submenu. This can be used to help visually link the trigger item with the `AContextMenu.Content`. Must be rendered inside `AContextMenu.Content`. ::docs-component-meta{name="a-context-menu-arrow"} :: ### Item The component that contains the context menu items. ::docs-component-meta{name="a-context-menu-item"} :: ::docs-data-attributes-table --- data: - attribute: "[data-highlighted]" values: Present when highlighted - attribute: "[data-disabled]" values: Present when disabled --- :: ### Group Used to group multiple `AContextMenu.Item`s. ::docs-component-meta{name="a-context-menu-group"} :: ### Label Used to render a label. It won't be focusable using arrow keys. ::docs-component-meta{name="a-context-menu-label"} :: ### CheckboxItem An item that can be controlled and rendered like a checkbox. ::docs-component-meta{name="a-context-menu-checkbox-item"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - checked - unchecked - indeterminate - attribute: "[data-highlighted]" values: Present when highlighted - attribute: "[data-disabled]" values: Present when disabled --- :: ### RadioGroup Used to group multiple `AContextMenu.RadioItem`s. ::docs-component-meta{name="a-context-menu-radio-group"} :: ### RadioItem An item that can be controlled and rendered like a radio. ::docs-component-meta{name="a-context-menu-radio-item"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - checked - unchecked - indeterminate - attribute: "[data-highlighted]" values: Present when highlighted - attribute: "[data-disabled]" values: Present when disabled --- :: ### ItemIndicator Renders when the parent `AContextMenu.CheckboxItem` or `AContextMenu.RadioItem` is checked. You can style this element directly, or you can use it as a wrapper to put an icon into, or both. ::docs-component-meta{name="a-context-menu-item-indicator"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - checked - unchecked - indeterminate --- :: ### Separator Used to visually separate items in the context menu. ::docs-component-meta{name="a-context-menu-separator"} :: ### Sub Contains all the parts of a submenu. ::docs-component-meta{name="a-context-menu-sub"} :: ### SubTrigger An item that opens a submenu. Must be rendered inside `AContextMenu.Sub`. ::docs-component-meta{name="a-context-menu-sub-trigger"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - open - closed - attribute: "[data-highlighted]" values: Present when highlighted - attribute: "[data-disabled]" values: Present when disabled --- :: ### SubContent The component that pops out when a submenu is open. Must be rendered inside `AContextMenu.Sub`. ::docs-component-meta{name="a-context-menu-sub-content"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - open - closed - attribute: "[data-side]" values: - left - right - bottom - top - attribute: "[data-align]" values: - start - end - center --- :: ::docs-css-variables-table --- data: - cssVariable: --akar-context-menu-content-transform-origin description: The `transform-origin` computed from the content and arrow positions/offsets - cssVariable: --akar-context-menu-content-available-width description: The remaining width between the trigger and the boundary edge - cssVariable: --akar-context-menu-content-available-height description: The remaining height between the trigger and the boundary edge - cssVariable: --akar-context-menu-trigger-width description: The width of the trigger - cssVariable: --akar-context-menu-trigger-height description: The height of the trigger --- :: ## Examples ### With submenus You can create submenus by using `AContextMenuSub` in combination with its parts. ```vue {24-33} ``` ### With disabled items You can add special styles to disabled items via the `data-disabled` attribute. ```vue {12} ``` ```css {2} /* styles.css */ .AContextMenuItem[data-disabled] { color: gainsboro; } ``` ### With separators Use the `Separator` part to add a separator between items. ```vue {7,18,20} ``` ### With labels Use the `Label` part to help label a section. ```vue {5,17} ``` ### With checkbox items Use the `CheckboxItem` part to add an item that can be checked. ```vue {3,25-30} ``` ### With radio items Use the `RadioGroup` and `RadioItem` parts to add an item that can be checked amongst others. ```vue {8-9,24-43} ``` ### With complex items You can add extra decorative elements in the `Item` parts, such as images. ```vue {11,15} ``` ### Constrain the content/sub-content size You may want to constrain the width of the content (or sub-content) so that it matches the trigger (or sub-trigger) width. You may also want to constrain its height to not exceed the viewport. We expose several CSS custom properties such as `--akar-context-menu-trigger-width` and `--akar-context-menu-content-available-height` to support this. Use them to constrain the content dimensions. ```vue {9} ``` ```css {3-4} /* styles.css */ .AContextMenuContent { width: var(--akar-context-menu-trigger-width); max-height: var(--akar-context-menu-content-available-height); } ``` ### Origin-aware animations We expose a CSS custom property `--akar-context-menu-content-transform-origin`. Use it to animate the content from its computed origin based on `side`, `sideOffset`, `align`, `alignOffset` and any collisions. ```vue {9} ``` ```css {3} /* styles.css */ .AContextMenuContent { transform-origin: var(--akar-context-menu-content-transform-origin); animation: scaleIn 0.5s ease-out; } @keyframes scaleIn { from { opacity: 0; transform: scale(0); } to { opacity: 1; transform: scale(1); } } ``` ### Collision-aware animations We expose `data-side` and `data-align` attributes. Their values will change at runtime to reflect collisions. Use them to create collision and direction-aware animations. ```vue {9} ``` ```css {6-11} /* styles.css */ .AContextMenuContent { animation-duration: 0.6s; animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1); } .AContextMenuContent[data-side='top'] { animation-name: slideUp; } .AContextMenuContent[data-side='bottom'] { animation-name: slideDown; } @keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } } @keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } } ``` ## Accessibility Uses [roving tabindex](https://www.w3.org/WAI/ARIA/apg/patterns/kbd_roving_tabindex){rel="nofollow"} to manage focus movement among menu items. ### Keyboard Interactions ::docs-keyboard-table --- data: - keys: - Space description: Activates the focused item. - keys: - Enter description: Activates the focused item. - keys: - ArrowDown description: Moves focus to the next item. - keys: - ArrowUp description: Moves focus to the previous item. - keys: - ArrowRight - ArrowLeft description: When focus is on `AContextMenu.SubTrigger`, opens or closes the submenu depending on reading direction. - keys: - Esc description: Closes the context menu name: keyboard-a-context-menu --- :: # Date Field ::docs-component-example{name="a-date-field"} :: ## Features ::docs-highlights --- features: - Full keyboard navigation. - Supports Right to Left direction. - Can be controlled or uncontrolled. - Focus is fully managed. - Localization support. - Highly composable. - Accessible by default. - Supports both date and date-time formats. --- :: ## Preface The component depends on the [@internationalized/date](https://react-spectrum.adobe.com/internationalized/date/index.html){rel="nofollow"} package, which solves a lot of the problems that come with working with dates and times in JavaScript. We highly recommend reading through the documentation for the package to get a solid feel for how it works, and you'll need to install it in your project to use the date-related components. ## Installation Install the date package. ::code-group{sync="pm"} ```bash [pnpm] pnpm add @internationalized/date ``` ```bash [npm] npm install @internationalized/date ``` ```bash [bun] bun add @internationalized/date ``` :: ## Anatomy Import all parts and piece them together. ```vue ``` ## Pohon ::docs-akar-to-pohon --- to: https://akar.vinicunca.dev/docs/pohon/components/input-date --- :: ## API Reference ### Root Contains all the parts of a date field ::docs-component-meta{name="a-date-field-root"} :: ::data-attributes-table --- data: - attribute: "[data-readonly]" values: Present when readonly - attribute: "[data-disabled]" values: Present when disabled - attribute: "[data-invalid]" values: Present when invalid --- :: ### Input Contains the date field segments ::docs-component-meta{name="a-date-field-input"} :: ::docs-data-attributes-table --- data: - attribute: "[data-disabled]" values: Present when disabled - attribute: "[data-invalid]" values: Present when invalid - attribute: "[data-placeholder]" values: Present when no value is set --- :: ## Accessibility ### Keyboard Interactions ::docs-keyboard-table --- data: - keys: - Tab description: When focus moves onto the date field, focuses the first segment. - keys: - ArrowLeft - ArrowRight description: Navigates between the date field segments. - keys: - ArrowUp - ArrowDown description: Increments/changes the value of the segment. - keys: - 0-9 description: When the focus is on a numeric `ADateFieldInput`, it types in number and focuses the next segment if the next input would result in an invalid value. - keys: - Backspace description: Deletes a digit from the focused numeric segments. - keys: - A - P description: When the focus is on the day period, it sets it to AM or PM. name: keyboard-a-date-field --- :: # Date Picker ::docs-component-example{name="a-date-picker"} :: ## Features ::docs-highlights --- features: - Full keyboard navigation. - Can be controlled or uncontrolled. - Focus is fully managed. - Localization support. - Accessible by default. - Supports both date and date-time formats. --- :: ## Preface The component depends on the [@internationalized/date](https://react-spectrum.adobe.com/internationalized/date/index.html){rel="nofollow"} package, which solves a lot of the problems that come with working with dates and times in JavaScript. We highly recommend reading through the documentation for the package to get a solid feel for how it works, and you'll need to install it in your project to use the date-related components. ## Installation Install the date package. ::code-group{sync="pm"} ```bash [pnpm] pnpm add @internationalized/date ``` ```bash [npm] npm install @internationalized/date ``` ```bash [bun] bun add @internationalized/date ``` :: ## Anatomy Import all parts and piece them together. ```vue ``` ## Pohon ::docs-akar-to-pohon --- to: https://akar.vinicunca.dev/docs/pohon/components/input-date#date-picker --- :: ## API Reference ### Root Contains all the parts of a date picker ::docs-component-meta{name="a-date-picker-root"} :: ### Field Contains the date picker date field segments and trigger ::docs-component-meta{name="a-date-picker-field"} :: ::docs-data-attributes-table --- data: - attribute: "[data-readonly]" values: Present when readonly - attribute: "[data-disabled]" values: Present when disabled - attribute: "[data-invalid]" values: Present when invalid --- :: ### Input Contains the date picker date field segments ::docs-component-meta{name="a-date-picker-input"} :: ::docs-data-attributes-table --- data: - attribute: "[data-disabled]" values: Present when disabled - attribute: "[data-invalid]" values: Present when invalid - attribute: "[data-placeholder]" values: Present when no value is set --- :: ### Trigger The button that toggles the popover. By default, the `ADatePickerContent` will position itself against the trigger. ::docs-component-meta{name="a-date-picker-trigger"} :: ### Content The component that pops out when the popover is open. ::docs-component-meta{name="a-date-picker-content"} :: ### Arrow An optional arrow element to render alongside the popover. This can be used to help visually link the anchor with the `ADatePickerContent`. Must be rendered inside `ADatePickerContent`. ::docs-component-meta{name="a-date-picker-arrow"} :: ### Close The button that closes an open date picker. ::docs-component-meta{name="a-date-picker-close"} :: ### Anchor An optional element to position the `ADatePickerContent` against. If this part is not used, the content will position alongside the `ADatePickerTrigger`. ::docs-component-meta{name="a-date-picker-anchor"} :: ### Calendar Contains all the parts of a calendar ::docs-component-meta{name="a-date-picker-calendar"} :: ::docs-data-attributes-table --- data: - attribute: "[data-disabled]" values: Present when disabled - attribute: "[data-readonly]" values: Present when readonly - attributes: "[data-invalid]" values: Present when invalid --- :: ### Header Contains the navigation buttons and the heading segments. ::docs-component-meta{name="a-date-picker-header"} :: ### Prev Button Calendar navigation button. It navigates the calendar one month/year/decade in the past based on the current calendar view. ::docs-component-meta{name="a-date-picker-prev"} :: ::docs-data-attributes-table --- data: - attribute: "[data-disabled]" values: Present when disabled --- :: ### Next Button Calendar navigation button. It navigates the calendar one month/year/decade in the future based on the current calendar view. ::docs-component-meta{name="a-date-picker-next"} :: ::docs-data-attributes-table --- data: - attribute: "[data-disabled]" values: Present when disabled --- :: ### Heading Heading for displaying the current month and year/ ::docs-component-meta{name="a-date-picker-heading"} :: ### Grid Container for wrapping the calendar grid. ::docs-component-meta{name="a-date-picker-grid"} :: ::docs-data-attributes-table --- data: - attribute: "[data-disabled]" values: Present when disabled - attribute: "[data-readonly]" values: Present when readonly --- :: ### Grid Head Container for wrapping the grid head. ::docs-component-meta{name="a-date-picker-grid-head"} :: ### Grid Body Container for wrapping the grid body. ::docs-component-meta{name="a-date-picker-grid-body"} :: ### Grid Row Container for wrapping the grid row. ::docs-component-meta{name="a-date-picker-grid-row"} :: ### Head Cell Container for wrapping the head cell. Used for displaying the week days. ::docs-component-meta{name="a-date-picker-head-cell"} :: ### Cell Container for wrapping the calendar cells. ::docs-component-meta{name="a-date-picker-cell"} :: ::docs-data-attributes-table --- data: - attribute: "[data-disabled]" values: Present when disabled --- :: ### Cell Trigger Interactable container for displaying the cell dates. Clicking it selects the date. ::docs-component-meta{name="a-date-picker-cell-trigger"} :: ::docs-data-attributes-table --- data: - attribute: "[data-selected]" values: Present when selected - attribute: "[data-value]" values: The ISO string value of the date. - attribute: "[data-disabled]" values: Present when disabled - attribute: "[data-unavailable]" values: Present when unavailable - attribute: "[data-today]" values: Present when today - attribute: "[data-outside-view]" values: Present when the date is outside the current month it is displayed in. - attribute: "[data-outside-visible-view]" values: Present when the date is outside the months that are visible on the calendar. - attribute: "[data-focused]" values: Present when focused --- :: ## Accessibility ### Keyboard Interactions ::docs-keyboard-table --- data: - keys: - Tab description: When focus moves onto the date field, focuses the first segment. - keys: - Space description: When the focus is on either `ADatePickerNext` or `ADatePickerPrev`, it navigates the calendar. Otherwise, it selects the date. If the focus is on `ADatePickerTrigger`, it opens/closes the popover. - keys: - Enter description: " When the focus is on either `ADatePickerNext` or `ADatePickerPrev`, it navigates the calendar. Otherwise it selects the date. If the focus is on `ADatePickerTrigger`, it opens/closes the popover." - keys: - ArrowLeft - ArrowRight description: Navigates between the date field segments. If the focus is on the `ADatePickerCalendar`, it navigates between dates. - keys: - ArrowUp - ArrowDown description: Increments/changes the value of the segment. If the focus is on the `ADatePickerCalendar`, it navigates between the dates. - keys: - 0-9 description: When the focus is on a numeric `ADatePickerInput`, it types in the number and focuses the next segment if the next input would result in an invalid value. - keys: - Backspace description: Deletes a digit from the focused numeric segments. - keys: - A - P description: When the focus is on the day period, it sets it to AM or PM. name: keyboard-a-date-picker --- :: # Date Range Field ::docs-component-example{name="a-date-range-field"} :: ## Features ::docs-highlights --- features: - Full keyboard navigation. - Can be controlled or uncontrolled. - Focus is fully managed. - Localization support. - Highly composable. - Accessible by default. - Supports both date and date-time formats. --- :: ## Preface The component depends on the [@internationalized/date](https://react-spectrum.adobe.com/internationalized/date/index.html){rel="nofollow"} package, which solves a lot of the problems that come with working with dates and times in JavaScript. We highly recommend reading through the documentation for the package to get a solid feel for how it works, and you'll need to install it in your project to use the date-related components. ## Installation Install the date package. ::code-group{sync="pm"} ```bash [pnpm] pnpm add @internationalized/date ``` ```bash [npm] npm install @internationalized/date ``` ```bash [bun] bun add @internationalized/date ``` :: ## Anatomy Import all parts and piece them together. ```vue ``` ## Pohon ::docs-akar-to-pohon --- to: https://akar.vinicunca.dev/docs/pohon/components/input-date#range --- :: ## API Reference ### Root Contains all the parts of a date field ::docs-component-meta{name="a-date-range-field-root"} :: ::data-attributes-table --- data: - attribute: "[data-readonly]" values: Present when readonly - attribute: "[data-disabled]" values: Present when disabled - attribute: "[data-invalid]" values: Present when invalid --- :: ### Input Contains the date field segments ::docs-component-meta{name="a-date-range-field-input"} :: ::docs-data-attributes-table --- data: - attribute: "[data-disabled]" values: Present when disabled - attribute: "[data-invalid]" values: Present when invalid - attribute: "[data-placeholder]" values: Present when no value is set --- :: ## Accessibility ### Keyboard Interactions ::docs-keyboard-table --- data: - keys: - Tab description: When focus moves onto the date field, focuses the first segment. - keys: - ArrowLeft - ArrowRight description: Navigates between the date field segments. - keys: - ArrowUp - ArrowDown description: Increments/changes the value of the segment. - keys: - 0-9 description: When the focus is on a numeric `ADateFieldInput`, it types in number and focuses the next segment if the next input would result in an invalid value. - keys: - Backspace description: Deletes a digit from the focused numeric segments. - keys: - A - P description: When the focus is on the day period, it sets it to AM or PM. name: keyboard-a-date-range-field --- :: # Date Range Picker ::docs-component-example{name="a-date-range-picker"} :: ## Features ::docs-highlights --- features: - Full keyboard navigation. - Can be controlled or uncontrolled. - Focus is fully managed. - Localization support. - Accessible by default. - Supports both date and date-time formats. --- :: ## Preface The component depends on the [@internationalized/date](https://react-spectrum.adobe.com/internationalized/date/index.html){rel="nofollow"} package, which solves a lot of the problems that come with working with dates and times in JavaScript. We highly recommend reading through the documentation for the package to get a solid feel for how it works, and you'll need to install it in your project to use the date-related components. ## Installation Install the date package. ::code-group{sync="pm"} ```bash [pnpm] pnpm add @internationalized/date ``` ```bash [npm] npm install @internationalized/date ``` ```bash [bun] bun add @internationalized/date ``` :: ## Anatomy Import all parts and piece them together. ```vue ``` ## Pohon ::docs-akar-to-pohon --- to: https://akar.vinicunca.dev/docs/pohon/components/input-date#range-picker --- :: ## API Reference ### Root Contains all the parts of a date picker ::docs-component-meta{name="a-date-range-picker-root"} :: ### Field Contains the date picker date field segments and trigger ::docs-component-meta{name="a-date-range-picker-field"} :: ::docs-data-attributes-table --- data: - attribute: "[data-readonly]" values: Present when readonly - attribute: "[data-disabled]" values: Present when disabled - attribute: "[data-invalid]" values: Present when invalid --- :: ### Input Contains the date picker date field segments ::docs-component-meta{name="a-date-range-picker-input"} :: ::docs-data-attributes-table --- data: - attribute: "[data-disabled]" values: Present when disabled - attribute: "[data-invalid]" values: Present when invalid - attribute: "[data-placeholder]" values: Present when no value is set --- :: ### Trigger The button that toggles the popover. By default, the `ADateRangePickerContent` will position itself against the trigger. ::docs-component-meta{name="a-date-range-picker-trigger"} :: ### Content The component that pops out when the popover is open. ::docs-component-meta{name="a-date-range-picker-content"} :: ### Arrow An optional arrow element to render alongside the popover. This can be used to help visually link the anchor with the `ADateRangePickerContent`. Must be rendered inside `ADateRangePickerContent`. ::docs-component-meta{name="a-date-range-picker-arrow"} :: ### Close The button that closes an open date picker. ::docs-component-meta{name="a-date-range-picker-close"} :: ### Anchor An optional element to position the `ADateRangePickerContent` against. If this part is not used, the content will position alongside the `ADateRangePickerTrigger`. ::docs-component-meta{name="a-date-range-picker-anchor"} :: ### Calendar Contains all the parts of a calendar ::docs-component-meta{name="a-date-range-picker-calendar"} :: ::docs-data-attributes-table --- data: - attribute: "[data-disabled]" values: Present when disabled - attribute: "[data-readonly]" values: Present when readonly - attributes: "[data-invalid]" values: Present when invalid --- :: ### Header Contains the navigation buttons and the heading segments. ::docs-component-meta{name="a-date-range-picker-header"} :: ### Prev Button Calendar navigation button. It navigates the calendar one month/year/decade in the past based on the current calendar view. ::docs-component-meta{name="a-date-range-picker-prev"} :: ::docs-data-attributes-table --- data: - attribute: "[data-disabled]" values: Present when disabled --- :: ### Next Button Calendar navigation button. It navigates the calendar one month/year/decade in the future based on the current calendar view. ::docs-component-meta{name="a-date-range-picker-next"} :: ::docs-data-attributes-table --- data: - attribute: "[data-disabled]" values: Present when disabled --- :: ### Heading Heading for displaying the current month and year ::docs-component-meta{name="a-date-range-picker-heading"} :: ::docs-data-attributes-table --- data: - attribute: "[data-disabled]" values: Present when disabled --- :: ### Grid Container for wrapping the calendar grid. ::docs-component-meta{name="a-date-range-picker-grid"} :: ::docs-data-attributes-table --- data: - attribute: "[data-disabled]" values: Present when disabled - attribute: "[data-readonly]" values: Present when readonly --- :: ### Grid Head Container for wrapping the grid head. ::docs-component-meta{name="a-date-range-picker-grid-head"} :: ### Grid Body Container for wrapping the grid body. ::docs-component-meta{name="a-date-range-picker-grid-body"} :: ### Grid Row Container for wrapping the grid row. ::docs-component-meta{name="a-date-range-picker-grid-row"} :: ### Head Cell Container for wrapping the head cell. Used for displaying the week days. ::docs-component-meta{name="a-date-range-picker-head-cell"} :: ### Cell Container for wrapping the calendar cells. ::docs-component-meta{name="a-date-range-picker-cell"} :: ::docs-data-attributes-table --- data: - attribute: "[data-disabled]" values: Present when disabled --- :: ### Cell Trigger Interactable container for displaying the cell dates. Clicking it selects the date. ::docs-component-meta{name="a-date-range-picker-cell-trigger"} :: ::docs-data-attributes-table --- data: - attribute: "[data-selected]" values: Present when selected - attribute: "[data-value]" values: The ISO string value of the date. - attribute: "[data-disabled]" values: Present when disabled - attribute: "[data-unavailable]" values: Present when unavailable - attribute: "[data-today]" values: Present when today - attribute: "[data-outside-view]" values: Present when the date is outside the current month it is displayed in. - attribute: "[data-outside-visible-view]" values: Present when the date is outside the months that are visible on the calendar. - attribute: "[data-focused]" values: Present when focused --- :: ## Accessibility ### Keyboard Interactions ::docs-keyboard-table --- data: - keys: - Tab description: When focus moves onto the date field, focuses the first segment. - keys: - Space description: When the focus is on either `ADatePickerNext` or `ADatePickerPrev`, it navigates the calendar. Otherwise, it selects the date. If the focus is on `ADatePickerTrigger`, it opens/closes the popover. - keys: - Enter description: When the focus is on either `ADatePickerNext` or `ADatePickerPrev`, it navigates the calendar. Otherwise it selects the date. If the focus is on `ADatePickerTrigger`, it opens/closes the popover. - keys: - ArrowLeft - ArrowRight description: Navigates between the date field segments. If the focus is on the `ADatePickerCalendar`, it navigates between dates. - keys: - ArrowUp - ArrowDown description: Increments/changes the value of the segment. If the focus is on the `ADatePickerCalendar`, it navigates between the dates. - keys: - 0-9 description: When the focus is on a numeric `ADatePickerInput`, it types in the number and focuses the next segment if the next input would result in an invalid value. - keys: - Backspace description: Deletes a digit from the focused numeric segments. - keys: - A - P description: When the focus is on the day period, it sets it to AM or PM. name: keyboard-a-date-picker --- :: # Dialog ::docs-component-example{name="a-dialog"} :: ## Features ::docs-highlights --- features: - Supports modal and non-modal modes. - Focus is automatically trapped when modal. - Can be controlled or uncontrolled. - Manages screen reader announcements with `` and `` components. - Esc closes the component automatically. --- :: ## Anatomy Import all parts and piece them together. ```vue ``` ## Pohon ::docs-akar-to-pohon --- to: https://akar.vinicunca.dev/docs/pohon/components/dialog --- :: ## API Reference ### Root Contains all the parts of a dialog ::docs-component-meta{name="a-dialog-root"} :: ### Trigger The button that opens the dialog ::docs-component-meta{name="a-dialog-trigger"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - open - closed --- :: ### Portal When used, portals your overlay and content parts into the `body`. ::docs-component-meta{name="a-dialog-portal"} :: ### Overlay A layer that covers the inert portion of the view when the dialog is open. ::docs-presence-tip :: ::docs-component-meta{name="a-dialog-overlay"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - open - closed --- :: ### Content Contains content to be rendered in the open dialog ::docs-presence-tip :: ::docs-component-meta{name="a-dialog-content"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - open - closed --- :: ### Close The button that closes the dialog ::docs-component-meta{name="a-dialog-close"} :: ### Title An accessible title to be announced when the dialog is opened. If you want to hide the title, wrap it inside our Visually Hidden utility like this ``. ::docs-component-meta{name="a-dialog-title"} :: ### Description An optional accessible description to be announced when the dialog is opened. If you want to hide the description, wrap it inside our Visually Hidden utility like this ``. If you want to remove the description entirely, remove this part and pass `:aria-describedby="undefined"` to `ADialogContent`. ::docs-component-meta{name="a-dialog-description"} :: ## Examples ### Nested dialog You can nest multiple layers of dialogs. ::docs-component-example{name="a-dialog-nested"} :: ### Close after asynchronous form submission Use the controlled props to programmatically close the ADialog after an async operation has completed. ```vue {4-5,15-19,22-24} ``` ### Scrollable overlay Move the content inside the overlay to render a dialog with overflow. ```vue // index.vue ``` ```css /* styles.css */ .ADialogOverlay { background: rgba(0 0 0 / 0.5); position: fixed; top: 0; left: 0; right: 0; bottom: 0; display: grid; place-items: center; overflow-y: auto; } .ADialogContent { min-width: 300px; background: white; padding: 30px; border-radius: 4px; } ``` However, there's a caveat to this approach, where user might click on the scrollbar and close the dialog unintentionally. There's no universal solution that would fix this issue for now, however you can add the following snippet to `ADialogContent` to prevent closing of modal when clicking on scrollbar. ```vue ``` ### Custom portal container Customise the element that your dialog portals into. ```vue {4,11,17} ``` ## Accessibility Adheres to the [ADialog WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/){rel="nofollow"}. ### Close icon button When providing an icon (or font icon), remember to label it correctly for screen reader users. ```vue {9-11} ``` ### Close using slot props Alternatively, you can use the `close` method provided by the `ADialogRoot` slot props to programmatically close the dialog. ```vue {4,8,16-20} ``` ### Keyboard Interactions ::docs-keyboard-table --- data: - keys: - Space description: Opens/closes the dialog - keys: - Enter description: Opens/closes the dialog - keys: - Tab description: Moves focus to the next focusable element. - keys: - Shift + Tab description: Moves focus to the previous focusable element. - keys: - Esc description: Closes the dialog and moves focus to `ADialogTrigger`. name: keyboard-a-dialog --- :: ## Custom APIs Create your own API by abstracting the primitive parts into your own component. ### Abstract the overlay and the close button This example abstracts the `ADialogOverlay` and `ADialogClose` parts. #### Usage ```vue ``` #### Implementation ```ts // your-dialog.ts export { default as ADialogContent } from 'ADialogContent.vue'; export { ADialogRoot as ADialog, ADialogTrigger } from 'akar'; ``` ```vue ``` # Drawer Work in Progress # Dropdown Menu ::docs-component-example{name="a-dropdown-menu"} :: ## Features ::docs-highlights --- features: - Can be controlled or uncontrolled. - Supports submenus with configurable reading direction. - Supports items, labels, groups of items. - Supports checkable items (single or multiple) with optional indeterminate state. - Supports modal and non-modal modes. - Customize side, alignment, offsets, collision handling. - Optionally render a pointing arrow. - Focus is fully managed. - Full keyboard navigation. - Typeahead support. - Dismissing and layering behavior is highly customizable. --- :: ## Anatomy Import all parts and piece them together. ```vue ``` ## Pohon ::docs-akar-to-pohon --- to: https://akar.vinicunca.dev/docs/pohon/components/dropdown-menu --- :: ## API Reference ### Root Contains all the parts of a dropdown menu. ::docs-component-meta{name="a-dropdown-menu-root"} :: ### Trigger The button that toggles the dropdown menu. By default, the `ADropdownMenuContent` will position itself against the trigger. ::docs-component-meta{name="a-dropdown-menu-trigger"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - open - closed - attribute: "[data-disabled]" values: Present when disabled --- ### Portal When used, portals the content part into the `body`. :::docs-component-meta{name="a-dropdown-menu-portal"} ::: ### Content The component that pops out when the dropdown menu is open. :::docs-component-meta{name="a-dropdown-menu-content"} ::: :::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - open - closed - attribute: "[data-side]" values: - left - right - bottom - top - attribute: "[data-align]" values: - start - end - center - attribute: "[data-orientation]" values: - vertical - horizontal --- ::: :::docs-css-variables-table --- data: - cssVariable: --akar-dropdown-menu-content-transform-origin description: The `transform-origin` computed from the content and arrow positions/offsets' - cssVariable: --akar-dropdown-menu-content-available-width description: The remaining width between the trigger and the boundary edge - cssVariable: --akar-dropdown-menu-content-available-height description: The remaining height between the trigger and the boundary edge - cssVariable: --akar-dropdown-menu-trigger-width description: The width of the trigger - cssVariable: --akar-dropdown-menu-trigger-height description: The height of the trigger --- ::: ### Arrow An optional arrow element to render alongside the dropdown menu. This can be used to help visually link the trigger with the `ADropdownMenuContent`. Must be rendered inside `ADropdownMenuContent`. :::docs-component-meta{name="a-dropdown-menu-arrow"} ::: ### Item The component that contains the dropdown menu items. :::docs-component-meta{name="a-dropdown-menu-item"} ::: :::docs-data-attributes-table --- data: - attribute: "[data-orientation]" values: - vertical - horizontal - attribute: "[data-highlighted]" values: Present when highlighted - attribute: "[data-disabled]" values: Present when disabled --- ::: ### Group Used to group multiple `ADropdownMenuItem`s. :::docs-component-meta{name="a-dropdown-menu-group"} ::: ### Label Used to render a label. It won't be focusable using arrow keys. :::docs-component-meta{name="a-dropdown-menu-label"} ::: ### CheckboxItem An item that can be controlled and rendered like a checkbox. :::docs-component-meta{name="a-dropdown-menu-checkbox-item"} ::: :::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - checked - unchecked - indeterminate - attribute: "[data-highlighted]" values: Present when highlighted - attribute: "[data-disabled]" values: Present when disabled --- ::: ### RadioGroup Used to group multiple `ADropdownMenuRadioItem`s. :::docs-component-meta{name="a-dropdown-menu-radio-group"} ::: ### RadioItem An item that can be controlled and rendered like a radio. :::docs-component-meta{name="a-dropdown-menu-radio-item"} ::: :::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - checked - unchecked - indeterminate - attribute: "[data-highlighted]" values: Present when highlighted - attribute: "[data-disabled]" values: Present when disabled --- ::: ### ItemIndicator Renders when the parent `ADropdownMenuCheckboxItem` or `ADropdownMenuRadioItem` is checked. You can style this element directly, or you can use it as a wrapper to put an icon into, or both. :::docs-component-meta{name="a-dropdown-menu-item-indicator"} ::: :::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - checked - unchecked - indeterminate --- ::: ### Separator Used to visually separate items in the dropdown menu. :::docs-component-meta{name="a-dropdown-menu-separator"} ::: ### Sub Contains all the parts of a submenu. :::docs-component-meta{name="a-dropdown-menu-sub"} ::: ### SubTrigger An item that opens a submenu. Must be rendered inside `ADropdownMenuSub`. :::docs-component-meta{name="a-dropdown-menu-sub-trigger"} ::: :::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - open - closed - attribute: "[data-highlighted]" values: Present when highlighted - attribute: "[data-disabled]" values: Present when disabled --- ::: :::docs-css-variables-table --- data: - cssVariable: --akar-dropdown-menu-content-transform-origin description: The `transform-origin` computed from the content and arrow positions/offsets - cssVariable: --akar-dropdown-menu-content-available-width description: The remaining width between the trigger and the boundary edge - cssVariable: --akar-dropdown-menu-content-available-height description: The remaining height between the trigger and the boundary edge - cssVariable: --akar-dropdown-menu-trigger-width description: The width of the trigger - cssVariable: --akar-dropdown-menu-trigger-height description: The height of the trigger --- ::: ### SubContent The component that pops out when a submenu is open. Must be rendered inside `ADropdownMenuSub`. :::docs-component-meta{name="a-dropdown-menu-sub-content"} ::: :::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - open - closed - attribute: "[data-side]" values: - left - right - bottom - top - attribute: "[data-align]" values: - start - end - center - attribute: "[data-orientation]" values: - vertical - horizontal --- ::: ## Examples ### With submenus You can create submenus by using `ADropdownMenuSub` in combination with its parts. ```vue {9-11,24-33} ``` ### With disabled items You can add special styles to disabled items via the `data-disabled` attribute. ```vue {18} ``` ```css {2} /* styles.css */ .ADropdownMenuItem[data-disabled] { color: gainsboro; } ``` ### With separators Use the `Separator` part to add a separator between items. ```vue {7,18,20} ``` ### With labels Use the `Label` part to help label a section. ```vue {5,17} ``` ### With checkbox items Use the `CheckboxItem` part to add an item that can be checked. ```vue {5,26-31} ``` ### With radio items Use the `RadioGroup` and `RadioItem` parts to add an item that can be checked amongst others. ```vue {8-9,22-41} ``` ### With complex items You can add extra decorative elements in the `Item` parts, such as images. ```vue {17,21} ``` ### Constrain the content/sub-content size You may want to constrain the width of the content (or sub-content) so that it matches the trigger (or sub-trigger) width. You may also want to constrain its height to not exceed the viewport. We expose several CSS custom properties such as `--akar-dropdown-menu-trigger-width` and `--akar-dropdown-menu-content-available-height` to support this. Use them to constrain the content dimensions. ```vue {9-12} ``` ```css {3-4} /* styles.css */ .ADropdownMenuContent { width: var(--akar-dropdown-menu-trigger-width); max-height: var(--akar-dropdown-menu-content-available-height); } ``` ### Origin-aware animations We expose a CSS custom property `--akar-dropdown-menu-content-transform-origin`. Use it to animate the content from its computed origin based on `side`, `sideOffset`, `align`, `alignOffset` and any collisions. ```vue {9} ``` ```css {3} /* styles.css */ .ADropdownMenuContent { transform-origin: var(--akar-dropdown-menu-content-transform-origin); animation: scaleIn 0.5s ease-out; } @keyframes scaleIn { from { opacity: 0; transform: scale(0); } to { opacity: 1; transform: scale(1); } } ``` ### Collision-aware animations We expose `data-side` and `data-align` attributes. Their values will change at runtime to reflect collisions. Use them to create collision and direction-aware animations. ```vue {9} ``` ```css {6-11} /* styles.css */ .ADropdownMenuContent { animation-duration: 0.6s; animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1); } .ADropdownMenuContent[data-side='top'] { animation-name: slideUp; } .ADropdownMenuContent[data-side='bottom'] { animation-name: slideDown; } @keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } } @keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } } ``` ## Accessibility Adheres to the [Menu Button WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/menu-button){rel="nofollow"} and uses [roving tabindex](https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_roving_tabindex){rel="nofollow"} to manage focus movement among menu items. ### Keyboard Interactions :::docs-keyboard-table --- data: - keys: - Space description: When focus is on `ADropdownMenuTrigger`, opens the dropdown menu and focuses the first item.
When focus is on an item, activates the focused item. - keys: - Enter description: When focus is on `ADropdownMenuTrigger`, opens the dropdown menu and focuses the first item.
When focus is on an item, activates the focused item. - keys: - ArrowDown description: When focus is on `ADropdownMenuTrigger`, opens the dropdown menu.
When focus is on an item, moves focus to the next item. - keys: - ArrowUp description: When focus is on an item, moves focus to the previous item. - keys: - ArrowRight - ArrowLeft description: When focus is on `ADropdownMenuSubTrigger`, opens or closes the submenu depending on reading direction. - keys: - Esc description: Closes the dropdown menu and moves focus to `ADropdownMenuTrigger`. name: keyboard-a-dropdown-menu --- ::: ## Custom APIs Create your own API by abstracting the primitive parts into your own component. ### Abstract the arrow and item indicators This example abstracts the `ADropdownMenuArrow` and `ADropdownMenuItemIndicator` parts. It also wraps implementation details for `CheckboxItem` and `RadioItem`. #### Usage ```vue ``` #### Implementation ```ts export { default as ADropdownMenuCheckboxItem } from 'ADropdownMenuCheckboxItem.vue'; // your-dropdown-menu.ts export { default as ADropdownMenuContent } from 'ADropdownMenuContent.vue'; export { default as ADropdownMenuRadioItem } from 'ADropdownMenuRadioItem.vue'; export { ADropdownMenuRoot as ADropdownMenu, ADropdownMenuGroup, ADropdownMenuItem, ADropdownMenuLabel, ADropdownMenuRadioGroup, ADropdownMenuSeparator, ADropdownMenuTrigger } from 'akar'; ``` ```vue ``` ```vue ``` ```vue ``` :: # Editable ::docs-component-example{name="a-editable"} :: ## Features ::docs-highlights --- features: - Full keyboard navigation. - Can be controlled or uncontrolled. - Focus is fully managed. --- :: ## Anatomy Import all parts and piece them together. ```vue ``` ## API Reference ### Root Contains all the parts of an editable component. ::docs-component-meta{name="a-editable-root"} :: ### Area Contains the text parts of an editable component. ::docs-component-meta{name="a-editable-area"} :: ::docs-data-attributes-table --- data: - attribute: "[data-readonly]" values: Present when readonly - attribute: "[data-disabled]" values: Present when disabled - attribute: "[data-placeholder-shown]" values: Present when preview is shown - attribute: "[data-empty]" values: Present when the input is empty - attribute: "[data-focus]" values: Present when the editable field is focused. To be deprecated in favor of [data-focused] - attribute: "[data-focused]" values: Present when the editable field is focused --- :: ### Input Contains the input of an editable component. ::docs-component-meta{name="a-editable-input"} :: ::docs-data-attributes-table --- data: - attribute: "[data-disabled]" values: Present when disabled - attribute: "[data-invalid]" values: Present when invalid --- :: ### Preview Contains the preview of the editable component. ::docs-component-meta{name="a-editable-preview"} :: ### Edit Trigger Contains the edit trigger of the editable component. ::docs-component-meta{name="a-editable-edit-trigger"} :: ### Submit Trigger Contains the submit trigger of the editable component. ::docs-component-meta{name="a-editable-submit-trigger"} :: ### Cancel Trigger Contains the cancel trigger of the editable component. ::docs-component-meta{name="a-editable-cancel-trigger"} :: ## Examples ### Change only on submit By default the component will submit when `blur` event triggers. We can modify the `submit-mode` prop to alter this behavior. In this case, we want to submit only when user click on `AEditableSubmitTrigger`, so we change the submit mode to `none`. ```vue line=2,8 ``` ## Accessibility ### Keyboard Interactions ::docs-keyboard-table --- data: - keys: - Tab description: When focus moves onto the editable field, switches into the editable mode if the `activation-mode` is set to focus. - keys: - Enter description: If the `submit-mode` is set to `enter` or `both`, it submits the changes. - keys: - Escape description: When the focus is on the editable field, it cancels the changes. name: a-keyboard-table --- :: # Hover Card ::docs-component-example{name="a-hover-card"} :: ## Features ::docs-highlights --- features: - Can be controlled or uncontrolled. - Customize side, alignment, offsets, collision handling. - Optionally render a pointing arrow. - Supports custom open and close delays. - Ignored by screen readers. --- :: ## Anatomy Import all parts and piece them together. ```vue ``` ## Pohon ::docs-akar-to-pohon --- to: https://akar.vinicunca.dev/docs/pohon/components/popover#mode --- :: ## API Reference ### Root Contains all the parts of a hover card. ::docs-component-meta{name="a-hover-card-root"} :: ### Trigger The link that opens the hover card when hovered. ::docs-component-meta{name="a-hover-card-trigger"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - open - closed --- :: ### Portal When used, portals the content part into the `body`. ::docs-component-meta{name="a-hover-card-portal"} :: ### Content The component that pops out when the hover card is open. ::docs-presence-tip :: ::docs-component-meta{name="a-hover-card-content"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - open - closed - attribute: "[data-side]" values: - left - right - bottom - top - attribute: "[data-align]" values: - start - end - center --- :: ::docs-css-variables-table --- data: - cssVariable: --akar-hover-card-content-transform-origin description: The `transform-origin` computed from the content and arrow positions/offsets - cssVariable: --akar-hover-card-content-available-width description: The remaining width between the trigger and the boundary edge - cssVariable: --akar-hover-card-content-available-height description: The remaining height between the trigger and the boundary edge - cssVariable: --akar-hover-card-trigger-width description: The width of the trigger - cssVariable: --akar-hover-card-trigger-height description: The height of the trigger --- :: ### Arrow An optional arrow element to render alongside the hover card. This can be used to help visually link the trigger with the `AHoverCardContent`. Must be rendered inside `AHoverCardContent`. ::docs-component-meta{name="a-hover-card-arrow"} :: ## Examples ### Show instantly Use the `openDelay` prop to control the time it takes for the hover card to open. ```vue {12} ``` ### Constrain the content size You may want to constrain the width of the content so that it matches the trigger width. You may also want to constrain its height to not exceed the viewport. We expose several CSS custom properties such as `--akar-hover-card-trigger-width` and `--akar-hover-card-content-available-height` to support this. Use them to constrain the content dimensions. ```vue {11} // index.vue ``` ```css {3-4} /* styles.css */ .AHoverCardContent { width: var(--akar-hover-card-trigger-width); max-height: var(--akar-hover-card-content-available-height); } ``` ### Origin-aware animations We expose a CSS custom property `--akar-hover-card-content-transform-origin`. Use it to animate the content from its computed origin based on `side`, `sideOffset`, `align`, `alignOffset` and any collisions. ```vue {8} ``` ```css {3} /* styles.css */ .AHoverCardContent { transform-origin: var(--akar-hover-card-content-transform-origin); animation: scaleIn 0.5s ease-out; } @keyframes scaleIn { from { opacity: 0; transform: scale(0); } to { opacity: 1; transform: scale(1); } } ``` ### Collision-aware animations We expose `data-side` and `data-align` attributes. Their values will change at runtime to reflect collisions. Use them to create collision and direction-aware animations. ```vue {8} ``` ```css {6-11} /* styles.css */ .AHoverCardContent { animation-duration: 0.6s; animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1); } .AHoverCardContent[data-side="top"] { animation-name: slideUp; } .AHoverCardContent[data-side="bottom"] { animation-name: slideDown; } @keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } } @keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } } ``` ## Accessibility The hover card is intended for sighted users only, the content will be inaccessible to keyboard users. ### Keyboard Interactions ::docs-keyboard-table --- data: - keys: - Tab description: Opens/closes the hover card. - keys: - Enter description: Opens the hover card link name: keyboard-a-popover --- :: # Label ::docs-component-example{name="a-label"} :: ## Features ::docs-highlights --- features: - Text selection is prevented when double clicking label. - Supports nested controls. --- :: ## Anatomy Import the component. ```vue ``` ## API Reference ### Root Contains the content for the label. ::docs-component-meta{name="a-label"} :: ## Accessibility This component is based on the native `label` element, it will automatically apply the correct labelling when wrapping controls or using the `for` attribute. For your own custom controls to work correctly, ensure they use native elements such as `button` or `input` as a base. # Listbox ::docs-component-example{name="a-listbox"} :: ## Features ::docs-highlights --- features: - Can be controlled or uncontrolled. - Supports items, labels, groups of items. - Focus is fully managed. - Full keyboard navigation. - Supports Right to Left direction. - Different selection behavior. --- :: ## Anatomy Import all parts and piece them together. ```vue ``` ## API Reference ### Root Contains all the parts of a listbox. An `input` will also render when used within a `form` to ensure events propagate correctly. ::docs-component-meta{name="a-listbox-root"} :: ::docs-data-attributes-table --- data: - attribute: "[data-disabled]" values: Present when disabled --- :: ### Filter Input element to perform filtering. ::docs-component-meta{name="a-listbox-filter"} :: ::docs-data-attributes-table --- data: - attribute: "[data-disabled]" values: Present when disabled --- :: ### Content Contains all the listbox group and items. ::docs-component-meta{name="a-listbox-content"} :: ### Item The item component. ::docs-component-meta{name="a-listbox-item"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - checked - unchecked - attribute: "[data-highlighted]" values: Present when highlighted - attribute: "[data-disabled]" values: Present when disabled --- :: ### ItemIndicator Renders when the item is selected. You can style this element directly, or you can use it as a wrapper to put an icon into, or both. ::docs-component-meta{name="a-listbox-item-indicator"} :: ### Group Used to group multiple items. use in conjunction with `AListboxGroupLabel` to ensure good accessibility via automatic labelling. ::docs-component-meta{name="a-listbox-group"} :: ### GroupLabel Used to render the label of a group. It won't be focusable using arrow keys. ::docs-component-meta{name="a-listbox-group-label"} :: ### Virtualizer Virtual container to achieve list virtualization. ::docs-component-meta{name="a-listbox-virtualizer"} :: ## Examples ### Binding objects as values Unlike native HTML form controls which only allow you to provide strings as values, `akar` supports binding complex objects as well. ```vue {12,16,21} ``` ### Selecting multiple values The `AListbox` component allows you to select multiple values. You can enable this by providing an array of values instead of a single value. ```vue {12,18} ``` ### Custom filtering ```vue {13,15-16,21,24} ``` ### Virtual List Rendering a long list of item can slow down the app, thus using virtualization would significantly improve the performance. See the [virtualization guide](https://akar.vinicunca.dev/docs/akar/guides/virtualization.md) for more general info on virtualization. ```vue {18-23} ``` ## Accessibility Adheres to the [AListbox WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/listbox/){rel="nofollow"}. ### Keyboard Interactions ::docs-keyboard-table --- data: - keys: - Enter description: When highlight on AListboxItem, selects the focused item. - keys: - ArrowDown description: When focus is on AListboxItem, moves focus to the next item. - keys: - ArrowUp description: When focus is on AListboxItem, moves focus to the previous item. - keys: - Home description: Moves focus and highlight to the first item. - keys: - End description: Moves focus and highlight to the last item. - keys: - Ctrl/Cmd + A description: Select all the items. name: keyboard-a-calendar --- :: # Navigation Menu ::docs-component-example{name="a-navigation-menu"} :: ## Features ::docs-highlights --- features: - Can be controlled or uncontrolled. - Flexible layout structure with managed tab focus. - Supports submenus. - Optional active item indicator. - Full keyboard navigation. - Exposes CSS variables for advanced animation. - Supports custom timings. --- :: ## Anatomy Import all parts and piece them together. ```vue ``` ## Pohon ::docs-akar-to-pohon --- to: https://akar.vinicunca.dev/docs/pohon/components/navigation-menu --- :: ## API Reference ### Root Contains all the parts of a navigation menu. ::docs-component-meta{name="a-navigation-menu-root"} :: ::docs-data-attributes-table{keys="orientation"} :: ### Sub Signifies a submenu. Use it in place of the root part when nested to create a submenu. ::docs-component-meta{name="a-navigation-menu-sub"} :: ::docs-data-attributes-table{keys="orientation"} :: ### List Contains the top level menu items. ::docs-component-meta{name="a-navigation-menu-list"} :: ::docs-data-attributes-table{keys="orientation"} :: ### Item A top level menu item, contains a link or trigger with content combination. ::docs-component-meta{name="a-navigation-menu-item"} :: ### Trigger The button that toggles the content. ::docs-component-meta{name="a-navigation-menu-trigger"} :: ::docs-data-attributes-table{keys="state, disabled"} :: ### Content Contains the content associated with each trigger. ::docs-presence-tip :: ::docs-component-meta{name="a-navigation-menu-content"} :: ::docs-data-attributes-table{keys="state, motion, orientation"} :: ### Link A navigational link. ::docs-component-meta{name="a-navigation-menu-link"} :: ::docs-data-attributes-table{keys="active"} :: ### Indicator An optional indicator element that renders below the list, is used to highlight the currently active trigger. ::docs-presence-tip :: ::docs-component-meta{name="a-navigation-menu-indicator"} :: ::docs-data-attributes-table{keys="visible, orientation"} :: ::docs-css-variables-table --- data: - cssVariable: --akar-navigation-menu-indicator-size description: The size of the indicator. - cssVariable: --akar-navigation-menu-indicator-position description: The position of the indicator --- :: ### Viewport An optional viewport element that is used to render active content outside of the list. ::docs-presence-tip :: ::docs-component-meta{name="a-navigation-menu-viewport"} :: ::docs-data-attributes-table{keys="visible, orientation"} :: ::docs-css-variables-table --- data: - cssVariable: --akar-navigation-menu-viewport-width description: The width of the viewport when visible/hidden, computed from the active content - cssVariable: --akar-navigation-menu-viewport-height description: The height of the viewport when visible/hidden, computed from the active content --- :: ## Examples ### Vertical You can create a vertical menu by using the `orientation` prop. ```vue {16} ``` ### Flexible layouts Use the `Viewport` part when you need extra control over where `Content` is rendered. This can be helpful when your design requires an adjusted DOM structure or if you need flexibility to achieve [advanced animation](https://akar.vinicunca.dev/docs/akar/components/navigation-menu#advanced-animation). Tab focus will be maintained automatically. ```vue {26} ``` ### With indicator You can use the optional `Indicator` part to highlight the currently active `Trigger`, this is useful when you want to provide an animated visual cue such as an arrow or highlight to accompany the `Viewport`. ```vue {24} ``` ```css /* styles.css */ .ANavigationMenuIndicator { background-color: grey; position: absolute; transition: width, transform, 250ms ease; } .ANavigationMenuIndicator[data-orientation='horizontal'] { left: 0; height: 3px; transform: translateX(var(--akar-navigation-menu-indicator-position)); width: var(--akar-navigation-menu-indicator-size); } ``` ### With submenus Create a submenu by nesting your `ANavigationMenu` and using the `Sub` part in place of its `Root`. Submenus work differently to `Root` navigation menus and are similar to [`Tabs`](https://akar.vinicunca.dev/docs/akar/components/tabs) in that one item should always be active, so be sure to assign and set a `defaultValue`. ```vue {7,23-34} ``` ### With client side routing If you need to use the `RouterLink` component provided by your routing package then we recommend adding `asChild="true"` to `ANavigationMenuLink`, or setting `as="RouterLink"`. This will ensure accessibility and consistent keyboard control is maintained: ```vue {12-14,19-21} ``` ### Advanced animation We expose `--akar-navigation-menu-viewport-[width|height]` and `data-motion['from-start'|'to-start'|'from-end'|'to-end']` attributes to allow you to animate `Viewport` size and `Content` position based on the enter/exit direction. Combining these with `position: absolute;` allows you to create smooth overlapping animation effects when moving between items. ```vue {17,23,29} ``` ```css {9-20,24-25} /* styles.css */ .ANavigationMenuContent { position: absolute; top: 0; left: 0; animation-duration: 250ms; animation-timing-function: ease; } .ANavigationMenuContent[data-motion='from-start'] { animation-name: enterFromLeft; } .ANavigationMenuContent[data-motion='from-end'] { animation-name: enterFromRight; } .ANavigationMenuContent[data-motion='to-start'] { animation-name: exitToLeft; } .ANavigationMenuContent[data-motion='to-end'] { animation-name: exitToRight; } .ANavigationMenuViewport { position: relative; width: var(--akar-navigation-menu-viewport-width); height: var(--akar-navigation-menu-viewport-height); transition: width, height, 250ms ease; } @keyframes enterFromRight { from { opacity: 0; transform: translateX(200px); } to { opacity: 1; transform: translateX(0); } } @keyframes enterFromLeft { from { opacity: 0; transform: translateX(-200px); } to { opacity: 1; transform: translateX(0); } } @keyframes exitToRight { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(200px); } } @keyframes exitToLeft { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(-200px); } } ``` ## Accessibility Adheres to the [`navigation` role requirements](https://www.w3.org/TR/wai-aria-1.2/#navigation){rel="nofollow"}. ### Differences to menubar `ANavigationMenu` should not be confused with `menubar`, although this primitive shares the name `menu` in the colloquial sense to refer to a set of navigation links, it does not use the WAI-ARIA `menu` role. This is because `menu` and `menubars` behave like native operating system menus most commonly found in desktop application windows, as such they feature complex functionality like composite focus management and first-character navigation. These features are often considered [unnecessary for website navigation](https://github.com/w3c/aria-practices/issues/353){rel="nofollow"} and at worst can confuse users who are familiar with established website patterns. See the W3C [Disclosure Navigation Menu](https://w3c.github.io/aria-practices/examples/disclosure/disclosure-navigation.html){rel="nofollow"} example for more information. ### Link usage and aria-current It's important to use `ANavigationMenuLink` for all navigational links within a menu, this not only applies to the main list but also within any content rendered via `ANavigationMenuContent`. This will ensure consistent keyboard interactions and accessibility while also giving access to the `active` prop for setting `aria-current` and the active styles. See [this example](https://akar.vinicunca.dev/docs/akar/components/navigation-menu#with-client-side-routing) for more information on usage with third party routing components. ### Keyboard Interactions ::docs-keyboard-table --- data: - keys: - Space - Enter description: When focus is on ANavigationMenuTrigger, opens the content. - keys: - Tab description: Moves focus to the next focusable element. - keys: - ArrowDown description: When horizontal and focus is on an open ANavigationMenuTrigger, moves focus into ANavigationMenuContent.
Moves focus to the next ANavigationMenuTrigger or ANavigationMenuLink.
- keys: - ArrowUp description: Moves focus to the previous ANavigationMenuTrigger or ANavigationMenuLink. - keys: - ArrowRight - ArrowLeft description: When vertical and focus is on an open ANavigationMenuTrigger, moves focus into its ANavigationMenuContent.
Moves focus to the next / previous ANavigationMenuTrigger or ANavigationMenuLink.
- keys: - Home - End description: Moves focus to the first/last ANavigationMenu.Trigger or ANavigationMenu.Link. - keys: - Esc description: Closes open ANavigationMenu.Content and moves focus to itsANavigationMenu.Trigger. name: keyboard-a-navigation-menu --- :: # Number Field ::docs-component-example{name="a-number-field"} :: ## Features ::docs-highlights --- features: - Full keyboard navigation. - Can be controlled or uncontrolled. - Support button hold and wheel event. - Support numbering systems in different locale. - Customizable formatting. --- :: ::code-group{sync="pm"} ```bash [pnpm] pnpm add @internationalized/number ``` ```bash [npm] npm install @internationalized/number ``` ```bash [bun] bun add @internationalized/number ``` :: ## Anatomy Import all parts and piece them together. ```vue ``` ## Pohon ::docs-akar-to-pohon --- to: https://akar.vinicunca.dev/docs/pohon/components/input-number --- :: ## API Reference ### Root Contains all the parts of a number field. An `input` will also render when used within a `form` to ensure events propagate correctly. ::docs-component-meta{name="a-number-field-root"} :: ::docs-data-attributes-table --- data: - attribute: "[data-disabled]" values: Present when disabled --- :: ### Input Input The input component that renders the text value based on value and format options. ::docs-component-meta{name="a-number-field-input"} :: ::docs-data-attributes-table --- data: - attribute: "[data-disabled]" values: Present when disabled --- :: ### Increment The button that increases the value. ::docs-component-meta{name="a-number-field-increment"} :: ::docs-data-attributes-table --- data: - attribute: "[data-disabled]" values: Present when disabled - attribute: "[data-pressed]" values: Present when pressed --- :: ### Decrement The button that decreases the value. ::docs-component-meta{name="a-number-field-decrement"} :: ::docs-data-attributes-table --- data: - attribute: "[data-disabled]" values: Present when disabled - attribute: "[data-pressed]" values: Present when pressed --- :: ## Example ### Decimal All options supported by `Intl.NumberFormat` are supported, including configuration of minimum and maximum fraction digits, sign display, grouping separators, etc. ```vue {3-7} ``` ### Percentage You can set `formatOptions.style` to `percent` to treat the value as a percentage. You need to set the step to 0.01 manually to allow an appropriate step size in this mode. ```vue {3-7} ``` ### Currency You can set `formatOptions.style` to `currency` to treat the value as a currency value. The currency option must also be passed to set the currency code (e.g., USD). If you need to allow the user to change the currency, you should include a separate dropdown next to the number field. The number field itself will not determine the currency from the user input. ```vue {4-9} ``` ## Accessibility Adheres to the [Spinbutton WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/spinbutton){rel="nofollow"}. ### Keyboard Interactions ::docs-keyboard-table --- data: - keys: - ArrowUp description: Increase the value - keys: - ArrowDown description: Decrease the value - keys: - PageUp description: Increase the value by scale of 10 - keys: - PageDown description: Decrease the value by scale of 10 - keys: - Home description: Set value to minimum (if min is provided) - keys: - End description: Set value to maximum (if max is provided) name: keyboard-a-number-field --- :: # Pagination ::docs-component-example{name="a-pagination"} :: ## Features ::docs-highlights --- features: - Enable quick access to first, or last page - Enable to show edges constantly, or not --- :: ### Anatomy Import all parts and piece them together. ```vue ``` ## Pohon ::docs-akar-to-pohon --- to: https://akar.vinicunca.dev/docs/pohon/components/pagination --- :: ## API Reference ### Root Contains all of the paginations parts. ::docs-component-meta{name="a-pagination-root"} :: ### List Used to show the list of pages. It also makes pagination accessible to assistive technologies. ::docs-component-meta{name="a-pagination-list"} :: ### Item Used to render the button that changes the current page. ::docs-component-meta{name="a-pagination-item"} :: ::docs-data-attributes-table --- data: - attribute: "[data-selected]" values: - "true" - "" - attribute: "[data-type]" values: - page --- :: ### Ellipsis Placeholder element when the list is long, and only a small amount of `siblingCount` was set and `showEdges` was set to `true`. ::docs-component-meta{name="a-pagination-ellipsis"} :: ::docs-data-attributes-table --- data: - attribute: "[data-type]" values: - ellipsis --- :: ### First Triggers that set the page value to 1 ::docs-component-meta{name="a-pagination-first"} :: ### Prev Triggers that set the page value to the previous page ::docs-component-meta{name="a-pagination-prev"} :: ### Next Triggers that set the page value to the next page ::docs-component-meta{name="a-pagination-next"} :: ### Last Triggers that set the page value to the last page ::docs-component-meta{name="a-pagination-last"} :: ## Examples ### With ellipsis You can add `APaginationEllipsis` as a visual cue for more previous and after items. ```vue {10,14} ``` ### With first/last button You can add `APaginationFirst` to allow user to navigate to first page, or `APaginationLast` to navigate to last page. ```vue {8,10} ``` ### Control page programmatically You can control the current page by passing it a reactive value. ```vue {6,10-11} ``` ## Keyboard Interactions ::docs-keyboard-table --- data: - keys: - Tab description: Moves focus to the next focusable element. - keys: - Space description: When focus is on a any trigger, trigger selected page or arrow navigation - keys: - Enter description: When focus is on a any trigger, trigger selected page or arrow navigation name: keyboard-a-pagination --- :: # Pin Input ::docs-component-example{name="a-pin-input"} :: ## Features ::docs-highlights --- features: - Full keyboard navigation. - Can be controlled or uncontrolled. - Supports pasting from clipboard - Emit event when inputs were filled. --- :: ## Anatomy Import all parts and piece them together. ```vue ``` ## Pohon ::docs-akar-to-pohon --- to: https://akar.vinicunca.dev/docs/pohon/components/pin-input --- :: ## API Reference ### Root Contains all the parts of a pin. An `input` will also render when used within a `form` to ensure events propagate correctly. ::docs-component-meta{name="a-pin-input-root"} :: ::docs-data-attributes-table --- data: - attribute: "[data-complete]" values: Present when all inputs are filled - attribute: "[data-disabled]" values: Present when disabled --- :: ### Input Input field for Pin Input. You can add as many input as you like. ::docs-component-meta{name="a-pin-input-input"} :: ::docs-data-attributes-table --- data: - attribute: "[data-complete]" values: Present when all inputs are filled - attribute: "[data-disabled]" values: Present when disabled --- :: ## Examples ### OTP mode You can set the pin input to `otp` mode by setting otp to `true`. ````vue {6} `` ### Numeric mode You can set the pin input to only accept `number` type by setting type to `number`. ```vue{6} ```` ## Accessibility ### Keyboard Interactions ::docs-keyboard-table --- data: - keys: - ArrowLeft description: Focus on previous input. - keys: - ArrowRight description: Focus on next input. - keys: - Home description: Focus on the first input. - keys: - End description: Focus on the last input. - keys: - Backspace description: Deletes the value of the current input. If the input is empty, moves to the previous input and deletes that value as well. - keys: - Delete description: Deletes the value of the current input. - keys: - Ctrl + V description: Pastes the contents of the clipboard into the pin input. If the number of characters in the clipboard equals exceeds the number of inputs, the contents are pasted from the first input. Otherwise, the contents are pasted from the current input onwards. name: keyboard-a-number-field --- :: # Popover ::docs-component-example{name="a-popover"} :: ## Features ::docs-highlights --- features: - Can be controlled or uncontrolled. - Customize side, alignment, offsets, collision handling. - Optionally render a pointing arrow. - Focus is fully managed and customizable. - Supports modal and non-modal modes. - Dismissing and layering behavior is highly customizable. --- :: ## Anatomy Import all parts and piece them together. ```vue ``` ## Pohon ::docs-akar-to-pohon --- to: https://akar.vinicunca.dev/docs/pohon/components/popover --- :: ## API Reference ### Root Contains all the parts of a popover. ::docs-component-meta{name="a-popover-root"} :: ### Trigger The button that toggles the popover. By default, the `APopoverContent` will position itself against the trigger. ::docs-component-meta{name="a-popover-trigger"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - open - closed --- :: ### Anchor An optional element to position the `APopoverContent` against. If this part is not used, the content will position alongside the `APopoverTrigger`. ::docs-component-meta{name="a-popover-anchor"} :: ### Portal When used, portals the content part into the `body`. ::docs-component-meta{name="a-popover-portal"} :: ### Content The component that pops out when the popover is open. ::docs-presence-tip :: ::docs-component-meta{name="a-popover-content"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - open - closed - attribute: "[data-side]" values: - left - right - bottom - top - attribute: "[data-align]" values: - start - end - center --- :: ::docs-css-variables-table --- data: - cssVariable: --akar-popover-content-transform-origin description: The `transform-origin` computed from the content and arrow positions/offsets - cssVariable: --akar-popover-content-available-width description: The remaining width between the trigger and the boundary edge - cssVariable: --akar-popover-content-available-height description: The remaining height between the trigger and the boundary edge - cssVariable: --akar-popover-trigger-width description: The width of the trigger - cssVariable: --akar-popover-trigger-height description: The height of the trigger --- :: ### Arrow An optional arrow element to render alongside the popover. This can be used to help visually link the anchor with the `APopoverContent`. Must be rendered inside `APopoverContent`. ::docs-component-meta{name="a-popover-arrow"} :: ### Close The button that closes an open popover. ::docs-component-meta{name="a-popover-close"} :: ## Examples ### Constrain the content size You may want to constrain the width of the content so that it matches the trigger width. You may also want to constrain its height to not exceed the viewport. We expose several CSS custom properties such as `--akar-popover-trigger-width` and `--akar-popover-content-available-height` to support this. Use them to constrain the content dimensions. ```vue {10-11} ``` ```css {3-4} /* styles.css */ .APopoverContent { width: var(--akar-popover-trigger-width); max-height: var(--akar-popover-content-available-height); } ``` ### Origin-aware animations We expose a CSS custom property `--akar-popover-content-transform-origin`. Use it to animate the content from its computed origin based on `side`, `sideOffset`, `align`, `alignOffset` and any collisions. ```vue {9} ``` ```css {3} /* styles.css */ .APopoverContent { transform-origin: var(--akar-popover-content-transform-origin); animation: scaleIn 0.5s ease-out; } @keyframes scaleIn { from { opacity: 0; transform: scale(0); } to { opacity: 1; transform: scale(1); } } ``` ### Collision-aware animations We expose `data-side` and `data-align` attributes. Their values will change at runtime to reflect collisions. Use them to create collision and direction-aware animations. ```vue {9} ``` ```css {6-11} /* styles.css */ .APopoverContent { animation-duration: 0.6s; animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1); } .APopoverContent[data-side='top'] { animation-name: slideUp; } .APopoverContent[data-side='bottom'] { animation-name: slideDown; } @keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } } @keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } } ``` ### With custom anchor You can anchor the content to another element if you do not want to use the trigger as the anchor. ```vue {7-11} ``` ```css /* styles.css */ .Row { background-color: gainsboro; padding: 20px; } ``` ### Close using slot props Alternatively, you can use the `close` method provided by the `APopoverRoot` slot props to programmatically close the popover. ```vue {4,8,16-20} ``` ## Accessibility Adheres to the [Dialog WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/){rel="nofollow"}. ### Keyboard Interactions ::docs-keyboard-table --- data: - keys: - Space description: Opens/closes the popover. - keys: - Enter description: Opens/closes the popover. - keys: - Tab description: Moves focus to the next focusable element - keys: - Shift + Tab description: Moves focus to the previous focusable element - keys: - Esc description: Closes the popover and moves focus to APopoverTrigger. name: keyboard-a-popover --- :: ## Custom APIs Create your own API by abstracting the primitive parts into your own component. #### Abstract the arrow and set default configuration This example abstracts the `APopoverArrow` part and sets a default `sideOffset` configuration. #### Usage ```vue ``` #### Implementation ```ts export { APopoverRoot as APopover, APopoverTrigger } from 'akar'; // your-popover.ts export { default as APopoverContent } from 'APopoverContent.vue'; ``` ```vue ``` # Progress ::docs-component-example{name="a-progress"} :: ## Features ::docs-highlights --- features: - Provides context for assistive technology to read the progress of a task. --- :: ### Anatomy Import all parts and piece them together. ```vue ``` ## Accessibility Adheres to the [`progressbar` role requirements](https://www.w3.org/WAI/ARIA/apg/patterns/meter){rel="nofollow"}. ## API Reference ### Root Contains all of the progress parts. ::docs-component-meta{name="a-progress-root"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - complete - indeterminate - loading - attribute: "[data-value]" values: The current value - attribute: "[data-max]" values: The max value --- :: ### Indicator Used to show the progress visually. It also makes progress accessible to assistive technologies. ::docs-component-meta{name="a-progress-indicator"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - complete - indeterminate - loading - attribute: "[data-value]" values: The current value - attribute: "[data-max]" values: The max value --- :: # Radio Group ::docs-component-example{name="a-radio-group"} :: ## Features ::docs-highlights --- features: - Full keyboard navigation. - Supports horizontal/vertical orientation. - Can be controlled or uncontrolled. --- :: ## Anatomy Import all parts and piece them together. ```vue ``` ## API Reference ### Root Contains all the parts of a radio group. ::docs-component-meta{name="a-radio-group-root"} :: ::docs-data-attributes-table --- data: - attribute: "[data-disabled]" values: Present when disabled --- :: ### Item An item in the group that can be checked. An `input` will also render when used within a `form` to ensure events propagate correctly. ::docs-component-meta{name="a-radio-group-item"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - checked - unchecked - attribute: "[data-disabled]" values: Present when disabled --- :: ### Indicator Renders when the radio item is in a checked state. You can style this element directly, or you can use it as a wrapper to put an icon into, or both. ::docs-presence-tip :: ::docs-component-meta{name="a-radio-group-indicator"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - checked - unchecked - attribute: "[data-disabled]" values: Present when disabled --- :: ## Accessibility Adheres to the [Radio Group WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/radiobutton){rel="nofollow"} and uses [roving tabindex](https://www.w3.org/TR/wai-aria-practices-1.2/examples/radio/radio.html){rel="nofollow"} to manage focus movement among radio items. ### Keyboard Interactions ::docs-keyboard-table --- data: - keys: - Tab description: Moves focus to either the checked radio item or the first radio item in the group. - keys: - Space description: When focus is on an unchecked radio item, checks it. - keys: - ArrowDown description: Moves focus and checks the next radio item in the group. - keys: - ArrowRight description: Moves focus and checks the next radio item in the group. - keys: - ArrowUp description: Moves focus to the previous radio item in the group. - keys: - ArrowLeft description: Moves focus to the previous radio item in the group. name: keyboard-a-radio-group --- :: # Range Calendar ::docs-component-example{name="a-range-calendar"} :: ## Features ::docs-highlights --- features: - Full keyboard navigation - Can be controlled or uncontrolled - Focus is fully managed - Localization support - Highly composable --- :: ## Preface The component depends on the [@internationalized/date](https://react-spectrum.adobe.com/internationalized/date/index.html){rel="nofollow"} package, which solves a lot of the problems that come with working with dates and times in JavaScript. We highly recommend reading through the documentation for the package to get a solid feel for how it works, and you'll need to install it in your project to use the date-related components. ## Anatomy Import all parts and piece them together. ```vue ``` ## Pohon ::docs-akar-to-pohon --- to: https://akar.vinicunca.dev/docs/pohon/components/calendar#range --- :: ## API Reference ### Root Contains all the parts of a calendar ::docs-component-meta{name="a-range-calendar-root"} :: ::docs-data-attributes-table --- data: - attribute: "[data-readonly]" values: Present when readonly - attribute: "[data-disabled]" values: Present when disabled - attribute: "[data-invalid]" values: Present when invalid --- :: ### Header Contains the navigation buttons and the heading segments. ::docs-component-meta{name="a-range-calendar-header"} :: ### Prev Button Calendar navigation button. It navigates the calendar one month/year/decade in the past based on the current calendar view. ::docs-data-attributes-table --- data: - attribute: "[data-disabled]" values: Present when disabled --- :: ::docs-component-meta{name="a-range-calendar-prev"} :: ### Next Button Calendar navigation button. It navigates the calendar one month/year/decade in the future based on the current calendar view. ::docs-component-meta{name="a-range-calendar-next"} :: ::docs-data-attributes-table --- data: - attribute: "[data-disabled]" values: Present when disabled --- :: ### Heading Heading for displaying the current month and year. ::docs-component-meta{name="a-range-calendar-heading"} :: ::docs-data-attributes-table --- data: - attribute: "[data-disabled]" values: Present when disabled --- :: ### Grid Container for wrapping the calendar grid. ::docs-component-meta{name="a-range-calendar-grid"} :: ::docs-data-attributes-table --- data: - attribute: "[data-readonly]" values: Present when readonly - attribute: "[data-disabled]" values: Present when disabled --- :: ### Grid Head Container for wrapping the grid head. ::docs-component-meta{name="a-range-calendar-grid-head"} :: ### Grid Body Container for wrapping the grid body. ::docs-component-meta{name="a-range-calendar-grid-body"} :: ### Grid Row Container for wrapping the grid row. ::docs-component-meta{name="a-range-calendar-grid-row"} :: ### Head Cell Container for wrapping the head cell. Used for displaying the week days. ::docs-component-meta{name="a-range-calendar-head-cell"} :: ### Cell Container for wrapping the calendar cells. ::docs-component-meta{name="a-range-calendar-cell"} :: ::docs-data-attributes-table --- data: - attribute: "[data-disabled]" values: Present when disabled --- :: ### Cell Trigger Interactable container for displaying the cell dates. Clicking it selects the date. ::docs-component-meta{name="a-range-calendar-cell-trigger"} :: ::docs-data-attributes-table --- data: - attribute: "[data-selected]" values: Present when selected - attribute: "[data-value]" values: The ISO string value of the date. - attribute: "[data-disabled]" values: Present when disabled - attribute: "[data-unavailable]" values: Present when unavailable - attribute: "[data-today]" values: Present when today - attribute: "[data-outside-view]" values: Present when the date is outside the current month it is displayed in. - attribute: "[data-outside-visible-view]" values: Present when the date is outside the months that are visible on the calendar. - attribute: "[data-focused]" values: Present when focused - attribute: "[data-selection-start]" values: Present when the date is the start of the selection. - attribute: "[data-selection-end]" values: Present when the date is the end of the selection. - attribute: "[data-highlighted]" values: Present when the date is highlighted by the user as they select a range. - attribute: "[data-highlighted-start]" values: Present when the date is the start of the range that is highlighted by the user. - attribute: "[data-highlighted-end]" values: Present when the date is the end of the range that is highlighted by the user. - attribute: "[data-focused]" values: Present when focused --- :: ## Accessibility ### Keyboard Interactions ::docs-keyboard-table --- data: - keys: - Tab description: When focus moves onto the calendar, focuses the first navigation button. - keys: - Space description: When the focus is on either `CalendarNext` or `CalendarPrev`, it navigates the calendar. Otherwise, it selects the date. - keys: - Enter description: When the focus is on either `CalendarNext` or `CalendarPrev`, it navigates the calendar. Otherwise, it selects the date. - keys: - ArrowLeft - ArrowRight - ArrowUp - ArrowDown description: When the focus is on `CalendarCellTrigger`, it navigates the dates, changing the month/year/decade if necessary. name: keyboard-a-range-calendar --- :: # Scroll Area ::docs-component-example{name="a-scroll-area"} :: ## Features ::docs-highlights --- features: - Scrollbar sits on top of the scrollable content, taking up no space. - Scrolling is native; no underlying position movements via CSS transformations. - Shims pointer behaviors only when interacting with the controls, so keyboard controls are unaffected. - Supports Right to Left direction. --- :: ## Anatomy Import all parts and piece them together. ```vue ``` ## API Reference ### Root Contains all the parts of a scroll area. ::docs-component-meta{name="a-scroll-area-root"} :: ### Viewport The viewport area of the scroll area. ::docs-component-meta{name="a-scroll-area-viewport"} :: ### Scrollbar The vertical scrollbar. Add a second `Scrollbar` with an `orientation` prop to enable horizontal scrolling. ::docs-presence-tip :: ::docs-component-meta{name="a-scroll-area-scrollbar"} :: ::docs-data-attributes-table --- data: - attribute: "[data-orientation]" values: - vertical - horizontal - attribute: "[data-state]" values: - visible - hidden --- :: ### Thumb The thumb to be used in `AScrollAreaScrollbar`. ::docs-component-meta{name="a-scroll-area-thumb"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - visible - hidden --- :: ### Corner The corner where both vertical and horizontal scrollbars meet. ::docs-component-meta{name="a-scroll-area-corner"} :: ## Examples ### Custom Scroll Use the exposed `viewport` to modify / or set the scroll position outside default methods ```vue {4,18} ``` ## Accessibility In most cases, it's best to rely on native scrolling and work with the customization options available in CSS. When that isn't enough, `AScrollArea` provides additional customizability while maintaining the browser's native scroll behavior (as well as accessibility features, like keyboard scrolling). ### Keyboard Interactions Scrolling via keyboard is supported by default because the component relies on native scrolling. Specific keyboard interactions may differ between platforms, so we do not specify them here or add specific event listeners to handle scrolling via key events. # Select ::docs-component-example{name="a-select"} :: ## Features ::docs-highlights --- features: - Can be controlled or uncontrolled. - Offers 2 positioning modes. - Supports items, labels, groups of items. - Focus is fully managed. - Full keyboard navigation. - Supports custom placeholder. - Typeahead support. - Supports Right to Left direction. --- :: ## Anatomy Import all parts and piece them together. ```vue ``` ## Pohon ::docs-akar-to-pohon --- to: https://akar.vinicunca.dev/docs/pohon/components/select --- :: ## API Reference ### Root Contains all the parts of a ASelect ::docs-component-meta{name="a-select-root"} :: ### Trigger The button that toggles the ASelect The `ASelectContent` will position itself by aligning over the trigger. ::docs-component-meta{name="a-select-trigger"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - open - closed - attribute: "[data-placeholder]" values: Present when has placeholder - attribute: "[data-disabled]" values: Present when disabled --- :: ### Value The part that reflects the selected value. By default the selected item's text will be rendered. if you require more control, you can instead control the select and pass your own `children`. It should not be styled to ensure correct positioning. An optional `placeholder` prop is also available for when the select has no value. ::docs-component-meta{name="a-select-value"} :: ### Icon A small icon often displayed next to the value as a visual affordance for the fact it can be open. By default renders ▼ but you can use your own icon via `asChild` or use `children`. ::docs-component-meta{name="a-select-item"} :: ### Portal When used, portals the content part into the `body`. ::docs-component-meta{name="a-select-portal"} :: ### Content The component that pops out when the select is open. ::docs-presence-tip :: ::docs-component-meta{name="a-select-content"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - open - closed - attribute: "[data-side]" values: - left - right - bottom - top - attribute: "[data-align]" values: - start - end - center --- :: ::docs-css-variables-table --- data: - cssVariable: --akar-select-content-transform-origin description: The `transform-origin` computed from the content and arrow positions/offsets. Only present when `position="popper"` - cssVariable: --akar-select-content-available-width description: The remaining width between the trigger and the boundary edge. Only present when `position="popper"` - cssVariable: --akar-select-content-available-height description: The remaining height between the trigger and the boundary edge. Only present when `position="popper"` - cssVariable: --akar-select-trigger-width description: The width of the trigger. Only present when `position="popper"` - cssVariable: --akar-select-trigger-height description: The height of the trigger. Only present when `position="popper"` --- :: ### Viewport The scrolling viewport that contains all of the items. ::docs-component-meta{name="a-select-viewport"} :: ### Item The component that contains the select items. ::docs-component-meta{name="a-select-item"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - checked - unchecked - attribute: "[data-highlighted]" values: Present when highlighted - attribute: "[data-disabled]" values: Present when disabled --- :: ### ItemText The textual part of the item. It should only contain the text you want to see in the trigger when that item is selected. It should not be styled to ensure correct positioning. ::docs-component-meta{name="a-select-item-text"} :: ### ItemIndicator Renders when the item is selected. You can style this element directly, or you can use it as a wrapper to put an icon into, or both. ::docs-component-meta{name="a-select-item-indicator"} :: ### ScrollUpButton An optional button used as an affordance to show the viewport overflow as well as functionally enable scrolling upwards. ::docs-component-meta{name="a-select-scroll-up-button"} :: ### ScrollDownButton An optional button used as an affordance to show the viewport overflow as well as functionally enable scrolling downwards. ::docs-component-meta{name="a-select-scroll-down-button"} :: ### Group Used to group multiple items. use in conjunction with `ASelectLabel` to ensure good accessibility via automatic labelling. ::docs-component-meta{name="a-select-group"} :: ### Label Used to render the label of a group. It won't be focusable using arrow keys. ::docs-component-meta{name="a-select-label"} :: ### Separator Used to visually separate items in the ASelect ::docs-component-meta{name="a-select-separator"} :: ### Arrow An optional arrow element to render alongside the content. This can be used to help visually link the trigger with the `ASelectContent`. Must be rendered inside `ASelectContent`. Only available when `position` is set to `popper`. ::docs-component-meta{name="a-select-arrow"} :: ## Examples ### Change the positioning mode By default, `ASelect` will behave similarly to a native MacOS menu by positioning `ASelectContent` relative to the active item. If you would prefer an alternative positioning approach similar to `Popover` or `DropdownMenu` then you can set `position` to `popper` and make use of additional alignment options such as `side`, `sideOffset` and more. ```vue {20-23} // index.vue ``` ### Constrain the content size When using `position="popper"` on `ASelectContent`, you may want to constrain the width of the content so that it matches the trigger width. You may also want to constrain its height to not exceed the viewport. We expose several CSS custom properties such as `--akar-select-trigger-width` and `--akar-select-content-available-height` to support this. Use them to constrain the content dimensions. ```vue {21} // index.vue ``` ```css {3-4} /* styles.css */ .ASelectContent { width: var(--akar-select-trigger-width); max-height: var(--akar-select-content-available-height); } ``` ### With disabled items You can add special styles to disabled items via the `data-disabled` attribute. ```vue {23-24} // index.vue ``` ```css {2} /* styles.css */ .ASelectItem[data-disabled] { color: 'gainsboro'; } ``` ### With a placeholder You can use the `placeholder` prop on `Value` for when the select has no value. There's also a `data-placeholder` attribute on `Trigger` to help with styling. ```vue {19-20} // index.vue ``` ```css {2} /* styles.css */ .ASelectTrigger[data-placeholder] { color: 'gainsboro'; } ``` ### With separators Use the `Separator` part to add a separator between items. ```vue {10} ``` ### With grouped items Use the `Group` and `Label` parts to group items in a section. ```vue {7-8,12} ``` ### With complex items You can use custom content in your items. ```vue {23} ``` ### Controlling the value displayed in the trigger By default the trigger display the selected item's text (no longer automatically render `ItemText`'s content like in v1). If you need to render other than plain text, you can control the component using `v-model` props (or accessing `ASelectValue`'s slotProps) and passing `slot` to `ASelectValue`. Remember to make sure what you put in there is accessible. ```vue {2,4,10-12} ``` ### With custom scrollbar The native scrollbar is hidden by default as we recommend using the `ScrollUpButton` and `ScrollDownButton` parts for the best UX. If you do not want to use these parts, compose your select with our [Scroll Area](https://akar.vinicunca.dev/docs/akar/components/scroll-area) primitive. ```vue {25,27,32-34} // index.vue ``` ```css /* styles.css */ .ScrollAreaRoot { width: 100%; height: 100%; } .ScrollAreaViewport { width: 100%; height: 100%; } .ScrollAreaScrollbar { width: 4px; padding: 5px 2px; } .ScrollAreaThumb { background: rgba(0, 0, 0, 0.3); borderradius: 3px; } ``` ## Accessibility Adheres to the [ListBox WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/listbox){rel="nofollow"}. See the W3C [ASelect-Only Combobox](https://www.w3.org/TR/wai-aria-practices/examples/combobox/combobox-select-only.html){rel="nofollow"} example for more information. ### Keyboard Interactions ::docs-keyboard-table --- data: - keys: - Space description: When focus is on `ASelectTrigger`, opens the select and focuses the selected item.
When focus is on an item, selects the focused item. - keys: - Enter description: When focus is on `ASelectTrigger`, opens the select and focuses the first item.
When focus is on an item, selects the focused item. - keys: - ArrowDown description: When focus is on `ASelectTrigger`, opens the ASelect
When focus is on an item, moves focus to the next item. - keys: - ArrowUp description: When focus is on `ASelectTrigger`, opens the ASelect
When focus is on an item, moves focus to the previous item. - keys: - Esc description: Closes the select and moves focus to `ASelectTrigger`. name: keyboard-a-select --- :: ### Labelling Use our [Label](https://akar.vinicunca.dev/label) component in order to offer a visual and accessible label for the ASelect ```vue {19,22,26,28} ``` ## Custom APIs Create your own API by abstracting the primitive parts into your own component. ### Abstract down to `ASelect` and `ASelectItem` This example abstracts most of the parts. #### Usage ```vue ``` #### Implementation ```ts // your-select.ts export { default as ASelect } from 'ASelect.vue'; export { default as ASelectItem } from 'ASelectItem.vue'; ``` ```vue ``` ```vue ``` # Separator ::docs-component-example{name="a-separator"} :: ## Features ::docs-highlights --- features: - Supports horizontal and vertical orientations. --- :: ## Anatomy Import all parts and piece them together. ```vue ``` ## Pohon ::docs-akar-to-pohon --- to: https://akar.vinicunca.dev/docs/pohon/components/separator --- :: ## API Reference ### Root The separator. ::docs-component-meta{name="a-separator"} :: ::docs-data-attributes-table --- data: - attribute: "[data-orientation]" values: - vertical - horizontal --- :: ## Accessibility Adheres to the [`separator` role requirements](https://www.w3.org/TR/wai-aria-1.2/#separator){rel="nofollow"}. # Slider ::docs-component-example{name="a-slider"} :: ## Features ::docs-highlights --- features: - Can be controlled or uncontrolled. - Supports multiple thumbs. - Supports a minimum value between thumbs. - Supports touch or click on track to update value. - Supports Right to Left direction. - Full keyboard navigation. --- :: ## Anatomy Import all parts and piece them together. ```vue ``` ## Pohon ::docs-akar-to-pohon --- to: https://akar.vinicunca.dev/docs/pohon/components/slider --- :: ## API Reference ### Root Contains all the parts of a slider. It will render an `input` for each thumb when used within a `form` to ensure events propagate correctly. ::docs-component-meta{name="a-slider-root"} :: ::docs-data-attributes-table --- data: - attribute: "[data-disabled]" values: Present when disabled - attribute: "[data-orientation]" values: - vertical - horizontal --- :: ### Track The track that contains the `ASliderRange`. ::docs-component-meta{name="a-slider-track"} :: ::docs-data-attributes-table --- data: - attribute: "[data-disabled]" values: Present when disabled - attribute: "[data-orientation]" values: - vertical - horizontal --- :: ### Range The range part. Must live inside `ASliderTrack`. ::docs-component-meta{name="a-slider-range"} :: ::docs-data-attributes-table --- data: - attribute: "[data-disabled]" values: Present when disabled - attribute: "[data-orientation]" values: - vertical - horizontal --- :: ### Thumb A draggable thumb. You can render multiple thumbs. ::docs-component-meta{name="a-slider-thumb"} :: ::docs-data-attributes-table --- data: - attribute: "[data-disabled]" values: Present when disabled - attribute: "[data-orientation]" values: - vertical - horizontal --- :: ## Examples ### Vertical orientation Use the `orientation` prop to create a vertical slider. ```vue {10} // index.vue ``` ```css {7,18,26} /* styles.css */ .ASliderRoot { position: relative; display: flex; align-items: center; } .ASliderRoot[data-orientation='vertical'] { flex-direction: column; width: 20px; height: 100px; } .ASliderTrack { position: relative; flex-grow: 1; background-color: grey; } .ASliderTrack[data-orientation='vertical'] { width: 3px; } .ASliderRange { position: absolute; background-color: black; } .ASliderRange[data-orientation='vertical'] { width: 100%; } .ASliderThumb { display: block; width: 20px; height: 20px; background-color: black; } ``` ### Create a range Add multiple thumbs and values to create a range slider. ```vue {7,11-12} // index.vue ``` ### Define step size Use the `step` prop to increase the stepping interval. ```vue {9} // index.vue ``` ### Prevent thumb overlap Use `minStepsBetweenThumbs` to avoid thumbs with equal values. ```vue {10} // index.vue ``` ## Accessibility Adheres to the [ASlider WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/slidertwothumb){rel="nofollow"}. ### Keyboard Interactions ::docs-keyboard-table --- data: - keys: - ArrowRight description: Increases the value by the `step` amount. - keys: - ArrowLeft description: Decreases the value by the `step` amount. - keys: - ArrowUp description: Increases the value by the `step` amount. - keys: - ArrowDown description: Decreases the value by the `step` amount. - keys: - PageUp description: Increases the value by a larger `step`. - keys: - PageDown description: Decreases the value by a larger `step`. - keys: - Shift + ArrowUp description: Increases the value by a larger `step`. - keys: - Shift + ArrowDown description: Decreases the value by a larger `step`. - keys: - Home description: Sets the value to its minimum. - keys: - End description: Sets the value to its maximum. name: keyboard-a-slider --- :: #### Inverted sliders When the slider is `inverted`, some controls are inverted as well, depending on the `orientation`. - When the slider is `horizontal` (the default), ``, ``, ``, and `` are inverted. - When the slider is `vertical`, ``, ``, ``, ``, ``, and `` are inverted. ## Custom APIs Create your own API by abstracting the primitive parts into your own component. ### Abstract all parts This example abstracts all of the `ASlider` parts so it can be used as a self closing element. #### Usage ```vue ``` #### Implementation ```ts // your-slider.ts export { default as ASlider } from 'ASlider.vue'; ``` ```vue ``` ## Caveats ### Mouse events are not fired Because of [a limitation](https://github.com/vinicunca/akar/blob/main/packages/core/src/slider/slider-impl.vue#L48-L49){rel="nofollow"} we faced during implementation, the following example won't work as expected and the `@mousedown` and `@mousedown` event handlers won't be fired: ```vue ``` We recommend using pointer events instead (eg. `@pointerdown`, `@pointerup`). Regardless of the above limitation, these events are better suited for cross-platform/device handling as they are fired for all pointer input types (mouse, touch, pen, etc.). # Splitter ::docs-component-example{name="a-splitter"} :: ## Features ::docs-highlights --- features: - Supports keyboard interaction. - Supports horizontal/vertical layout. - Supports nested layout. - Supports Right to Left direction. - Can resize across another panel. - Can be mounted conditionally. --- :: ## Anatomy Import all parts and piece them together. ```vue ``` ## API Reference ### Group Contains all the parts of a ASplitter. ::docs-component-meta{name="a-splitter-group.md"} :: ::docs-data-attributes-table --- data: - attribute: "[data-orientation]" values: - vertical - horizontal - attribute: "[data-state]" values: - collapsed - expanded - Present when collapsible --- :: ### Panel A collapsible section. ::docs-component-meta{name="a-splitter-panel.md"} :: ### Resize Handle Handle that use for resizing. ::docs-component-meta{name="a-splitter-resize-handle.md"} :: ::docs-data-attributes-table --- data: - attribute: "[data-orientation]" values: - vertical - horizontal - attribute: "[data-state]" values: - drag - hover - inactive - attribute: "[data-disabled]" values: Present when disabled --- :: ## Examples ### Collapsible Use the `collapsible` prop to allow the panel to collapse into `collapsedSize` when `minSize` is reached. (`collapsedSize` and `minSize` props are required.) ```vue {4-6} ``` ### Persist in localStorage Use the `autoSaveId` prop to save the layout data into `localStorage`. ```vue {2} ``` ### Persist layout with SSR By default, ASplitter uses `localStorage` to persist layouts. With server rendering, this can cause a flicker when the default layout (rendered on the server) is replaced with the persisted layout (in `localStorage`). The way to avoid this flicker is to also persist the layout with a cookie like so: ```vue {3,8-9,11,15} ``` ### Collapse/Expand programmatically Sometimes panels need to resize or collapse/expand in response to user actions. `ASplitterPanel` exposes the `collapse` and `expand` methods to achieve this. ```vue {2,7,14} ``` ### Custom handle Customize the handle by passing any element as the slot. ```vue {6-8} ``` ### SSR ASplitter component heavily relies on unique `id`, however for Vue<3.4 we don't have a reliable way of generating [SSR-friendly `id`](https://github.com/vuejs/rfcs/discussions/557){rel="nofollow"}. Thus, if you are using Nuxt or other SSR framework, you are required to manually add the `id` for all ASplitter components. Alternatively, you can wrap the component with ``. ```vue ``` ## Accessibility Adheres to the [Window ASplitter WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/windowsplitter){rel="nofollow"}. ### Keyboard Interactions ::docs-keyboard-table --- data: - keys: - Enter description: If the primary pane is not collapsed, collapses the pane. If the pane is collapsed, restores the splitter to its previous position. - keys: - ArrowDown description: Moves a horizontal splitter down. - keys: - ArrowUp description: Moves a horizontal splitter up. - keys: - ArrowRight description: Moves a vertical splitter to the right. - keys: - ArrowLeft description: Moves a vertical splitter to the left. - keys: - Home description: "Moves splitter to the position that gives the primary pane its smallest allowed size. " - keys: - End description: Moves splitter to the position that gives the primary pane its largest allowed size. name: keyboard-a-accordion --- :: # Stepper ::docs-component-example{name="a-slider"} :: ## Features ::docs-highlights --- features: - Can be controlled or uncontrolled. - Supports horizontal/vertical orientation. - Supports linear/non-linear activation. - Full keyboard navigation. --- :: ## Anatomy Import all parts and piece them together. ```vue ``` ## Pohon ::docs-akar-to-pohon --- to: https://akar.vinicunca.dev/docs/pohon/components/stepper --- :: ## API Reference ### Root Contains all the stepper component parts. ::docs-component-meta{name="a-stepper-root"} :: ::docs-data-attributes-table --- data: - attribute: "[data-orientation]" values: - vertical - horizontal - attribute: "[data-linear]" values: Present when linear --- :: ### Item The step item component. ::docs-component-meta{name="a-stepper-item"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - active - inactive - completed - attribute: "[data-disabled]" values: Present when disabled - attribute: "[data-orientation]" values: - vertical - horizontal --- :: ### Trigger The trigger that toggles the step. ::docs-component-meta{name="a-stepper-trigger"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - active - inactive - completed - attribute: "[data-disabled]" values: Present when disabled - attribute: "[data-orientation]" values: - vertical - horizontal --- :: ### Indicator The indicator for the step. ::docs-component-meta{name="a-stepper-indicator"} :: ### Title An accessible title to be announced when the stepper trigger is focused. If you want to hide the title, wrap it inside our Visually Hidden utility like this ``. ::docs-component-meta{name="a-stepper-title"} :: ### Description An optional accessible description to be announced when the stepper trigger is focused. If you want to hide the description, wrap it inside our Visually Hidden utility like this ``. If you want to remove the description entirely, remove this part and pass `aria-describedby="undefined"` to `AStepperTrigger`. ::docs-component-meta{name="a-stepper-item"} :: ## Examples ### Vertical You can create vertical steps by using the `orientation` prop. ```vue {8} ``` ### With controls You can add additional controls for the stepper using buttons and access the typed component instance using `useTemplateRef`. ```vue {8} ``` ## Accessibility ### Keyboard Interactions ::docs-keyboard-table --- data: - keys: - Tab description: When focus moves onto the steps, focuses the first step - keys: - ArrowDown description: Moves focus to the next step depending on `orientation` - keys: - ArrowRight description: Moves focus to the next step depending on `orientation` - keys: - ArrowUp description: Moves focus to the previous step depending on `orientation` - keys: - ArrowLeft description: Moves focus to the previous step depending on `orientation` - keys: - Enter - Space description: Selects the focused step. name: keyboard-a-stepper --- :: # Switch ::docs-component-example{name="a-switch"} :: ## Features ::docs-highlights --- features: - Full keyboard navigation. - Can be controlled or uncontrolled. --- :: ## Anatomy Import all parts and piece them together. ```vue ``` ## Pohon ::docs-akar-to-pohon --- to: https://akar.vinicunca.dev/docs/pohon/components/switch --- :: ## API Reference ### Root Contains all the parts of a switch. An `input` will also render when used within a `form` to ensure events propagate correctly. ::docs-component-meta{name="a-switch-root"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - checked - unchecked - attribute: "[data-disabled]" values: Present when disabled --- :: ### Thumb The thumb that is used to visually indicate whether the switch is on or off. ::docs-component-meta{name="a-switch-thumb"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - checked - unchecked - attribute: "[data-disabled]" values: Present when disabled --- :: ## Accessibility Adheres to the [`switch` role requirements](https://www.w3.org/WAI/ARIA/apg/patterns/switch){rel="nofollow"}. ### Keyboard Interactions ::docs-keyboard-table --- data: - keys: - Space description: Toggles the component's state. - keys: - Enter description: Toggles the component's state. name: keyboard-a-switch --- :: # Tabs ::docs-component-example{name="a-tabs"} :: ## Features ::docs-highlights --- features: - Can be controlled or uncontrolled. - Supports horizontal/vertical orientation. - Supports automatic/manual activation. - Full keyboard navigation. --- :: ## Anatomy Import all parts and piece them together. ```vue ``` ## Pohon ::docs-akar-to-pohon{to="https://akar.vinicunca.dev/docs/pohon/components/tabs"} :: ## API Reference ### Root Contains all the tabs component parts. ::docs-component-meta{name="a-tabs-root"} :: ::docs-data-attributes-table --- data: - attribute: "[data-orientation]" values: - vertical - horizontal --- :: ### List Contains the triggers that are aligned along the edge of the active content. ::docs-component-meta{name="a-tabs-list"} :: ::docs-data-attributes-table --- data: - attribute: "[data-orientation]" values: - vertical - horizontal --- :: ### Trigger The button that activates its associated content. ::docs-component-meta{name="a-tabs-trigger"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - active - inactive - attribute: "[data-disabled]" values: Present when disabled - attribute: "[data-orientation]" values: - vertical - horizontal --- :: ### Indicator The indicator that highlights the current active tab. ::docs-component-meta{name="a-tabs-indicator"} :: ::docs-css-variables-table --- data: - cssVariable: --akar-tabs-indicator-size description: The size of the indicator - cssVariable: --akar-tabs-indicator-position description: The position of the indicator --- :: ### Content Contains the content associated with each trigger. ::docs-presence-tip :: ::docs-component-meta{name="a-tabs-content"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - active - inactive - attribute: "[data-orientation]" values: - vertical - horizontal --- :: ## Examples ### Vertical You can create vertical tabs by using the `orientation` prop. ```vue {8} ``` ## Accessibility Adheres to the [ATabs WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/tabpanel){rel="nofollow"}. ### Keyboard Interactions ::docs-keyboard-table --- data: - keys: - Tab description: When focus moves onto the tabs, focuses the active trigger. When a trigger is focused, moves focus to the active content. - keys: - ArrowDown description: Moves focus to the next trigger depending on `orientation` and activates its associated content. - keys: - ArrowRight description: Moves focus to the next trigger depending on `orientation` and activates its associated content. - keys: - ArrowUp description: Moves focus to the previous trigger depending on `orientation` and activates its associated content. - keys: - ArrowLeft description: Moves focus to the previous trigger depending on `orientation` and activates its associated content. - keys: - Home description: Moves focus to the first trigger and activates its associated content. - keys: - End description: Moves focus to the last trigger and activates its associated content. name: keyboard-a-tabs --- :: # Tags Input ::docs-component-example{name="a-tags-input"} :: ## Features ::docs-highlights --- features: - Can be controlled or uncontrolled. - Full keyboard navigation. - Limit the number of tags. - Accept value from clipboard. - Clear button to reset all tags values. --- :: ## Anatomy Import all parts and piece them together. ```vue ``` ## Pohon ::docs-akar-to-pohon --- to: https://akar.vinicunca.dev/docs/pohon/components/input-tags --- :: ## API Reference ### Root Contains all the tags input component parts. ::docs-component-meta{name="a-tags-input-root"} :: ::docs-data-attributes-table --- data: - attribute: "[data-disabled]" values: Present when disabled - attribute: "[data-focused]" values: Present when focus on input - attribute: "[data-invalid]" values: Present when input value is invalid --- :: ### Item The component that contains the tag. ::docs-component-meta{name="a-tags-input-item"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - active - inactive - attribute: "[data-disabled]" values: Present when disabled --- :: ### ItemText The textual part of the tag. Important for accessibility. ::docs-component-meta{name="a-tags-input-item-text"} :: ### ItemDelete The button that delete the associate tag. ::docs-component-meta{name="a-tags-input-item-delete"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - active - inactive - attribute: "[data-disabled]" values: Present when disabled --- :: ### Input The input element for the tags input. ::docs-component-meta{name="a-tags-input-input"} :: ::docs-data-attributes-table --- data: - attribute: "[data-invalid]" values: Present when input value is invalid --- :: ### Clear The button that remove all tags. ::docs-component-meta{name="a-tags-input-clear"} :: ::docs-data-attributes-table --- data: - attribute: "[data-disabled]" values: Present when disabled --- :: ## Examples ### Paste behavior You can automatically add tags on paste by passing the `add-on-paste` prop. ```vue {8} ``` ### Multiple delimiters You can pass `RegExp` as `delimiter` to allow multiple characters to trigger addition of a new tag. When `add-on-paste` is passed it will be also used to split tags for `@paste` event. ```vue {4-5,11} ``` ## Accessibility ### Keyboard Interactions ::docs-keyboard-table --- data: - keys: - Delete description: When tag is active, remove it and set the tag on right active. - keys: - Backspace description: When tag is active, remove it and set the tag on left active. If there are no tags to the left, either the next tags gets focus, or the input. - keys: - ArrowRight description: Set the next tag active. - keys: - ArrowLeft description: Set the previous tag active. - keys: - Home description: Set the first tag active. - keys: - End description: Set the last tag active. name: keyboard-a-switch --- :: # Time Field ::docs-component-example{name="a-time-field"} :: ## Features ::docs-highlights --- features: - Full keyboard navigation. - Can be controlled or uncontrolled. - Focus is fully managed. - Localization support. - Highly composable. - Accessible by default. --- :: ## Preface The component depends on the [@internationalized/date](https://react-spectrum.adobe.com/internationalized/date/index.html){rel="nofollow"} package, which solves a lot of the problems that come with working with dates and times in JavaScript. We highly recommend reading through the documentation for the package to get a solid feel for how it works, and you'll need to install it in your project to use the date-related components. ## Installation Install the date package. ::code-group{sync="pm"} ```bash [pnpm] pnpm add @internationalized/date ``` ```bash [npm] npm install @internationalized/date ``` ```bash [bun] bun add @internationalized/date ``` :: ## Anatomy Import all parts and piece them together. ```vue ``` ## Pohon ::docs-akar-to-pohon --- to: https://akar.vinicunca.dev/docs/pohon/components/input-time --- :: ## API Reference ### Root Contains all the parts of a time field ::docs-component-meta{name="a-time-field-root"} :: ::data-attributes-table --- data: - attribute: "[data-readonly]" values: Present when readonly - attribute: "[data-disabled]" values: Present when disabled - attribute: "[data-invalid]" values: Present when invalid --- :: ### Input Contains the time field segments ::docs-component-meta{name="a-time-field-input"} :: ::docs-data-attributes-table --- data: - attribute: "[data-disabled]" values: Present when disabled - attribute: "[data-invalid]" values: Present when invalid - attribute: "[data-placeholder]" values: Present when no value is set --- :: ## Accessibility ### Keyboard Interactions ::docs-keyboard-table --- data: - keys: - Tab description: When focus moves onto the time field, focuses the first segment. - keys: - ArrowLeft - ArrowRight description: Navigates between the time field segments. - keys: - ArrowUp - ArrowDown description: Increments/changes the value of the segment. - keys: - 0-9 description: When the focus is on a numeric `ATimeFieldInput`, it types in number and focuses the next segment if the next input would result in an invalid value. - keys: - Backspace description: Deletes a digit from the focused numeric segments. - keys: - A - P description: When the focus is on the day period, it sets it to AM or PM. name: keyboard-a-time-field --- :: # Toast ::docs-component-example{name="a-toast"} :: ## Features ::docs-highlights --- features: - Automatically closes. - Pauses closing on hover, focus and window blur. - Supports hotkey to jump to toast viewport. - Supports closing via swipe gesture. - Exposes CSS variables for swipe gesture animations. - Can be controlled or uncontrolled. --- :: ## Anatomy Import the component. ```vue ``` ## Pohon ::docs-akar-to-pohon --- to: https://akar.vinicunca.dev/docs/pohon/components/toast --- :: ## API Reference ### Provider The provider that wraps your toasts and toast viewport. It usually wraps the application. ::docs-component-meta{name="a-toast-provider"} :: ### Viewport The fixed area where toasts appear. Users can jump to the viewport by pressing a hotkey. It is up to you to ensure the discoverability of the hotkey for keyboard users. ::docs-component-meta{name="a-toast-viewport"} :: ### Root The toast that automatically closes. It should not be held open to [acquire a user response](https://akar.vinicunca.dev/docs/akar/components/toast#action). ::docs-presence-tip :: ::docs-component-meta{name="a-toast-root"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - open - closed - attribute: "[data-swipe-direction]" values: - up - down - left - right - attribute: "[data-swipe]" values: - start - move - cancel - end --- :: ::docs-css-variables-table --- data: - cssVariable: --akar-toast-swipe-move-x description: The offset position of the toast when horizontally swiping - cssVariable: --akar-toast-swipe-move-y description: The offset position of the toast when vertically swiping - cssVariable: --akar-toast-swipe-end-x description: The offset end position of the toast after horizontally swiping - cssVariable: --akar-toast-swipe-end-y description: The offset end position of the toast after vertically swiping --- :: ### Portal When used, portals the content part into the `body`. ::docs-component-meta{name="a-toast-portal"} :: ### Title An optional title for the toast ::docs-component-meta{name="a-toast-title"} :: ### Description The toast message. ::docs-component-meta{name="a-toast-description"} :: ### Action An action that is safe to ignore to ensure users are not expected to complete tasks with unexpected side effects as a result of a [time limit](https://www.w3.org/TR/UNDERSTANDING-WCAG20/time-limits-required-behaviors.html){rel="nofollow"}. When obtaining a user response is necessary, portal an ["AlertDialog"](https://akar.vinicunca.dev/docs/akar/components/alert-dialog) styled as a toast into the viewport instead. ::docs-component-meta{name="a-toast-action"} :: ### Close A button that allows users to dismiss the toast before its duration has elapsed. ::docs-component-meta{name="a-toast-close"} :: ## Examples ### Custom hotkey Override the default hotkey using the `event.code` value for each key from [keycode.info](https://keycode.info/){rel="nofollow"}. ```vue {4} ``` ### Custom duration Customise the duration of a toast to override the provider value. ```vue {2} ``` ### Duplicate toasts When a toast must appear every time a user clicks a button, use state to render multiple instances of the same toast (see below). Alternatively, you can abstract the parts to create your own [imperative API](https://akar.vinicunca.dev/docs/akar/components/toast#imperative-api). ```vue {3,8} ``` ### Animating swipe gesture Combine `--akar-toast-swipe-move-[x|y]` and `--akar-toast-swipe-end-[x|y]` CSS variables with `data-swipe="[start|move|cancel|end]"` attributes to animate a swipe to close gesture. Here's an example: ```vue {2} ``` ```css {2-3,5,9,15} /* styles.css */ .AToastRoot[data-swipe='move'] { transform: translateX(var(--akar-toast-swipe-move-x)); } .AToastRoot[data-swipe='cancel'] { transform: translateX(0); transition: transform 200ms ease-out; } .AToastRoot[data-swipe='end'] { animation: slideRight 100ms ease-out; } @keyframes slideRight { from { transform: translateX(var(--akar-toast-swipe-end-x)); } to { transform: translateX(100%); } } ``` ## Accessibility Adheres to the [`aria-live` requirements](https://www.w3.org/TR/wai-aria/#aria-live){rel="nofollow"}. ### Sensitivity Control the sensitivity of the toast for screen readers using the `type` prop. For toasts that are the result of a user action, choose `foreground`. AToasts generated from background tasks should use `background`. #### Foreground Foreground toasts are announced immediately. Assistive technologies may choose to clear previously queued messages when a foreground toast appears. Try to avoid stacking distinct foreground toasts at the same time. #### Background Background toasts are announced at the next graceful opportunity, for example, when the screen reader has finished reading its current sentence. They do not clear queued messages so overusing them can be perceived as a laggy user experience for screen reader users when used in response to a user interaction. ```vue {2,7} ``` ### Alternative action Use the `altText` prop on the `Action` to instruct an alternative way of actioning the toast to screen reader users. You can direct the user to a permanent place in your application where they can action it or implement your own custom hotkey logic. If implementing the latter, use `foreground` type to announce immediately and increase the duration to give the user ample time. ```vue {5,11,13} ``` ### Close icon button When providing an icon (or font icon), remember to label it correctly for screen reader users. ```vue {4-5} ``` ### Keyboard Interactions ::docs-keyboard-table --- data: - keys: - F8 description: Focuses toasts viewport. - keys: - Tab description: Moves focus to the next focusable element. - keys: - Shift + Tab description: Moves focus to the previous focusable element. - keys: - Space description: When focus is on a `AToastAction` or `AToastClose`, closes the toast. - keys: - Enter description: When focus is on a `AToastAction` or `AToastClose`, closes the toast. - keys: - Esc description: When focus is on a `AToast`, closes the toast. name: keyboard-a-toast --- :: ## Custom APIs ### Abstract parts Create your own API by abstracting the primitive parts into your own component. #### Usage ```vue ``` #### Implementation ```vue // your-toast.vue ``` ### Imperative API Create your own imperative API to allow [toast duplication](https://akar.vinicunca.dev/docs/akar/components/toast#duplicate-toasts) if preferred. #### Usage ```vue ``` #### Implementation ```vue // your-toast.vue ``` # Toggle ::docs-component-example{name="a-toggle"} :: ## Features ::docs-highlights --- features: - Full keyboard navigation. - Can be controlled or uncontrolled. --- :: ## Anatomy Import the component. ```vue ``` ## API Reference ### Root The toggle. ::docs-component-meta{name="a-toggle"} :: ::docs-data-attribute-table --- data: - attribute: "[data-state]" values: - on - off - attribute: "[data-disabled]" values: Present when disabled --- :: ## Accessibility ### Keyboard Interactions ::docs-keyboard-table --- data: - keys: - Space description: Activates/deactivates the toggle. - keys: - Enter description: Activates/deactivates the toggle. name: keyboard-a-toggle --- :: # Toggle Group ::docs-component-example{name="a-toggle-group"} :: ## Features ::docs-highlights --- features: - Full keyboard navigation. - Supports horizontal/vertical orientation. - Support single and multiple pressed buttons. - Can be controlled or uncontrolled. --- :: ## Anatomy Import the component. ```vue ``` ## API Reference ### Root Contains all the parts of a toggle group. ::docs-component-meta{name="a-toggle-group-root"} :: ::docs-data-attribute-table --- data: - attribute: "[data-orientation]" values: - vertical - horizontal --- :: ### Item An item in the group. ::docs-component-meta{name="a-toggle-group-item"} :: ::docs-data-attribute-table --- data: - attribute: "[data-state]" values: - on - off - attribute: "[data-disabled]" values: Present when disabled - attribute: "[data-orientation]" values: - vertical - horizontal --- :: ## Examples ### Ensuring there is always a value You can control the component to ensure a value. ```vue {5,10-13} ``` ## Accessibility Uses [roving tabindex](https://www.w3.org/TR/wai-aria-practices-1.2/examples/radio/radio.html){rel="nofollow"} to manage focus movement among items. ### Keyboard Interactions ::docs-keyboard-table --- data: - keys: - Tab description: Moves focus to either the pressed item or the first item in the group. - keys: - Space description: Activates/deactivates the item. - keys: - Enter description: Activates/deactivates the item. - keys: - ArrowDown description: Moves focus to the next item in the group. - keys: - ArrowRight description: Moves focus to the next item in the group. - keys: - ArrowUp description: Moves focus to the previous item in the group. - keys: - ArrowLeft description: Moves focus to the previous item in the group. - keys: - Home description: Moves focus to the first item. - keys: - End description: Moves focus to the last item. name: keyboard-a-toggle-group --- :: # Tooltip ::docs-component-example{name="a-tooltip"} :: ## Features ::docs-highlights --- features: - Provider to control display delay globally. - Opens when the trigger is focused or hovered. - Closes when the trigger is activated or when pressing escape. - Supports custom timings. --- :: ## Anatomy Import all parts and piece them together. ```vue ``` ## Pohon ::docs-akar-to-pohon --- to: https://akar.vinicunca.dev/docs/pohon/components/tooltip --- :: ## API Reference ### Provider Wraps your app to provide global functionality to your tooltips. ::docs-component-meta{name="a-tooltip-provider"} :: ### Root Contains all the parts of a tooltip. ::docs-component-meta{name="a-tooltip-root"} :: ### Trigger The button that toggles the tooltip. By default, the `ATooltipContent` will position itself against the trigger. ::docs-component-meta{name="a-tooltip-trigger"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - closed - delayed-open - instant-open --- :: ### Portal When used, portals the content part into the `body`. ::docs-component-meta{name="a-tooltip-portal"} :: ### Content The component that pops out when the tooltip is open. ::docs-presence-tip :: ::docs-component-meta{name="a-tooltip-content"} :: ::docs-data-attributes-table --- data: - attribute: "[data-state]" values: - closed - delayed-open - instant-open - attribute: "[data-side]" values: - left - right - bottom - top - attribute: "[data-align]" values: - start - end - center --- :: ::docs-css-variables-table --- data: - cssVariable: --akar-tooltip-content-transform-origin description: The `transform-origin` computed from the content and arrow positions/offsets - cssVariable: --akar-tooltip-content-available-width description: The remaining width between the trigger and the boundary edge - cssVariable: --akar-tooltip-content-available-height description: The remaining height between the trigger and the boundary edge - cssVariable: --akar-tooltip-trigger-width description: The width of the trigger - cssVariable: --akar-tooltip-trigger-height description: The height of the trigger --- :: ### Arrow An optional arrow element to render alongside the tooltip. This can be used to help visually link the trigger with the `ATooltipContent`. Must be rendered inside `ATooltipContent`. ::docs-component-meta{name="a-tooltip-arrow"} :: ## Examples ### Configure globally Use the `Provider` to control `delayDuration` and `skipDelayDuration` globally. ```vue {7-8} ``` ### Show instantly Use the `delayDuration` prop to control the time it takes for the tooltip to open. ```vue {6} ``` ### Displaying a tooltip from a disabled button Since disabled buttons don't fire events, you need to: - Render the `Trigger` as `span`. - Ensure the `button` has no `pointerEvents`. ```vue {7-11} ``` ### Constrain the content size You may want to constrain the width of the content so that it matches the trigger width. You may also want to constrain its height to not exceed the viewport. We expose several CSS custom properties such as `--akar-tooltip-trigger-width` and `--akar-tooltip-content-available-height` to support this. Use them to constrain the content dimensions. ```vue {10} ``` ```css {3-4} /* styles.css */ .ATooltipContent { width: var(--akar-tooltip-trigger-width); max-height: var(--akar-tooltip-content-available-height); } ``` ### Origin-aware animations We expose a CSS custom property `--akar-tooltip-content-transform-origin`. Use it to animate the content from its computed origin based on `side`, `sideOffset`, `align`, `alignOffset` and any collisions. ```vue {8} ``` ```css {3-4} /* styles.css */ .ATooltipContent { transform-origin: var(--akar-tooltip-content-transform-origin); animation: scaleIn 0.5s ease-out; } @keyframes scaleIn { from { opacity: 0; transform: scale(0); } to { opacity: 1; transform: scale(1); } } ``` ### Collision-aware animations We expose `data-side` and `data-align` attributes. Their values will change at runtime to reflect collisions. Use them to create collision and direction-aware animations. ```vue {8} ``` ```css {6,9} /* styles.css */ .ATooltipContent { animation-duration: 0.6s; animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1); } .ATooltipContent[data-side='top'] { animation-name: slideUp; } .ATooltipContent[data-side='bottom'] { animation-name: slideDown; } @keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } } @keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } } ``` ## Accessibility ### Keyboard Interactions ::docs-keyboard-table --- data: - keys: - Tab description: Opens/closes the tooltip without delay. - keys: - Space description: If open, closes the tooltip without delay. - keys: - Enter description: If open, closes the tooltip without delay. - keys: - Escape description: If open, closes the tooltip without delay. name: keyboard-a-tooltip --- :: ## Custom APIs Create your own API by abstracting the primitive parts into your own component. ### Abstract parts and introduce a content prop This example abstracts all of the `ATooltip` parts and introduces a new `content` prop. #### Usage ```vue ``` #### Implementation Use the [`asChild` prop](https://akar.vinicunca.dev/docs/akar/guides/composition) to convert the trigger part into a slottable area. It will replace the trigger with the child that gets passed to it. ```vue {13-15} ``` # Tree ::docs-component-example{name="a-tree"} :: ## Features ::docs-highlights --- features: - Can be controlled or uncontrolled. - Focus is fully managed. - Full keyboard navigation. - Supports Right to Left direction. - Supports multiple selection. - Different selection behavior. --- :: ## Anatomy Import all parts and piece them together. ```vue ``` ## Pohon ::docs-akar-to-pohon{to="https://akar.vinicunca.dev/docs/pohon/components/tree"} :: ## API Reference ### Root Contains all the parts of a tree. ::docs-component-meta{name="a-tree-root"} :: ### Item The item component. ::docs-component-meta{name="a-tree-item"} :: ::docs-data-attributes-table --- data: - attribute: "[data-indent]" values: Number - attribute: "[data-expanded]" values: Present when expanded - attribute: "[data-selected]" values: Present when selected --- :: ### Virtualizer Virtual container to achieve list virtualization. ::docs-component-meta{name="a-tree-virtualizer"} :: ## Examples ### Selecting multiple items The `ATree` component allows you to select multiple items. You can enable this by providing an array of values instead of a single value and set `multiple="true"`. ```vue {12,17-18} ``` ### Virtual List Rendering a long list of item can slow down the app, thus using virtualization would significantly improve the performance. See the [virtualization guide](https://akar.vinicunca.dev/docs/akar/guides/virtualization.md) for more general info on virtualization. ```vue {8-15} ``` ### With Checkbox Some `ATree` component might want to show `toggled/indeterminate` checkbox. We can change the behavior of the `ATree` component by using a few props and `preventDefault` event. We set `propagateSelect` to `true` because we want the parent checkbox to select/deselect it's descendants. Then, we add a checkbox that triggers `select` event. ```vue {10-11,17-25,27-30} ``` ### Nested ATree Node The default example shows flatten tree items and nodes, this enables [Virtualization](https://akar.vinicunca.dev/docs/akar/components/tree.html#virtual-list) and custom feature such as Drag & Drop easier. However, you can also build it to have nested DOM node. In `ATree.vue`, ```vue ``` In `CustomATree.vue` ```vue ``` ### Custom children schema By default, `` expects you to provide the list of node's children by passing a list of `children` for every node. You can override that by providing the `getChildren` prop. ::note If the node doesn't have any children, `getChildren` should return `undefined` instead of an empty array. :: ```vue {22} ``` ### Draggable/Sortable ATree For more complex draggable `ATree` component, in this example we will be using [pragmatic-drag-and-drop](https://github.com/atlassian/pragmatic-drag-and-drop){rel="nofollow"}, as the core package for handling dnd. ## Accessibility Adheres to the [ATree WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/treeview/){rel="nofollow"}. ### Keyboard Interactions ::docs-keyboard-table --- data: - keys: - Enter - Space description: When highlight on ATreeItem, selects the focused item. - keys: - ArrowDown description: When focus is on ATreeItem, moves focus to the next item. - keys: - ArrowUp description: When focus is on ATreeItem, moves focus to the previous item. - keys: - ArrowRight description: When focus is on a closed ATreeItem (node), it opens the node without moving focus. When on an open node, it moves focus to the first child node. When on an end node, it does nothing. - keys: - ArrowLeft description: When focus is on an open ATreeItem (node), closes the node. When focus is on a child node that is also either an end node or a closed node, moves focus to its parent node. When focus is on a root node that is also either an end node or a closed node, does nothing. - keys: - Home - PageUp description: Moves focus first ATreeItem - keys: - End - PageDown description: Moves focus last ATreeItem name: keyboard-a-tree --- :: # Config Provider ::docs-highlights --- features: - Enables all primitives to inherit global reading direction. - Enables changing the behavior of scroll body when setting body lock. - Much more controls to prevent layout shifts. --- :: ## Anatomy Import the component. ```vue ``` ## API Reference ### Config Provider When creating localized apps that require right-to-left (RTL) reading direction, you need to wrap your application with the `AConfigProvider` component to ensure all of the primitives adjust their behavior based on the `dir` prop. You can also change the global behavior of `bodylock` for components such as `AAlert`, `ADropdownMenu` and etc to fit your layout to prevent any content shifts. ::docs-component-meta{name="a-config-provider"} :: ## Example Use the config provider. Set global direction to `rtl`, and scroll body behavior to `false` (will not set any padding/margin). ```vue ``` # Focus Scope Focus Scope provides enhanced control over keyboard focus management within component boundaries. It can trap focus within its container and optionally loop focus navigation, making it ideal for modal interfaces and other interactive components that need to manage focus states. ## API Reference ::docs-component-meta{name="a-focus-scope"} :: ## Example Basic usage with focus trapping ```vue {2} ``` ### With Focus Looping Enable both trapping and looping for complete focus management: ```vue {2} ``` ### Handling Focus Event ```vue {2-5} ``` :br ::warning When using trapped mode, ensure there is always at least one focusable element within the scope to prevent focus from being trapped in an inaccessible state. :: # Presence ::note The difference between this component from [Vue Transition](https://vuejs.org/guide/built-ins/transition.html#transition){rel="nofollow"} is it accepts css animation, and control the visibility of element. :: Presence component provides enhanced control over element mounting/unmounting. It ensures animations and transitions complete before removing elements from the DOM, making it perfect for animated UI components. ## API Reference ::docs-props-table --- meta-props: - name: present description:

Conditional to mount or unmount the child element. Similar to v-if

type: boolean required: true - name: forceMount description:

Force the element to render all the time.\n\nUseful for programmatically render grandchild component with the exposed present

type: boolean required: false default: false --- :: ::docs-emits-table --- meta-events: - name: enter description:

Event handler called when the enter animation has started

type: CustomEvent - name: after-enter description:

Event handler called when the enter animation has finished

type: CustomEvent - name: leave description:

Event handler called when the leave animation has started

type: CustomEvent - name: after-leave description:

Event handler called when the leave animation has finished

type: CustomEvent --- :: ::tip Read our [Animation Guide](https://akar.vinicunca.dev/docs/akar/guides/animation) to learn more about implementing animations with Presence component. :: ## Example ```vue {2,4-5} ``` ### Force Mount When you need to ensure content is always rendered regardless of the present state: ```vue ``` # Primitive ::description Compose Akar's functionality onto alternative element types or your own Vue components. :: When you are building a component, in some cases you might want to allow user to compose some functionalities onto the underlying element, or alternative element. This is where `Primitive` comes in handy as it expose this capability to the user. ## API Reference ::docs-props-table --- meta-props: - name: as description: The element or component the current element should render as. Can be overwrite by `asChild` type: string | Component required: false default: div - name: asChild description: Change the default rendered element for the one passed as a child, merging their props and behavior.

Read our [Composition](/docs/akar/guides/composition) guide for more details. type: boolean required: false default: false --- :: ## Usage ### Changing `as` value If you want to change the default element or component being render, you can set the default `as` when defining the props. ```vue ``` ### Render `asChild` Change the default rendered element for the one passed as a child, merging their props and behavior. :br:br Read our [Composition](https://akar.vinicunca.dev/docs/akar/guides/composition) guide for more details. # Roving Focus ::docs-component-example{name="a-roving-focus"} :: ::note Learn more about roving tabindex in [Keyboard Navigation Inside Composite Components](https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#x6-6-keyboard-navigation-inside-components){rel="nofollow"} :: ## Anatomy Import all parts and piece them together. ```vue ``` ## API Reference ### Group Contains all the parts of a Roving Focus ::docs-component-meta{name="a-roving-focus-group"} :: ::docs-data-attributes-table --- data: - attribute: "[data-orientation]" values: - vertical - horizontal - undefined --- :: ### Item The item that would inherit the roving tabindex ::docs-component-meta{name="a-roving-focus-item"} :: ::docs-data-attributes-table --- data: - attribute: "[data-active]" values: Present when not active - attribute: "[data-disabled]" values: Present when not focusable - attribute: "[data-orientation]" values: - vertical - horizontal - undefined --- :: ## Examples ### Vertical orientation ```vue {2} ``` ### Loop Use `loop` property to enable roving from last item to the first item, and vice versa. ```vue {2} ``` ### Initial focus item Set `active` prop to item to initially focused item. ```vue {4} ``` ### Unfocusable item Set `focusable="false"` prop to item will prevent them from being focused. ```vue {4} ``` ## Accessibility Adheres to the [Keyboard Navigation Inside Composite Components](https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#x6-6-keyboard-navigation-inside-components){rel="nofollow"}. ### Keyboard Interactions ::docs-keyboard-table --- data: - keys: - ArrowDown description: Moves focus to the next roving focus item in the group. - keys: - ArrowRight description: Moves focus to the next roving focus item in the group. - keys: - ArrowUp description: Moves focus to the previous roving focus item in the group. - keys: - ArrowLeft description: Moves focus to the previous roving focus item in the group. - keys: - Space - Enter description: Triggers click on the roving focus item. name: keyboard-a-checkbox --- :: # Slot ::note The different between this component from [Vue native slot](https://vuejs.org/guide/components/slots.html){rel="nofollow"} is how it handles the `attributes` assigned to it. :: Native slot treat any binded value as [Scoped Slots](https://vuejs.org/guide/components/slots.html#scoped-slots){rel="nofollow"}, where the values will be exposed to the parent template and be consumed. But Akar's slot behave differently, it would merge all the assigned attributes onto it's immediate child. ## Example Say we want to assign an `id` attribute to whatever component/element that was rendered, but Native slot will convert it into a scoped slot, and you will need to assign that id manually. ```vue