# OVERVIEW --- # Introduction ## Motivation Most popular UI component libraries are designed to work with a specific JavaScript framework. Building UI components that work across different JavaScript frameworks presents significant challenges for organizations working with diverse technology stacks. ## Solution Ark UI provides components for building complex, interactive, and accessible user interfaces across multiple JavaScript frameworks. To achieve this, Ark UI is built on top of [Zag.js](https://zagjs.com), a UI component library powered by Finite State Machines. Check out the architecture diagram below for a high-level overview. # Getting Started ## Quickstart Running tight on schedule? No worries! Check out our quickstart examples to get started with Ark UI in seconds. - [Next.js Template](https://stackblitz.com/edit/github-qcm2dskf) - [Solid Start Template](https://stackblitz.com/edit/github-1hgkbbln) - [Nuxt Template](https://stackblitz.com/edit/github-s3sg6syq) ## Setup Guide Before you start, ensure you have a proper project setup. If not, follow your preferred application framework setup guide and then return to this guide. Install the Ark UI dependency using your preferred package manager. ```bash npm install @ark-ui/vue // or pnpm install @ark-ui/vue // or yarn add @ark-ui/vue // or bun add @ark-ui/vue ``` In this guide, we will be adding a Slider component. Copy the following code to your project. ```vue ``` Ark UI is a headless component library that doesn't include default styles. You can leverage the `data-scope` and `data-part` attributes to style your components with custom CSS. For example, to style a slider component, you can target its parts using these attributes: ```css /* Targets the */ [data-scope='slider'][data-part='root'] { display: flex; flex-direction: column; } ``` Check out the [Styling Components guide](/react/docs/guides/styling) to learn more about styling components in Ark UI. Congratulations! You've successfully set up and styled your components using Ark UI. If you run into any issues or have questions, open an issue on our [GitHub](https://github.com/chakra-ui/ark/issues/new/choose) or reach out on [Discord](https://discord.gg/ww6HE5xaZ2). Happy hacking! ✌️ # Changelog ## [Unreleased] ## [5.2.0] - 2025-03-22 ### Added - **[NEW] DownloadTrigger**: Added Component for downloading a blob or file, whether retrieved synchronously or asynchronously. ```tsx import { DownloadTrigger } from '@ark-ui/react/download-trigger' export const DownloadImage = () => { async function fetchImage() { const response = await fetch('https://picsum.photos/200/300') return response.blob() } return ( Download Image ) } ``` ### Changed - **NumberInput**: Set the default step to `0.01` when `formatOptions.style` was set to `percent`. - **[Breaking] Splitter**: Redesigned splitter machine to support more use cases and improve DX. Check out the [Splitter](https://ark-ui.com/react/docs/components/splitter) documentation for more details. ### Fixed - **Toast**: Fixed issue where setting `offsets` to `undefined` caused the machine to throw. - **Select**: Fixed issue where select `valueAsString` lost reactivity. ## [5.1.0] - 2025-03-17 ### Added - Added support for a cleanup function in `ref`. ### Fixed - **Field**: Exported the missing `useField` hook. - **NumberInput**: `onValueChange` correctly received `valueAsNumber`. - **Slider**: Thumbs initialized correctly when `min` was set to a non-zero value. ## [5.0.1] - 2025-03-11 ### Fixed - Effects now flush synchronously instead of using a microtask. - **Checkbox**: `data-invalid` is no longer set when `invalid` is `false`. - **Combobox**: Fixed unexpected cursor movement when editing input. - **PinInput**: OTP SMS autofill now works as expected. - **RatingGroup**: Fixed incorrect focus placement on the label. - **TagsInput**: Improved caret detection to prevent unintended tag removal. - **Timer** - Fixed slowdown when switching tabs/windows. - Changed default `interval` from `250` to `1000`. ## [5.0.0] - 2025-03-06 Ark UI just got a major performance boost! 🚀 ### What’s new in v5? - **Blazing-fast performance** – Every component runs smoother and renders faster. - **Smaller bundle size** – Leaner components and adapters for a more efficient build. We made this happen by using React’s native reactive primitives instead of external stores. In our stress tests with **10,000 components**, Ark v5 delivered **1.5x–4x** better performance across the board. ![Performance comparison showing Ark v5 is 1.5x-4x faster than other libraries](./v5.svg) ### A quick note on tests Most component updates are non-breaking, but due to this change, some tests may need adjustments. For example: ```jsx // Before it('should open by default', () => { render() expect(screen.getByRole('dialog')).toBeInTheDocument() }) // After it('should open by default', async () => { render() expect(await screen.findByRole('dialog')).toBeInTheDocument() }) ``` #### Added - **Carousel**: ⚠️ Breaking change: Added required prop `slideCount` to `Carousel.Root` component. - **Clipboard**: Added `onValueChange` and `defaultValue` props. - **ColorPicker**: Added `defaultFormat` prop. - **Combobox**: Added `defaultHighlightedValue` and `defaultInputValue` props. - **DatePicker**: Added `defaultFocusedValue` prop, `getViewProps`, and `visibleRangeText`. - **HoverCard**: Expanded interaction handlers. - **Menu**: Added `defaultHighlightedValue` prop. - **Pagination**: Added `defaultPageSize` prop. - **PinInput**: Added `count` prop for better SSR aria-label. - **Progress**: Added `locale` and `formatOptions` props. - **QrCode**: Added `pixelSize` prop. - **Select**: Added `defaultHighlightedValue` prop. - **TagsInput**: Added `defaultInputValue` prop. - **Toggle**: Reintroduced toggle machine. #### Fixed - **Accordion**: Fixed issue in Safari where clicking triggers didn't show content. - **Avatar**: Fixed `api.setSrc` not working. - **Carousel**: Fixed pagination sync and initial page issues. - **File Upload**: Fixed drag-and-drop when `directory: true`. - **Menu**: Fixed context menu positioning not updating on right-click. - **Number Input**: Fixed `value` prop not being consumed. - **Pin Input**: Fixed focus warnings and editing issues. - **Progress**: Allowed more precise (decimal) values. - **Radio Group, Switch**: Improved focus behavior in Safari. - **Select**: Fixed regression where `multiple: true` didn't work. - **Steps**: Ensured ARIA attributes use valid values and wrapped `
  • ` elements correctly within `
      ` or `
        `. - **Textarea**: Fixed `ResizeObserver` warning. - **Timer**: Fixed stopping issue when switching tabs; resolved issue where `action` prop was passed to `ActionTrigger`. - **Toast**: Fixed keyboard navigation skipping close button. - **Toggle Group**: Fixed `data-focus` not being removed on blur. # Changelog ## [Unreleased] ## [5.2.0] - 2025-03-22 ### Added - **[NEW] DownloadTrigger**: Added Component for downloading a blob or file, whether retrieved synchronously or asynchronously. ```tsx import { DownloadTrigger } from '@ark-ui/solid/download-trigger' export const DownloadImage = () => { async function fetchImage() { const response = await fetch('https://picsum.photos/200/300') return response.blob() } return ( Download Image ) } ``` ### Changed - **NumberInput**: Set the default step to `0.01` when `formatOptions.style` was set to `percent`. - **[Breaking] Splitter**: Redesigned splitter machine to support more use cases and improve DX. Check out the [Splitter](https://ark-ui.com/solid/docs/components/splitter) documentation for more details. ### Fixed - **Presence**: Fixed issue where `onExitComplete` was not being called. - **Select**: Fixed issue where select `valueAsString` lost reactivity. - **Toast**: - Fixed issue where setting `offsets` to `undefined` caused the machine to throw. - Fixed issue where `onExitComplete` was not being called. ## [5.1.1] - 2025-03-17 ### Fixed - **Field**: Exported the missing `useField` hook. - **NumberInput**: `onValueChange` correctly received `valueAsNumber`. - **Slider**: Thumbs initialized correctly when `min` was set to a non-zero value. ## [5.1.0] - 2025-03-11 ### Added - Implemented support for reactive props in `use-*.ts` functions. ```tsx const accordionProps = createMemo(() => ({ multiple: true, value: value(), onValueChange: (e) => setValue(e.value), })) const accordion = useAccordion(accordionProps) ``` ### Fixed - **Checkbox**: `data-invalid` is no longer set when `invalid` is `false`. - **Combobox**: Fixed unexpected cursor movement when editing input. - **PinInput**: OTP SMS autofill now works as expected. - **RatingGroup**: Fixed incorrect focus placement on the label. - **TagsInput**: Improved caret detection to prevent unintended tag removal. - **Timer** - Fixed slowdown when switching tabs/windows. - Changed default `interval` from `250` to `1000`. ## [5.0.0] - 2025-03-06 Ark UI just got a major performance boost! 🚀 ### What’s new in v5? - **Blazing-fast performance** – Every component runs smoother and renders faster. - **Smaller bundle size** – Leaner components and adapters for a more efficient build. We made this happen by using Solid's native reactive primitives instead of external stores. In our stress tests with **10,000 components**, Ark v5 delivered **1.5x–4x** better performance across the board. ### A quick note on tests Most component updates are non-breaking, but due to this change, some tests may need adjustments. For example: ```jsx // Before it('should open by default', () => { render(() => ) expect(screen.getByRole('dialog')).toBeInTheDocument() }) // After it('should open by default', async () => { render(() => ) expect(await screen.findByRole('dialog')).toBeInTheDocument() }) ``` #### Added - **Carousel**: ⚠️ Breaking change: Added required prop `slideCount` to `Carousel.Root` component. - **Clipboard**: Added `onValueChange` and `defaultValue` props. - **ColorPicker**: Added `defaultFormat` prop. - **Combobox**: Added `defaultHighlightedValue` and `defaultInputValue` props. - **DatePicker**: Added `defaultFocusedValue` prop, `getViewProps`, and `visibleRangeText`. - **HoverCard**: Expanded interaction handlers. - **Menu**: Added `defaultHighlightedValue` prop. - **Pagination**: Added `defaultPageSize` prop. - **PinInput**: Added `count` prop for better SSR aria-label. - **Progress**: Added `locale` and `formatOptions` props. - **QrCode**: Added `pixelSize` prop. - **Select**: Added `defaultHighlightedValue` prop. - **TagsInput**: Added `defaultInputValue` prop. - **Toggle**: Reintroduced toggle machine. #### Fixed - **Accordion**: Fixed issue in Safari where clicking triggers didn't show content. - **Avatar**: Fixed `api.setSrc` not working. - **Carousel**: Fixed pagination sync and initial page issues. - **File Upload**: Fixed drag-and-drop when `directory: true`. - **Menu**: Fixed context menu positioning not updating on right-click. - **Number Input**: Fixed `value` prop not being consumed. - **Pin Input**: Fixed focus warnings and editing issues. - **Progress**: Allowed more precise (decimal) values. - **Radio Group, Switch**: Improved focus behavior in Safari. - **Select**: Fixed regression where `multiple: true` didn't work. - **Steps**: Ensured ARIA attributes use valid values and wrapped `
      1. ` elements correctly within `
          ` or `
            `. - **Textarea**: Fixed `ResizeObserver` warning. - **Timer**: Fixed stopping issue when switching tabs; resolved issue where `action` prop was passed to `ActionTrigger`. - **Toast**: Fixed keyboard navigation skipping close button. - **Toggle Group**: Fixed `data-focus` not being removed on blur. # Changelog ## [Unreleased] ### Changed - Replaced custom ID generator with `$props.id()` rune. ## [0.3.0] - 2025-01-08 - Added `Format` component. - Added `Progress` component. ## [0.2.0] - 2024-12-12 ## Added - Added `Ark` factory component for `asChild` prop. - Added `Environment` component. - Added `Collection` helpers. - Added `Timer` component. - Added `Highlight` component. - Added `QrCode` component. ## [0.1.0] - 2024-11-27 ### Added - Added `Avatar` component. ## [0.0.0] - 2024-11-27 # Changelog ## [Unreleased] ## [5.2.0] - 2025-03-22 ### Added - **[NEW] DownloadTrigger**: Added Component for downloading a blob or file, whether retrieved synchronously or asynchronously. ```tsx import { DownloadTrigger } from '@ark-ui/react/download-trigger' export const DownloadImage = () => { async function fetchImage() { const response = await fetch('https://picsum.photos/200/300') return response.blob() } return ( Download Image ) } ``` ### Changed - **NumberInput**: Set the default step to `0.01` when `formatOptions.style` was set to `percent`. - **[Breaking] Splitter**: Redesigned splitter machine to support more use cases and improve DX. Check out the [Splitter](https://ark-ui.com/react/docs/components/splitter) documentation for more details. ### Fixed - **Toast**: Fixed issue where setting `offsets` to `undefined` caused the machine to throw. - **Select**: Fixed issue where select `valueAsString` lost reactivity. ## [5.1.1] - 2025-03-17 ### Fixed - **Field**: Exported the missing `useField` hook. - **NumberInput**: `onValueChange` correctly received `valueAsNumber`. - **Slider**: Thumbs initialized correctly when `min` was set to a non-zero value. ## [5.1.0] - 2025-03-11 ### Added - Implemented support for reactive props in `use-*.ts` functions. ```tsx const value = ref(['React']) const accordionProps = computed(() => ({ multiple: true, value: value.value, onValueChange: (e) => (value.value = e.value), })) const accordion = useAccordion(accordionProps) ``` ### Fixed - **Checkbox**: `data-invalid` is no longer set when `invalid` is `false`. - **Combobox**: Fixed unexpected cursor movement when editing input. - **PinInput**: OTP SMS autofill now works as expected. - **RatingGroup**: Fixed incorrect focus placement on the label. - **TagsInput**: Improved caret detection to prevent unintended tag removal. - **Timer** - Fixed slowdown when switching tabs/windows. - Changed default `interval` from `250` to `1000`. ## [5.0.2] - 2025-03-06 ### Fixed - **Steps**: Fixed issue where `Steps.X` namespace was not exported. ## [5.0.1] - 2025-03-06 Ark UI just got a major performance boost! 🚀 ### What’s new in v5? - **Blazing-fast performance** – Every component runs smoother and renders faster. - **Smaller bundle size** – Leaner components and adapters for a more efficient build. We made this happen by using Vue's native reactive primitives instead of external stores. In our stress tests with **10,000 components**, Ark v5 delivered **1.5x–4x** better performance across the board. ### A quick note on tests Most component updates are non-breaking, but due to this change, some tests may need adjustments. For example: ```jsx // Before it('should open by default', () => { render(ComponentUnderTest, { props: { defaultOpen: true, }, }) expect(screen.getByRole('dialog')).toBeInTheDocument() }) // After it('should open by default', async () => { render(ComponentUnderTest, { props: { defaultOpen: true, }, }) expect(await screen.findByRole('dialog')).toBeInTheDocument() }) ``` #### Added - **Carousel**: ⚠️ Breaking change: Added required prop `slideCount` to `Carousel.Root` component. - **Clipboard**: Added `onValueChange` and `defaultValue` props. - **ColorPicker**: Added `defaultFormat` prop. - **Combobox**: Added `defaultHighlightedValue` and `defaultInputValue` props. - **DatePicker**: Added `defaultFocusedValue` prop, `getViewProps`, and `visibleRangeText`. - **HoverCard**: Expanded interaction handlers. - **Menu**: Added `defaultHighlightedValue` prop. - **Pagination**: Added `defaultPageSize` prop. - **PinInput**: Added `count` prop for better SSR aria-label. - **Progress**: Added `locale` and `formatOptions` props. - **QrCode**: Added `pixelSize` prop. - **Select**: Added `defaultHighlightedValue` prop. - **TagsInput**: Added `defaultInputValue` prop. - **Toggle**: Reintroduced toggle machine. #### Fixed - **Accordion**: Fixed issue in Safari where clicking triggers didn't show content. - **Avatar**: Fixed `api.setSrc` not working. - **Carousel**: Fixed pagination sync and initial page issues. - **File Upload**: Fixed drag-and-drop when `directory: true`. - **Menu**: Fixed context menu positioning not updating on right-click. - **Number Input**: Fixed `value` prop not being consumed. - **Pin Input**: Fixed focus warnings and editing issues. - **Progress**: Allowed more precise (decimal) values. - **Radio Group, Switch**: Improved focus behavior in Safari. - **Select**: Fixed regression where `multiple: true` didn't work. - **Steps**: Ensured ARIA attributes use valid values and wrapped `
          1. ` elements correctly within `
              ` or `
                `. - **Textarea**: Fixed `ResizeObserver` warning. - **Timer**: Fixed stopping issue when switching tabs; resolved issue where `action` prop was passed to `ActionTrigger`. - **Toast**: Fixed keyboard navigation skipping close button. - **Toggle Group**: Fixed `data-focus` not being removed on blur. # About ## Acknowledgments We are committed to open source and the power of collaboration. Our work has been inspired by numerous projects and individuals who continually drive us to innovate and improve. - [Zag.js](https://zagjs.com/) - The foundation of this project - [Park UI](https://park-ui.com) - For providing the styled component demos featured in this project - [Radix Vue](https://www.radix-vue.com/) - For `useForwardPropsEmits`, which we re-export to build closed Vue components ## License This project is licensed under the terms of the [MIT license](https://github.com/chakra-ui/ark/blob/main/LICENSE). # LLMs.txt ## What is LLMs.txt? We support [LLMs.txt](https://llmstxt.org/) files for making the Ark UI documentation available to large language models (LLMs). This feature helps AI tools better understand our component library, its APIs, and usage patterns. ## Available Routes We provide several LLMs.txt routes to help AI tools access our documentation: - [llms.txt](https://ark-ui.com/llms.txt) - Contains a structured overview of all components and their documentation links - [llms-full.txt](https://ark-ui.com/llms-full.txt) - Provides comprehensive documentation including implementation details and examples - [llms-react.txt](https://ark-ui.com/llms-react.txt) - React-specific documentation and implementation details - [llms-solid.txt](https://ark-ui.com/llms-solid.txt) - SolidJS-specific documentation and implementation details - [llms-vue.txt](https://ark-ui.com/llms-vue.txt) - Vue-specific documentation and implementation details - [llms-svelte.txt](https://ark-ui.com/llms-svelte.txt) - Svelte-specific documentation and implementation details ## Usage with AI Tools ### Cursor Use the `@Docs` feature in Cursor to include the LLMs.txt files in your project. This helps Cursor provide more accurate code suggestions and documentation for Ark UI components. [Read more about @Docs in Cursor](https://docs.cursor.com/context/@-symbols/@-docs) ### Windstatic Reference the LLMs.txt files using `@` or in your `.windsurfrules` files to enhance Windstatic's understanding of Ark UI components. [Read more about Windstatic Memories](https://docs.codeium.com/windsurf/memories#memories-and-rules) ### Other AI Tools Any AI tool that supports LLMs.txt can use these routes to better understand Ark UI. Simply point your tool to any of the routes above based on your framework of choice. # GUIDES --- # Animation Adding animation to Ark UI Components is as straightforward as with any other component, but keep in mind some considerations when working with exit animations with JavaScript animation libraries. ## Animating with CSS The most straightforward method to animate your elements is using CSS. You can animate both the mounting and unmounting phases with CSS. The latter is achievable because Ark UI Components postpones the unmounting while your animation runs. Below is a simple example of creating a fade-in and fade-out animation using CSS keyframes: ```css @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } } @keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } } ``` You can use these keyframes to animate any element during its lifecycle. For instance, to apply the `fadeIn` animation when your `Tooltip` enters the 'open' state, and `fadeOut` when it enters the 'closed' state, you could use the following styles: ```css [data-scope='tooltip'][data-part='content'][data-state='open'] { animation: fadeIn 300ms ease-out; } [data-scope='tooltip'][data-part='content'][data-state='closed'] { animation: fadeOut 300ms ease-in; } ``` ## Animating with JS Libraries There's plenty of versatility when it comes to animating your Ark UI Elements with JavaScript libraries. Various libraries such as GreenSock, anime.js, Framer Motion, and more can add a new level of interaction and feedback to your UI components. One significant advantage of using Ark UI Elements is the control you have over the unmounting phase of your components. This is primarily facilitated through the `present` prop. The `present` prop allows the component to stay mounted even after its enclosing condition has been falsified, allowing for exit animations to complete before the component is removed from the DOM. # Closed Components ## Motivation Writing a few lines of code every time you need a simple `Avatar` is tedious. Creating a dedicated component encapsulates logic, simplifies the API, ensures consistent usage, and maintains clean code. This approach enhances reusability, making the component easier to maintain and test. Here's an example of an `Avatar` component that can be used consistently across your application: ```vue ``` ## Usage To use the `Avatar` component, pass the `name` and `src` props as shown below: ```jsx ``` # Collection Collections are used to manage a collection of some kind, like menus, select, combobox, etc. They provide functionalities such as sorting, searching, getting next or previous items, converting items to values or strings, checking if an item is disabled, and more. ## List Collection A list collection is a collection that is based on an array of items. It is created by passing an array of items to the constructor. ```ts import { createListCollection } from '@ark-ui/react/collection' const collection = createListCollection({ items: [ { label: 'Apple', value: 'apple' }, { label: 'Banana', value: 'banana' }, ], }) console.log(collection.items) // [{ label: 'Apple', value: 'apple' }, { label: 'Banana', value: 'banana' }] ``` ### Converting value to item Use the `find` or `findMany` method to convert a value to an item. ```ts const item = collection.find('banana') console.log(item) // { label: "Banana", value: "banana" } const items = collection.findMany(['apple', 'banana']) console.log(items) // [{ label: "Apple", value: "apple" }, { label: "Banana", value: "banana" }] ``` ### Value Traversal Use the `getNextValue` or `getPreviousValue` method to get the next or previous item based on a value. ```ts const nextValue = collection.getNextValue('apple') console.log(nextValue) // banana const previousItem = collection.getPreviousValue('banana') console.log(previousItem) // apple ``` Likewise, use the `firstValue` or `lastValue` computed properties to get the first or last item. ```ts console.log(collection.firstValue) // apple console.log(collection.lastValue) // banana ``` ### Check for value existence Use the `has` method to check if a value exists in the collection. ```ts const hasValue = collection.has('apple') console.log(hasValue) // true ``` ### Working with custom objects If you are working with custom objects, you can pass a function to the `itemToString` and `itemToValue` options to specify how to convert an item to a string and a value, respectively. > By default, we look for the `label` and `value` properties in the item. ```ts import { createListCollection } from '@ark-ui/react/collection' const collection = createListCollection({ items: [ { id: 1, name: 'apple' }, { id: 2, name: 'banana' }, { id: 3, name: 'cherry' }, ], itemToString: (item) => item.name, itemToValue: (item) => item.id, }) ``` To mark an item as disabled, pass a function to the `isItemDisabled` option. > By default, we look for the `disabled` property in the item. ```ts import { createListCollection } from '@ark-ui/react/collection' const collection = createListCollection({ items: [ { id: 1, name: 'apple' }, { id: 2, name: 'banana' }, { id: 3, name: 'cherry' }, ], isItemDisabled: (item) => item.id === 2, }) ``` ### Reorder items Use the `reorder` method to reorder items by passing the starting index and the ending index of the item to be moved. ```ts const fromIndex = 1 // Banana const toIndex = 0 // Apple collection.reorder(fromIndex, toIndex) console.log(collection.items) // [{ label: "Banana", value: "banana" }, { label: "Apple", value: "apple" }] ``` # Component State ## Context Components Context components expose state and functions to child components. In this example, `Avatar.Fallback` renders based on `loaded` state. ```vue ``` > **Good to know (RSC)**: Due to the usage of render prop, you might need to add the `'use client'` directive at the top > of your file when using React Server Components. ## Provider Components Provider components can help coordinate state and behavior between multiple components, enabling interactions that aren't possible with `Context` components alone. ```vue ``` See more in [Examples](/react/examples/popover-selection). # Composition ## The asChild Prop In Ark UI, the `asChild` prop lets you integrate custom components, ensuring consistent styling and behavior while promoting flexibility and reusability. All Ark components that render a DOM element accept the `asChild` prop. Here's an example using `asChild` to integrate a custom `Button` component within a `Popover`: ```vue ``` In this example, the `asChild` prop allows the `Button` to be used as the trigger for the `Popover`, inheriting its behaviors from Popover.Trigger. ## The Ark Factory You can use the `ark` factory to create your own elements that work just like Ark UI components. ```vue ``` This will produce the following HTML: ```html Ark UI ``` ## Limitations When using the `asChild` prop, ensure you pass only a single child element. Passing multiple children may cause rendering issues. Certain components, such as `Checkbox.Root` or `RadioGroup.Item`, have specific requirements for their child elements. For instance, they may require a label element as a child. If you change the underlying element type, ensure it remains accessible and functional. # Styling ## Overview Ark UI is a headless component library that works with any styling solution. It provides functional styles for elements like popovers for positioning, while leaving presentation styles up to you. Some components also expose CSS variables that can be used for styling or animations. > **Tip:** Looking for a ready-to-use solution? Checkout [Park UI](https://park-ui.com) for a collection of pre-designed > styles based on Ark UI components. ### Data Attributes Ark UI components use `data-scope` and `data-part` attributes to target specific elements within a component. Interactive components often include `data-*` attributes to indicate their state. For example, here's what an open accordion item looks like: ```html
                ``` For more details on each component's data attributes, refer to their respective documentation. ## Styling with CSS When styling components with CSS, you can target the data attributes assigned to each component part for easy customization. ### Styling a Part To style a specific component part, target its `data-scope` and `data-part` attributes: ```css [data-scope='accordion'][data-part='item'] { border-bottom: 1px solid #e5e5e5; } ``` ### Styling a State To style a component based on its state, use the `data-state` attribute: ```css [data-scope='accordion'][data-part='item'][data-state='open'] { background-color: #f5f5f5; } ``` > **Tip:** If you prefer using classes instead of data attributes, utilize the `class` or `className` prop to add custom > classes to Ark UI components. ## Styling with Panda CSS [Panda CSS](https://panda-css.com) is a build-time CSS-in-JS framework that integrates seamlessly with Ark UI, providing an efficient styling solution. ### Styling a part Panda offers various ways to write styles, but in the context of Ark UI, we recommend using the `defineSlotRecipe` function to style a component with its different parts and variants. ```ts import { accordionAnatomy } from '@ark-ui/anatomy' import { defineSlotRecipe } from '@pandacss/dev' export const accordionStyles = defineSlotRecipe({ className: 'accordion', slots: accordionAnatomy.keys(), base: { item: { borderBottom: '1px solid #e5e5e5', }, }, defaultVariants: {}, variants: {}, }) ``` ### Styling a state To style a component based on its state, you can use built in [conditions](https://panda-css.com/docs/customization/conditions) in Panda CSS. ```ts import { accordionAnatomy } from '@ark-ui/anatomy' import { defineSlotRecipe } from '@pandacss/dev' export const accordionStyles = defineSlotRecipe({ className: 'accordion', slots: accordionAnatomy.keys(), base: { item: { borderBottom: '1px solid {colors.gray.300}', _open: { // [!code highlight] backgroundColor: 'gray.100', }, }, }, defaultVariants: {}, variants: {}, }) ``` ## Styling with Tailwind CSS [Tailwind CSS](https://tailwindcss.com/) is a utility-first CSS framework providing a flexible way to style your components. ### Styling a Part To style a part, apply classes directly to the parts using either `class` or `className`, depending on the JavaScript framework. ```jsx {/* … */} ``` ### Styling a State Leverage Tailwind CSS's variant selector to style a component based on its data-state attribute. ```jsx {/* … */} ``` # COMPONENTS --- # Accordion ## Features - Full keyboard navigation - Supports horizontal and vertical orientation - Right-to-Left (RTL) support - Single or multiple item expansion - Controlled and uncontrolled modes - Collapse each accordion item ## Anatomy To set up the accordion correctly, it's essential to understand its anatomy and the naming of its parts. > Each part includes a `data-part` attribute to help identify them in the DOM. ## Examples ### Default Expanded State Set the `defaultValue` prop to specify which item should be expanded by default. ```vue ``` ### Collapsible Use the `collapsible` prop to allow the user to collapse all panels. ```vue ``` ### Multiple Panels Use the `multiple` prop to allow multiple panels to be expanded simultaneously. ```vue ``` ### Horizontal Orientation By default, the Accordion is oriented vertically. Use the `orientation` prop to switch to a horizontal layout. ```vue ``` ### Animate Content Size Use the `--height` and/or `--width` CSS variables to animate the size of the content when it expands or closes: ```css @keyframes slideDown { from { opacity: 0.01; height: 0; } to { opacity: 1; height: var(--height); } } @keyframes slideUp { from { opacity: 1; height: var(--height); } to { opacity: 0.01; height: 0; } } [data-scope='accordion'][data-part='item-content'][data-state='open'] { animation: slideDown 250ms ease-in-out; } [data-scope='accordion'][data-part='item-content'][data-state='closed'] { animation: slideUp 200ms ease-in-out; } ``` ### Using the Root Provider The `RootProvider` component provides a context for the accordion. It accepts the value of the `useAccordion` hook. You can leverage it to access the component state and methods from outside the accordion. ```vue ``` > If you're using the `RootProvider` component, you don't need to use the `Root` component. ### Accessing the focused item Use the `focusedValue` property to get the value of the focused accordion item. ```vue ``` ### Accessing the selected items Use the `value` property to get the selected accordion items. ```vue ``` ### Setting the selected items Use the `setValue` method to set the selected accordion items. ```vue ``` ### Accessing an item's state Use the `getItemState` method to get the state of an accordion item. ```vue ``` ## API Reference ### Root #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`collapsible`** Type: `boolean` Required: false Default Value: `false` Description: Whether an accordion item can be closed after it has been expanded. **`defaultValue`** Type: `string[]` Required: false Default Value: `undefined` Description: The initial value of the expanded accordion items. Use when you don't need to control the value of the accordion. **`disabled`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the accordion items are disabled **`id`** Type: `string` Required: false Default Value: `undefined` Description: The unique identifier of the machine. **`ids`** Type: `Partial<{ root: string item(value: string): string itemContent(value: string): string itemTrigger(value: string): string }>` Required: false Default Value: `undefined` Description: The ids of the elements in the accordion. Useful for composition. **`lazyMount`** Type: `boolean` Required: false Default Value: `false` Description: Whether to enable lazy mounting **`modelValue`** Type: `string[]` Required: false Default Value: `undefined` Description: The v-model value of the accordion **`multiple`** Type: `boolean` Required: false Default Value: `false` Description: Whether multiple accordion items can be expanded at the same time. **`orientation`** Type: `'horizontal' | 'vertical'` Required: false Default Value: `"vertical"` Description: The orientation of the accordion items. **`unmountOnExit`** Type: `boolean` Required: false Default Value: `false` Description: Whether to unmount on exit. #### Emits **`focusChange`** Type: `[details: FocusChangeDetails]` Description: The callback fired when the focused accordion item changes. **`update:modelValue`** Type: `[value: string[]]` Description: The callback fired when the model value changes. **`valueChange`** Type: `[details: ValueChangeDetails]` Description: The callback fired when the state of expanded/collapsed accordion items changes. #### Data Attributes **`data-scope`**: accordion **`data-part`**: root **`data-orientation`**: The orientation of the accordion ### ItemContent #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: accordion **`data-part`**: item-content **`data-state`**: "open" | "closed" **`data-disabled`**: Present when disabled **`data-focus`**: Present when focused **`data-orientation`**: The orientation of the item ### ItemIndicator #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: accordion **`data-part`**: item-indicator **`data-state`**: "open" | "closed" **`data-disabled`**: Present when disabled **`data-focus`**: Present when focused **`data-orientation`**: The orientation of the item ### Item #### Props **`value`** Type: `string` Required: true Default Value: `undefined` Description: The value of the accordion item. **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`disabled`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the accordion item is disabled. #### Data Attributes **`data-scope`**: accordion **`data-part`**: item **`data-state`**: "open" | "closed" **`data-focus`**: Present when focused **`data-disabled`**: Present when disabled **`data-orientation`**: The orientation of the item ### ItemTrigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: accordion **`data-part`**: item-trigger **`data-orientation`**: The orientation of the item **`data-state`**: "open" | "closed" ### RootProvider #### Props **`value`** Type: `AccordionApi` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`lazyMount`** Type: `boolean` Required: false Default Value: `false` Description: Whether to enable lazy mounting **`unmountOnExit`** Type: `boolean` Required: false Default Value: `false` Description: Whether to unmount on exit. ## Accessibility This component complies with the [Accordion WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/accordion/). ### Keyboard Support **`Space`** Description: When focus is on an trigger of a collapsed item, the item is expanded **`Enter`** Description: When focus is on an trigger of a collapsed section, expands the section. **`Tab`** Description: Moves focus to the next focusable element **`Shift + Tab`** Description: Moves focus to the previous focusable element **`ArrowDown`** Description: Moves focus to the next trigger **`ArrowUp`** Description: Moves focus to the previous trigger. **`Home`** Description: When focus is on an trigger, moves focus to the first trigger. **`End`** Description: When focus is on an trigger, moves focus to the last trigger. # Avatar ## Anatomy To set up the avatar correctly, you'll need to understand its anatomy and how we name its parts. > Each part includes a `data-part` attribute to help identify them in the DOM. ## Examples Learn how to use the `Avatar` component in your project. Let's take a look at the most basic example: ```vue ``` ### Handling Events `Avatar` allows you to listen for loading state changes. ```vue ``` ### Using the Root Provider The `RootProvider` component provides a context for the avatar. It accepts the value of the `useAvatar` hook. You can leverage it to access the component state and methods from outside the avatar. ```vue ``` > If you're using the `RootProvider` component, you don't need to use the `Root` component. ### Next.js Image Here's an example of how to use the `Image` component from `next/image`. ```tsx import { Avatar, useAvatarContext } from '@ark-ui/react/avatar' import Image, { ImageProps } from 'next/image' const AvatarNextImage = (props: ImageProps) => { const avatar = useAvatarContext() const { hidden, ...imageProps } = avatar.getImageProps() as ImageProps return ( ) } const Demo = () => { return ( JD ) } ``` > Refer to this [Github Discussion](https://github.com/chakra-ui/ark/discussions/3147) for more information. ## API Reference ### Root #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`id`** Type: `string` Required: false Default Value: `undefined` Description: The unique identifier of the machine. **`ids`** Type: `Partial<{ root: string; image: string; fallback: string }>` Required: false Default Value: `undefined` Description: The ids of the elements in the avatar. Useful for composition. #### Emits **`statusChange`** Type: `[details: StatusChangeDetails]` Description: Functional called when the image loading status changes. ### Fallback #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: avatar **`data-part`**: fallback **`data-state`**: "hidden" | "visible" ### Image #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: avatar **`data-part`**: image **`data-state`**: "visible" | "hidden" ### RootProvider #### Props **`value`** Type: `AvatarApi` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. # Carousel ## Features - Native CSS Scroll Snap integration for smooth, performant animations - Flexible orientation support (horizontal and vertical layouts) - Customizable slide alignment (start, center, or end positions) - Multi-slide display capabilities for complex layouts - Automatic playback with configurable looping behavior - Adjustable slide spacing and gap controls ## Anatomy To set up the carousel correctly, you'll need to understand its anatomy and how we name its parts. > Each part includes a `data-part` attribute to help identify them in the DOM. ## Examples Learn how to use the `Carousel` component in your project. Let's take a look at the most basic example: ```vue ``` ### Controlled Carousel To create a controlled Carousel component, you can manage the state of the carousel using the `index` prop and update it when the `onIndexChange` event handler is called: ```vue ``` ### Autoplay The Carousel can play automatically. Just add the `autoplay` prop. You'll probably want to add `loop` too, so it keeps going after the last slide. ```vue ``` ### Using the Root Provider The `RootProvider` sets up carousel context using the `useCarousel` hook, enabling external access to its state and methods. ```vue ``` > If you're using the `RootProvider` component, you don't need to use the `Root` component. ## API Reference ### Root #### Props **`slideCount`** Type: `number` Required: true Default Value: `undefined` Description: The total number of slides. Useful for SSR to render the initial ating the snap points. **`allowMouseDrag`** Type: `boolean` Required: false Default Value: `false` Description: Whether to allow scrolling via dragging with mouse **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`autoplay`** Type: `boolean | { delay: number }` Required: false Default Value: `false` Description: Whether to scroll automatically. The default delay is 4000ms. **`defaultPage`** Type: `number` Required: false Default Value: `0` Description: The initial page to scroll to when rendered. Use when you don't need to control the page of the carousel. **`id`** Type: `string` Required: false Default Value: `undefined` Description: The unique identifier of the machine. **`ids`** Type: `Partial<{ root: string item(index: number): string itemGroup: string nextTrigger: string prevTrigger: string indicatorGroup: string indicator(index: number): string }>` Required: false Default Value: `undefined` Description: The ids of the elements in the carousel. Useful for composition. **`inViewThreshold`** Type: `number | number[]` Required: false Default Value: `0.6` Description: The threshold for determining if an item is in view. **`loop`** Type: `boolean` Required: false Default Value: `false` Description: Whether the carousel should loop around. **`orientation`** Type: `'horizontal' | 'vertical'` Required: false Default Value: `"horizontal"` Description: The orientation of the element. **`padding`** Type: `string` Required: false Default Value: `undefined` Description: Defines the extra space added around the scrollable area, enabling nearby items to remain partially in view. **`page`** Type: `number` Required: false Default Value: `undefined` Description: The controlled page of the carousel. **`slidesPerMove`** Type: `number | 'auto'` Required: false Default Value: `"auto"` Description: The number of slides to scroll at a time. When set to `auto`, the number of slides to scroll is determined by the `slidesPerPage` property. **`slidesPerPage`** Type: `number` Required: false Default Value: `1` Description: The number of slides to show at a time. **`snapType`** Type: `'proximity' | 'mandatory'` Required: false Default Value: `"mandatory"` Description: The snap type of the item. **`spacing`** Type: `string` Required: false Default Value: `"0px"` Description: The amount of space between items. **`translations`** Type: `IntlTranslations` Required: false Default Value: `undefined` Description: The localized messages to use. #### Emits **`autoplayStatusChange`** Type: `[details: AutoplayStatusDetails]` Description: Function called when the autoplay status changes. **`dragStatusChange`** Type: `[details: DragStatusDetails]` Description: Function called when the drag status changes. **`pageChange`** Type: `[details: PageChangeDetails]` Description: Function called when the page changes. **`update:page`** Type: `[page: number]` Description: The callback fired when the carousel page changes. #### Data Attributes **`data-scope`**: carousel **`data-part`**: root **`data-orientation`**: The orientation of the carousel ### AutoplayTrigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: carousel **`data-part`**: autoplay-trigger **`data-orientation`**: The orientation of the autoplaytrigger **`data-pressed`**: Present when pressed ### Control #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: carousel **`data-part`**: control **`data-orientation`**: The orientation of the control ### IndicatorGroup #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: carousel **`data-part`**: indicator-group **`data-orientation`**: The orientation of the indicatorgroup ### Indicator #### Props **`index`** Type: `number` Required: true Default Value: `undefined` Description: The index of the indicator. **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`readOnly`** Type: `boolean` Required: false Default Value: `false` Description: Whether the indicator is read only. #### Data Attributes **`data-scope`**: carousel **`data-part`**: indicator **`data-orientation`**: The orientation of the indicator **`data-index`**: The index of the item **`data-readonly`**: Present when read-only **`data-current`**: Present when current ### ItemGroup #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: carousel **`data-part`**: item-group **`data-orientation`**: The orientation of the item **`data-dragging`**: Present when in the dragging state ### Item #### Props **`index`** Type: `number` Required: true Default Value: `undefined` Description: The index of the item. **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`snapAlign`** Type: `'start' | 'end' | 'center'` Required: false Default Value: `"start"` Description: The snap alignment of the item. #### Data Attributes **`data-scope`**: carousel **`data-part`**: item **`data-index`**: The index of the item **`data-inview`**: Present when in viewport **`data-orientation`**: The orientation of the item ### NextTrigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: carousel **`data-part`**: next-trigger **`data-orientation`**: The orientation of the nexttrigger ### PrevTrigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: carousel **`data-part`**: prev-trigger **`data-orientation`**: The orientation of the prevtrigger ### RootProvider #### Props **`value`** Type: `CarouselApi` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ## Accessibility Complies with the [Carousel WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/carousel/). # Checkbox ## Anatomy To set up the checkbox correctly, you'll need to understand its anatomy and how we name its parts. > Each part includes a `data-part` attribute to help identify them in the DOM. ### Design impact on the asChild property The `Checkbox.Root` element of the checkbox is a `label` element. This is because the checkbox is a form control and should be associated with a label to provide context and meaning to the user. Otherwise, the HTML and accessibility structure will be invalid. > If you need to use the `asChild` property, make sure that the `label` element is the direct child of the > `Checkbox.Root` component. ## Examples Learn how to use the `Checkbox` component in your project. Let's take a look at the most basic example: ```vue ``` ### Controlled Checkbox To create a controlled Checkbox component, manage the state of the checked status using the `checked` prop and update it when the `onCheckedChange` event handler is called: ```vue ``` ### Indeterminate Checkbox In some cases, you may need a checkbox to represent a state that is neither checked nor unchecked, known as the indeterminate state. This can be achieved by setting the `checked` prop to `indeterminate`: ```vue ``` ### Checkbox Group Ark provides a `Checkbox.Group` component to manage a group of checkboxes. The `Checkbox.Group` component manages the state of the checkboxes and provides a way to access the checked values: ```vue ``` ### Render Prop Usage For cases where you need more flexibility in rendering, the Checkbox component offers the use of a render prop. The render prop function gives you access to the checkbox's API, allowing you to customize the checkbox control's rendering: ```vue ``` ### Using the Field Component The `Field` component helps manage form-related state and accessibility attributes of a checkbox. It includes handling ARIA labels, helper text, and error text to ensure proper accessibility. ```vue ``` ### Using the Root Provider The `RootProvider` component provides a context for the checkbox. It accepts the value of the `useCheckbox` hook. You can leverage it to access the component state and methods from outside the checkbox. ```vue ``` > If you're using the `RootProvider` component, you don't need to use the `Root` component. ## API Reference ### Root #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`checked`** Type: `CheckedState` Required: false Default Value: `undefined` Description: The controlled checked state of the checkbox **`defaultChecked`** Type: `CheckedState` Required: false Default Value: `undefined` Description: The initial checked state of the checkbox when rendered. Use when you don't need to control the checked state of the checkbox. **`disabled`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the checkbox is disabled **`form`** Type: `string` Required: false Default Value: `undefined` Description: The id of the form that the checkbox belongs to. **`id`** Type: `string` Required: false Default Value: `undefined` Description: The unique identifier of the machine. **`ids`** Type: `Partial<{ root: string; hiddenInput: string; control: string; label: string }>` Required: false Default Value: `undefined` Description: The ids of the elements in the checkbox. Useful for composition. **`invalid`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the checkbox is invalid **`name`** Type: `string` Required: false Default Value: `undefined` Description: The name of the input field in a checkbox. Useful for form submission. **`readOnly`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the checkbox is read-only **`required`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the checkbox is required **`value`** Type: `string` Required: false Default Value: `"on"` Description: The value of checkbox input. Useful for form submission. #### Emits **`checkedChange`** Type: `[details: CheckedChangeDetails]` Description: The callback invoked when the checked state changes. **`update:checked`** Type: `[checked: CheckedState]` Description: The callback invoked when the checked state changes. #### Data Attributes **`data-active`**: Present when active or pressed **`data-focus`**: Present when focused **`data-focus-visible`**: Present when focused with keyboard **`data-readonly`**: Present when read-only **`data-hover`**: Present when hovered **`data-disabled`**: Present when disabled **`data-state`**: "indeterminate" | "checked" | "unchecked" **`data-invalid`**: Present when invalid ### Control #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-active`**: Present when active or pressed **`data-focus`**: Present when focused **`data-focus-visible`**: Present when focused with keyboard **`data-readonly`**: Present when read-only **`data-hover`**: Present when hovered **`data-disabled`**: Present when disabled **`data-state`**: "indeterminate" | "checked" | "unchecked" **`data-invalid`**: Present when invalid ### Group #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`defaultValue`** Type: `string[]` Required: false Default Value: `undefined` Description: The initial value of `value` when uncontrolled **`disabled`** Type: `boolean` Required: false Default Value: `undefined` Description: If `true`, the checkbox group is disabled **`invalid`** Type: `boolean` Required: false Default Value: `undefined` Description: If `true`, the checkbox group is invalid **`modelValue`** Type: `string[]` Required: false Default Value: `undefined` Description: The controlled value of the checkbox group **`name`** Type: `string` Required: false Default Value: `undefined` Description: The name of the input fields in the checkbox group (Useful for form submission). **`readOnly`** Type: `boolean` Required: false Default Value: `undefined` Description: If `true`, the checkbox group is read-only ### HiddenInput #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Indicator #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`indeterminate`** Type: `boolean` Required: false Default Value: `undefined` Description: undefined #### Data Attributes **`data-active`**: Present when active or pressed **`data-focus`**: Present when focused **`data-focus-visible`**: Present when focused with keyboard **`data-readonly`**: Present when read-only **`data-hover`**: Present when hovered **`data-disabled`**: Present when disabled **`data-state`**: "indeterminate" | "checked" | "unchecked" **`data-invalid`**: Present when invalid ### Label #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-active`**: Present when active or pressed **`data-focus`**: Present when focused **`data-focus-visible`**: Present when focused with keyboard **`data-readonly`**: Present when read-only **`data-hover`**: Present when hovered **`data-disabled`**: Present when disabled **`data-state`**: "indeterminate" | "checked" | "unchecked" **`data-invalid`**: Present when invalid ### RootProvider #### Props **`value`** Type: `CheckboxApi` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ## Accessibility Complies with the [Checkbox WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/checkbox/). ### Keyboard Support **`Space`** Description: Toggle the checkbox # Clipboard ## Anatomy To set up the Clipboard correctly, you'll need to understand its anatomy and how we name its parts. > Each part includes a `data-part` attribute to help identify them in the DOM. ## Examples Learn how to use the `Clipboard` component in your project. Let's take a look at the most basic example: ```vue ``` ### Using the Root Provider The `RootProvider` component provides a context for the clipboard. It accepts the value of the `useClipboard` hook. You can leverage it to access the component state and methods from outside the clipboard. ```vue ``` > If you're using the `RootProvider` component, you don't need to use the `Root` component. ## API Reference ### Root #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`defaultValue`** Type: `string` Required: false Default Value: `undefined` Description: The initial value to be copied to the clipboard when rendered. Use when you don't need to control the value of the clipboard. **`id`** Type: `string` Required: false Default Value: `undefined` Description: The unique identifier of the machine. **`ids`** Type: `Partial<{ root: string; input: string; label: string }>` Required: false Default Value: `undefined` Description: The ids of the elements in the clipboard. Useful for composition. **`modelValue`** Type: `string` Required: false Default Value: `undefined` Description: The v-model value of the clipboard **`timeout`** Type: `number` Required: false Default Value: `3000` Description: The timeout for the copy operation #### Emits **`statusChange`** Type: `[details: CopyStatusDetails]` Description: The function to be called when the value is copied to the clipboard **`update:modelValue`** Type: `[value: string]` Description: The callback fired when the model value changes. **`valueChange`** Type: `[details: ValueChangeDetails]` Description: The function to be called when the value changes #### Data Attributes **`data-scope`**: clipboard **`data-part`**: root **`data-copied`**: Present when copied state is true ### Control #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: clipboard **`data-part`**: control **`data-copied`**: Present when copied state is true ### Indicator #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Input #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: clipboard **`data-part`**: input **`data-copied`**: Present when copied state is true **`data-readonly`**: Present when read-only ### Label #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: clipboard **`data-part`**: label **`data-copied`**: Present when copied state is true ### RootProvider #### Props **`value`** Type: `ClipboardApi` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Trigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: clipboard **`data-part`**: trigger **`data-copied`**: Present when copied state is true ### ValueText #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. # Collapsible ## Animation You can use CSS animations to create smooth transitions for opening and closing the Collapsible content. Utilize the `data-state` attribute in combination with the `--height` CSS variable to animate the open and closed states. ```css @keyframes slideDown { from { height: 0; } to { height: var(--height); } } @keyframes slideUp { from { height: var(--height); } to { height: 0; } } [data-scope='collapsible'][data-part='content'][data-state='open'] { animation: slideDown 250ms; } [data-scope='collapsible'][data-part='content'][data-state='closed'] { animation: slideUp 200ms; } ``` ## Examples Learn how to use the `Collapsible` component in your project. Let's examine the most basic example: ```vue ``` ### Events You can listen for the `onExitComplete` event to know when the `Collapsible.Content` is no longer visible: ```vue ``` ### Lazy Mount To delay the mounting of the `Collapsible.Content`, use the `lazyMount` prop: ```vue ``` ### Unmount on Exit To remove the `Collapsible.Content` from the DOM when it is not visible, use the `unmountOnExit` prop: ```vue ``` ### Combining Lazy Mount and Unmount on Exit Both `lazyMount` and `unmountOnExit` can be combined to ensure that the component is mounted only when the `Collapsible` is expanded and unmounted when it is collapsed: ```vue ``` ### Using the Root Provider The `RootProvider` component provides a context for the collapsible. It accepts the value of the `useCollapsible` hook. You can leverage it to access the component state and methods from outside the collapsible. ```vue ``` > If you're using the `RootProvider` component, you don't need to use the `Root` component. ## API Reference ### Root #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`defaultOpen`** Type: `boolean` Required: false Default Value: `undefined` Description: The initial open state of the collapsible when rendered. Use when you don't need to control the open state of the collapsible. **`disabled`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the collapsible is disabled. **`id`** Type: `string` Required: false Default Value: `undefined` Description: The unique identifier of the machine. **`ids`** Type: `Partial<{ root: string; content: string; trigger: string }>` Required: false Default Value: `undefined` Description: The ids of the elements in the collapsible. Useful for composition. **`lazyMount`** Type: `boolean` Required: false Default Value: `false` Description: Whether to enable lazy mounting **`open`** Type: `boolean` Required: false Default Value: `undefined` Description: The controlled open state of the collapsible. **`unmountOnExit`** Type: `boolean` Required: false Default Value: `false` Description: Whether to unmount on exit. #### Emits **`exitComplete`** Type: `[]` Description: The callback invoked when the exit animation completes. **`openChange`** Type: `[details: OpenChangeDetails]` Description: The callback invoked when the open state changes. **`update:open`** Type: `[open: boolean]` Description: Event handler called when the open state of the collapsible changes. #### Data Attributes **`data-scope`**: collapsible **`data-part`**: root **`data-state`**: "open" | "closed" ### Content #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: collapsible **`data-part`**: content **`data-collapsible`**: **`data-state`**: "open" | "closed" **`data-disabled`**: Present when disabled ### RootProvider #### Props **`value`** Type: `Collapsible` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Trigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: collapsible **`data-part`**: trigger **`data-state`**: "open" | "closed" **`data-disabled`**: Present when disabled ## Accessibility ### Keyboard Support **`Space`** Description: Opens/closes the collapsible. **`Enter`** Description: Opens/closes the collapsible. # Color Picker ## Anatomy To set up the color picker correctly, you'll need to understand its anatomy and how we name its parts. > Each part includes a `data-part` attribute to help identify them in the DOM. ## Examples Learn how to use the `ColorPicker` component in your project. Let's take a look at the most basic example ```vue ``` ### Controlled Color Picker To create a controlled Color Picker component, manage the state of the current color using the `value` prop and update it when the `onValueChange` or `onValueChangeEnd` event handler is called: ```vue ``` ### Using the Field Component The `Field` component helps manage form-related state and accessibility attributes of a color picker. It includes handling ARIA labels, helper text, and error text to ensure proper accessibility. ```vue ``` ### Using the Root Provider The `RootProvider` component provides a context for the color-picker. It accepts the value of the `useColor-picker` hook. You can leverage it to access the component state and methods from outside the color-picker. ```vue ``` > If you're using the `RootProvider` component, you don't need to use the `Root` component. ## API Reference ### Root #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`closeOnSelect`** Type: `boolean` Required: false Default Value: `false` Description: Whether to close the color picker when a swatch is selected **`defaultFormat`** Type: `ColorFormat` Required: false Default Value: `"rgba"` Description: The initial color format when rendered. Use when you don't need to control the color format of the color picker. **`defaultOpen`** Type: `boolean` Required: false Default Value: `undefined` Description: The initial open state of the color picker when rendered. Use when you don't need to control the open state of the color picker. **`defaultValue`** Type: `Color` Required: false Default Value: `#000000` Description: The initial color value when rendered. Use when you don't need to control the color value of the color picker. **`disabled`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the color picker is disabled **`format`** Type: `ColorFormat` Required: false Default Value: `undefined` Description: The controlled color format to use **`id`** Type: `string` Required: false Default Value: `undefined` Description: The unique identifier of the machine. **`ids`** Type: `Partial<{ root: string; control: string; trigger: string; label: string; input: string; hiddenInput: string; content: string; area: string; areaGradient: string; positioner: string; formatSelect: string; areaThumb: string; channelInput(id: string): string; channelSliderTrack(id: ColorChannel): string; channelSliderT...` Required: false Default Value: `undefined` Description: The ids of the elements in the color picker. Useful for composition. **`initialFocusEl`** Type: `() => HTMLElement | null` Required: false Default Value: `undefined` Description: The initial focus element when the color picker is opened. **`invalid`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the color picker is invalid **`lazyMount`** Type: `boolean` Required: false Default Value: `false` Description: Whether to enable lazy mounting **`modelValue`** Type: `Color` Required: false Default Value: `undefined` Description: The v-model value of the color picker **`name`** Type: `string` Required: false Default Value: `undefined` Description: The name for the form input **`open`** Type: `boolean` Required: false Default Value: `undefined` Description: The controlled open state of the color picker **`openAutoFocus`** Type: `boolean` Required: false Default Value: `true` Description: Whether to auto focus the color picker when it is opened **`positioning`** Type: `PositioningOptions` Required: false Default Value: `undefined` Description: The positioning options for the color picker **`readOnly`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the color picker is read-only **`required`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the color picker is required **`unmountOnExit`** Type: `boolean` Required: false Default Value: `false` Description: Whether to unmount on exit. #### Emits **`focusOutside`** Type: `[event: FocusOutsideEvent]` Description: Function called when the focus is moved outside the component **`formatChange`** Type: `[details: FormatChangeDetails]` Description: Function called when the color format changes **`interactOutside`** Type: `[event: InteractOutsideEvent]` Description: Function called when an interaction happens outside the component **`openChange`** Type: `[details: OpenChangeDetails]` Description: Handler that is called when the user opens or closes the color picker. **`pointerDownOutside`** Type: `[event: PointerDownOutsideEvent]` Description: Function called when the pointer is pressed down outside the component **`update:format`** Type: `[format: ColorFormat]` Description: The callback fired when the format changes. **`update:modelValue`** Type: `[value: Color]` Description: The callback fired when the model value changes. **`update:open`** Type: `[open: boolean]` Description: The callback fired when the open state changes. **`valueChange`** Type: `[details: ValueChangeDetails]` Description: Handler that is called when the value changes, as the user drags. **`valueChangeEnd`** Type: `[details: ValueChangeDetails]` Description: Handler that is called when the user stops dragging. #### Data Attributes **`data-scope`**: color-picker **`data-part`**: root **`data-disabled`**: Present when disabled **`data-readonly`**: Present when read-only **`data-invalid`**: Present when invalid ### AreaBackground #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: color-picker **`data-part`**: area-background **`data-invalid`**: Present when invalid **`data-disabled`**: Present when disabled **`data-readonly`**: Present when read-only ### Area #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`xChannel`** Type: `ColorChannel` Required: false Default Value: `undefined` Description: undefined **`yChannel`** Type: `ColorChannel` Required: false Default Value: `undefined` Description: undefined #### Data Attributes **`data-scope`**: color-picker **`data-part`**: area **`data-invalid`**: Present when invalid **`data-disabled`**: Present when disabled **`data-readonly`**: Present when read-only ### AreaThumb #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: color-picker **`data-part`**: area-thumb **`data-disabled`**: Present when disabled **`data-invalid`**: Present when invalid **`data-readonly`**: Present when read-only ### ChannelInput #### Props **`channel`** Type: `ExtendedColorChannel` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`orientation`** Type: `Orientation` Required: false Default Value: `undefined` Description: undefined #### Data Attributes **`data-scope`**: color-picker **`data-part`**: channel-input **`data-channel`**: The color channel of the channelinput **`data-disabled`**: Present when disabled **`data-invalid`**: Present when invalid **`data-readonly`**: Present when read-only ### ChannelSliderLabel #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: color-picker **`data-part`**: channel-slider-label **`data-channel`**: The color channel of the channelsliderlabel ### ChannelSlider #### Props **`channel`** Type: `ColorChannel` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`orientation`** Type: `Orientation` Required: false Default Value: `undefined` Description: undefined #### Data Attributes **`data-scope`**: color-picker **`data-part`**: channel-slider **`data-channel`**: The color channel of the channelslider **`data-orientation`**: The orientation of the channelslider ### ChannelSliderThumb #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: color-picker **`data-part`**: channel-slider-thumb **`data-channel`**: The color channel of the channelsliderthumb **`data-disabled`**: Present when disabled **`data-orientation`**: The orientation of the channelsliderthumb ### ChannelSliderTrack #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: color-picker **`data-part`**: channel-slider-track **`data-channel`**: The color channel of the channelslidertrack **`data-orientation`**: The orientation of the channelslidertrack ### ChannelSliderValueText #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: color-picker **`data-part`**: channel-slider-value-text **`data-channel`**: The color channel of the channelslidervaluetext ### Content #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`immediate`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether to synchronize the present change immediately or defer it to the next frame **`lazyMount`** Type: `boolean` Required: false Default Value: `false` Description: Whether to enable lazy mounting **`present`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the node is present (controlled by the user) **`unmountOnExit`** Type: `boolean` Required: false Default Value: `false` Description: Whether to unmount on exit. #### Data Attributes **`data-scope`**: color-picker **`data-part`**: content **`data-placement`**: The placement of the content **`data-state`**: "open" | "closed" ### Control #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: color-picker **`data-part`**: control **`data-disabled`**: Present when disabled **`data-readonly`**: Present when read-only **`data-invalid`**: Present when invalid **`data-state`**: "open" | "closed" **`data-focus`**: Present when focused ### EyeDropperTrigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: color-picker **`data-part`**: eye-dropper-trigger **`data-disabled`**: Present when disabled **`data-invalid`**: Present when invalid **`data-readonly`**: Present when read-only ### FormatSelect #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### FormatTrigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### HiddenInput #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Label #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: color-picker **`data-part`**: label **`data-disabled`**: Present when disabled **`data-readonly`**: Present when read-only **`data-invalid`**: Present when invalid **`data-focus`**: Present when focused ### Positioner #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### RootProvider #### Props **`value`** Type: `ColorPickerApi` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`lazyMount`** Type: `boolean` Required: false Default Value: `false` Description: Whether to enable lazy mounting **`unmountOnExit`** Type: `boolean` Required: false Default Value: `false` Description: Whether to unmount on exit. ### SwatchGroup #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### SwatchIndicator #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Swatch #### Props **`value`** Type: `string | Color` Required: true Default Value: `undefined` Description: The color value **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`respectAlpha`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether to include the alpha channel in the color #### Data Attributes **`data-scope`**: color-picker **`data-part`**: swatch **`data-state`**: "checked" | "unchecked" **`data-value`**: The value of the item ### SwatchTrigger #### Props **`value`** Type: `string | Color` Required: true Default Value: `undefined` Description: The color value **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`disabled`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the swatch trigger is disabled #### Data Attributes **`data-scope`**: color-picker **`data-part`**: swatch-trigger **`data-state`**: "checked" | "unchecked" **`data-value`**: The value of the item **`data-disabled`**: Present when disabled ### TransparencyGrid #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`size`** Type: `string` Required: false Default Value: `undefined` Description: undefined ### Trigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: color-picker **`data-part`**: trigger **`data-disabled`**: Present when disabled **`data-readonly`**: Present when read-only **`data-invalid`**: Present when invalid **`data-placement`**: The placement of the trigger **`data-state`**: "open" | "closed" **`data-focus`**: Present when focused ### ValueSwatch #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`respectAlpha`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether to include the alpha channel in the color ### ValueText #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: color-picker **`data-part`**: value-text **`data-disabled`**: Present when disabled **`data-focus`**: Present when focused ### View #### Props **`format`** Type: `ColorFormat` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ## Accessibility ### Keyboard Support **`Enter`** Description: When focus is on the trigger, opens the color picker
                When focus is on a trigger of a swatch, selects the color (and closes the color picker)
                When focus is on the input or channel inputs, selects the color
                **`ArrowLeft`** Description: When focus is on the color area, decreases the hue value of the color
                When focus is on the channel sliders, decreases the value of the channel
                **`ArrowRight`** Description: When focus is on the color area, increases the hue value of the color
                When focus is on the channel sliders, increases the value of the channel
                **`ArrowUp`** Description: When focus is on the color area, increases the saturation value of the color
                When focus is on the channel sliders, increases the value of the channel
                **`ArrowDown`** Description: When focus is on the color area, decreases the saturation value of the color
                When focus is on the channel sliders, decreases the value of the channel
                **`Esc`** Description: Closes the color picker and moves focus to the trigger # Combobox ## Anatomy To set up the combobox correctly, you'll need to understand its anatomy and how we name its parts. > Each part includes a `data-part` attribute to help identify them in the DOM. ## Examples Learn how to use the `Combobox` component in your project. Let's take a look at the most basic example ```vue ``` ### Advanced Customization Extended example that shows usage with complex item objects, including disabled state for certain options. ```vue ``` ### Using the Field Component The `Field` component helps manage form-related state and accessibility attributes of a combobox. It includes handling ARIA labels, helper text, and error text to ensure proper accessibility. ```vue ``` ### Using the Root Provider The `RootProvider` component provides a context for the combobox. It accepts the value of the `useCombobox` hook. You can leverage it to access the component state and methods from outside the combobox. ```vue ``` > If you're using the `RootProvider` component, you don't need to use the `Root` component. ## API Reference ### Root #### Props **`allowCustomValue`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether to allow typing custom values in the input **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`autoFocus`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether to autofocus the input on mount **`closeOnSelect`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether to close the combobox when an item is selected. **`collection`** Type: `ListCollection` Required: false Default Value: `undefined` Description: The collection of items **`composite`** Type: `boolean` Required: false Default Value: `true` Description: Whether the combobox is a composed with other composite widgets like tabs **`defaultHighlightedValue`** Type: `string` Required: false Default Value: `undefined` Description: The initial highlighted value of the combobox when rendered. Use when you don't need to control the highlighted value of the combobox. **`defaultInputValue`** Type: `string` Required: false Default Value: `""` Description: The initial value of the combobox's input when rendered. Use when you don't need to control the value of the combobox's input. **`defaultOpen`** Type: `boolean` Required: false Default Value: `undefined` Description: The initial open state of the combobox when rendered. Use when you don't need to control the open state of the combobox. **`defaultValue`** Type: `string[]` Required: false Default Value: `[]` Description: The initial value of the combobox's selected items when rendered. Use when you don't need to control the value of the combobox's selected items. **`disabled`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the combobox is disabled **`disableLayer`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether to disable registering this a dismissable layer **`form`** Type: `string` Required: false Default Value: `undefined` Description: The associate form of the combobox. **`highlightedValue`** Type: `string` Required: false Default Value: `undefined` Description: The controlled highlighted value of the combobox **`id`** Type: `string` Required: false Default Value: `undefined` Description: The unique identifier of the machine. **`ids`** Type: `Partial<{ root: string label: string control: string input: string content: string trigger: string clearTrigger: string item(id: string, index?: number | undefined): string positioner: string itemGroup(id: string | number): string itemGroupLabel(id: string | number): string }>` Required: false Default Value: `undefined` Description: The ids of the elements in the combobox. Useful for composition. **`inputBehavior`** Type: `'autocomplete' | 'none' | 'autohighlight'` Required: false Default Value: `"none"` Description: Defines the auto-completion behavior of the combobox. - `autohighlight`: The first focused item is highlighted as the user types - `autocomplete`: Navigating the listbox with the arrow keys selects the item and the input is updated **`inputValue`** Type: `string` Required: false Default Value: `undefined` Description: The controlled value of the combobox's input **`invalid`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the combobox is invalid **`lazyMount`** Type: `boolean` Required: false Default Value: `false` Description: Whether to enable lazy mounting **`loopFocus`** Type: `boolean` Required: false Default Value: `true` Description: Whether to loop the keyboard navigation through the items **`modelValue`** Type: `string[]` Required: false Default Value: `undefined` Description: The v-model value of the combobox **`multiple`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether to allow multiple selection. **Good to know:** When `multiple` is `true`, the `selectionBehavior` is automatically set to `clear`. It is recommended to render the selected items in a separate container. **`name`** Type: `string` Required: false Default Value: `undefined` Description: The `name` attribute of the combobox's input. Useful for form submission **`navigate`** Type: `(details: NavigateDetails) => void` Required: false Default Value: `undefined` Description: Function to navigate to the selected item **`open`** Type: `boolean` Required: false Default Value: `undefined` Description: The controlled open state of the combobox **`openOnChange`** Type: `boolean | ((details: InputValueChangeDetails) => boolean)` Required: false Default Value: `true` Description: Whether to show the combobox when the input value changes **`openOnClick`** Type: `boolean` Required: false Default Value: `false` Description: Whether to open the combobox popup on initial click on the input **`openOnKeyPress`** Type: `boolean` Required: false Default Value: `true` Description: Whether to open the combobox on arrow key press **`placeholder`** Type: `string` Required: false Default Value: `undefined` Description: The placeholder text of the combobox's input **`positioning`** Type: `PositioningOptions` Required: false Default Value: `{ placement: "bottom-start" }` Description: The positioning options to dynamically position the menu **`readOnly`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the combobox is readonly. This puts the combobox in a "non-editable" mode but the user can still interact with it **`required`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the combobox is required **`scrollToIndexFn`** Type: `(details: ScrollToIndexDetails) => void` Required: false Default Value: `undefined` Description: Function to scroll to a specific index **`selectionBehavior`** Type: `'replace' | 'clear' | 'preserve'` Required: false Default Value: `"replace"` Description: The behavior of the combobox input when an item is selected - `replace`: The selected item string is set as the input value - `clear`: The input value is cleared - `preserve`: The input value is preserved **`translations`** Type: `IntlTranslations` Required: false Default Value: `undefined` Description: Specifies the localized strings that identifies the accessibility elements and their states **`unmountOnExit`** Type: `boolean` Required: false Default Value: `false` Description: Whether to unmount on exit. #### Data Attributes **`data-scope`**: combobox **`data-part`**: root **`data-invalid`**: Present when invalid **`data-readonly`**: Present when read-only ### ClearTrigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: combobox **`data-part`**: clear-trigger **`data-invalid`**: Present when invalid ### Content #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: combobox **`data-part`**: content **`data-state`**: "open" | "closed" **`data-placement`**: The placement of the content ### Control #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: combobox **`data-part`**: control **`data-state`**: "open" | "closed" **`data-focus`**: Present when focused **`data-disabled`**: Present when disabled **`data-invalid`**: Present when invalid ### Input #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: combobox **`data-part`**: input **`data-invalid`**: Present when invalid **`data-state`**: "open" | "closed" ### ItemGroupLabel #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### ItemGroup #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`id`** Type: `string` Required: false Default Value: `undefined` Description: undefined ### ItemIndicator #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: combobox **`data-part`**: item-indicator **`data-state`**: "checked" | "unchecked" ### Item #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`item`** Type: `any` Required: false Default Value: `undefined` Description: The item to render **`persistFocus`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether hovering outside should clear the highlighted state #### Data Attributes **`data-scope`**: combobox **`data-part`**: item **`data-highlighted`**: Present when highlighted **`data-state`**: "checked" | "unchecked" **`data-disabled`**: Present when disabled **`data-value`**: The value of the item ### ItemText #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: combobox **`data-part`**: item-text **`data-state`**: "checked" | "unchecked" **`data-disabled`**: Present when disabled **`data-highlighted`**: Present when highlighted ### Label #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: combobox **`data-part`**: label **`data-readonly`**: Present when read-only **`data-disabled`**: Present when disabled **`data-invalid`**: Present when invalid **`data-focus`**: Present when focused ### List #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Positioner #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### RootProvider #### Props **`value`** Type: `ComboboxApi` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`lazyMount`** Type: `boolean` Required: false Default Value: `false` Description: Whether to enable lazy mounting **`unmountOnExit`** Type: `boolean` Required: false Default Value: `false` Description: Whether to unmount on exit. ### Trigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`focusable`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the trigger is focusable #### Data Attributes **`data-scope`**: combobox **`data-part`**: trigger **`data-state`**: "open" | "closed" **`data-invalid`**: Present when invalid **`data-focusable`**: **`data-readonly`**: Present when read-only **`data-disabled`**: Present when disabled ## Accessibility Complies with the [Combobox WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/combobox/). ### Keyboard Support **`ArrowDown`** Description: When the combobox is closed, opens the listbox and highlights to the first option. When the combobox is open, moves focus to the next option. **`ArrowUp`** Description: When the combobox is closed, opens the listbox and highlights to the last option. When the combobox is open, moves focus to the previous option. **`Home`** Description: When the combobox is open, moves focus to the first option. **`End`** Description: When the combobox is open, moves focus to the last option. **`Escape`** Description: Closes the listbox. **`Enter`** Description: Selects the highlighted option and closes the combobox. **`Esc`** Description: Closes the combobox # Date Picker ## Anatomy To set up the date picker correctly, you'll need to understand its anatomy and how we name its parts. > Each part includes a `data-part` attribute to help identify them in the DOM. ## Examples Learn how to use the `DatePicker` component in your project. Let's take a look at the most basic example ```vue ``` ### Range Selection To create a Date Picker that allows a range selection, set the `selectionMode` prop to `range`. ```vue ``` ### Standalone Date Picker In some cases, you might want to display a non-dismissible date picker. This can be achieved by setting the `open` prop to `true` and `closeOnSelect` prop to `false`. > Important to note that standalone date picker doesn't use the `Portal`, `Positioner` and `Content` components. ```vue ``` ### Using the Root Provider The `RootProvider` component provides a context for the date-picker. It accepts the value of the `useDate-picker` hook. You can leverage it to access the component state and methods from outside the date-picker. ```vue ``` > If you're using the `RootProvider` component, you don't need to use the `Root` component. ## API Reference ### Root #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`closeOnSelect`** Type: `boolean` Required: false Default Value: `true` Description: Whether the calendar should close after the date selection is complete. This is ignored when the selection mode is `multiple`. **`defaultFocusedValue`** Type: `DateValue` Required: false Default Value: `undefined` Description: The initial focused date when rendered. Use when you don't need to control the focused date of the date picker. **`defaultOpen`** Type: `boolean` Required: false Default Value: `undefined` Description: The initial open state of the date picker when rendered. Use when you don't need to control the open state of the date picker. **`defaultValue`** Type: `DateValue[]` Required: false Default Value: `undefined` Description: The initial selected date(s) when rendered. Use when you don't need to control the selected date(s) of the date picker. **`defaultView`** Type: `DateView` Required: false Default Value: `"day"` Description: The default view of the calendar **`disabled`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the calendar is disabled. **`fixedWeeks`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the calendar should have a fixed number of weeks. This renders the calendar with 6 weeks instead of 5 or 6. **`focusedValue`** Type: `DateValue` Required: false Default Value: `undefined` Description: The controlled focused date. **`format`** Type: `(date: DateValue, details: LocaleDetails) => string` Required: false Default Value: `undefined` Description: The format of the date to display in the input. **`id`** Type: `string` Required: false Default Value: `undefined` Description: The unique identifier of the machine. **`ids`** Type: `Partial<{ root: string; label(index: number): string; table(id: string): string; tableHeader(id: string): string; tableBody(id: string): string; tableRow(id: string): string; content: string; ... 10 more ...; positioner: string; }>` Required: false Default Value: `undefined` Description: The ids of the elements in the date picker. Useful for composition. **`isDateUnavailable`** Type: `(date: DateValue, locale: string) => boolean` Required: false Default Value: `undefined` Description: Returns whether a date of the calendar is available. **`lazyMount`** Type: `boolean` Required: false Default Value: `false` Description: Whether to enable lazy mounting **`locale`** Type: `string` Required: false Default Value: `"en-US"` Description: The locale (BCP 47 language tag) to use when formatting the date. **`max`** Type: `DateValue` Required: false Default Value: `undefined` Description: The maximum date that can be selected. **`maxView`** Type: `DateView` Required: false Default Value: `"year"` Description: The maximum view of the calendar **`min`** Type: `DateValue` Required: false Default Value: `undefined` Description: The minimum date that can be selected. **`minView`** Type: `DateView` Required: false Default Value: `"day"` Description: The minimum view of the calendar **`modelValue`** Type: `DateValue[]` Required: false Default Value: `undefined` Description: The v-model value of the date picker **`name`** Type: `string` Required: false Default Value: `undefined` Description: The `name` attribute of the input element. **`numOfMonths`** Type: `number` Required: false Default Value: `undefined` Description: The number of months to display. **`open`** Type: `boolean` Required: false Default Value: `undefined` Description: The controlled open state of the date picker **`parse`** Type: `(value: string, details: LocaleDetails) => DateValue | undefined` Required: false Default Value: `undefined` Description: Function to parse the date from the input back to a DateValue. **`placeholder`** Type: `string` Required: false Default Value: `undefined` Description: The placeholder text to display in the input. **`positioning`** Type: `PositioningOptions` Required: false Default Value: `undefined` Description: The user provided options used to position the date picker content **`readOnly`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the calendar is read-only. **`selectionMode`** Type: `SelectionMode` Required: false Default Value: `"single"` Description: The selection mode of the calendar. - `single` - only one date can be selected - `multiple` - multiple dates can be selected - `range` - a range of dates can be selected **`startOfWeek`** Type: `number` Required: false Default Value: `undefined` Description: The first day of the week. `0` - Sunday `1` - Monday `2` - Tuesday `3` - Wednesday `4` - Thursday `5` - Friday `6` - Saturday **`timeZone`** Type: `string` Required: false Default Value: `"UTC"` Description: The time zone to use **`translations`** Type: `IntlTranslations` Required: false Default Value: `undefined` Description: The localized messages to use. **`unmountOnExit`** Type: `boolean` Required: false Default Value: `false` Description: Whether to unmount on exit. **`view`** Type: `DateView` Required: false Default Value: `undefined` Description: The view of the calendar #### Emits **`focusChange`** Type: `[details: FocusChangeDetails]` Description: Function called when the focused date changes. **`openChange`** Type: `[details: OpenChangeDetails]` Description: Function called when the calendar opens or closes. **`update:focusedValue`** Type: `[focusedValue: DateValue]` Description: The callback fired when the focused date changes. **`update:modelValue`** Type: `[value: DateValue[]]` Description: The callback fired when the model value changes. **`update:open`** Type: `[open: boolean]` Description: The callback fired when the open state changes. **`update:view`** Type: `[view: DateView]` Description: The callback fired when the view changes. **`valueChange`** Type: `[details: ValueChangeDetails]` Description: Function called when the value changes. **`viewChange`** Type: `[details: ViewChangeDetails]` Description: Function called when the view changes. #### Data Attributes **`data-scope`**: date-picker **`data-part`**: root **`data-state`**: "open" | "closed" **`data-disabled`**: Present when disabled **`data-readonly`**: Present when read-only ### ClearTrigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Content #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: date-picker **`data-part`**: content **`data-state`**: "open" | "closed" **`data-placement`**: The placement of the content ### Control #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: date-picker **`data-part`**: control **`data-disabled`**: Present when disabled ### Input #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`fixOnBlur`** Type: `boolean` Required: false Default Value: `true` Description: Whether to fix the input value on blur. **`index`** Type: `number` Required: false Default Value: `undefined` Description: The index of the input to focus. #### Data Attributes **`data-scope`**: date-picker **`data-part`**: input **`data-index`**: The index of the item **`data-state`**: "open" | "closed" ### Label #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: date-picker **`data-part`**: label **`data-state`**: "open" | "closed" **`data-index`**: The index of the item **`data-disabled`**: Present when disabled **`data-readonly`**: Present when read-only ### MonthSelect #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### NextTrigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: date-picker **`data-part`**: next-trigger **`data-disabled`**: Present when disabled ### Positioner #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### PresetTrigger #### Props **`value`** Type: `PresetTriggerValue` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### PrevTrigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: date-picker **`data-part`**: prev-trigger **`data-disabled`**: Present when disabled ### RangeText #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### RootProvider #### Props **`value`** Type: `DatePickerApi` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`lazyMount`** Type: `boolean` Required: false Default Value: `false` Description: Whether to enable lazy mounting **`unmountOnExit`** Type: `boolean` Required: false Default Value: `false` Description: Whether to unmount on exit. ### TableBody #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: date-picker **`data-part`**: table-body **`data-view`**: The view of the tablebody **`data-disabled`**: Present when disabled ### TableCell #### Props **`value`** Type: `Reactive` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`columns`** Type: `number` Required: false Default Value: `undefined` Description: undefined **`disabled`** Type: `boolean` Required: false Default Value: `undefined` Description: undefined **`visibleRange`** Type: `VisibleRange` Required: false Default Value: `undefined` Description: undefined ### TableCellTrigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### TableHead #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: date-picker **`data-part`**: table-head **`data-view`**: The view of the tablehead **`data-disabled`**: Present when disabled ### TableHeader #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: date-picker **`data-part`**: table-header **`data-view`**: The view of the tableheader **`data-disabled`**: Present when disabled ### Table #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`columns`** Type: `number` Required: false Default Value: `undefined` Description: undefined **`id`** Type: `string` Required: false Default Value: `undefined` Description: undefined **`view`** Type: `DateView` Required: false Default Value: `undefined` Description: undefined #### Data Attributes **`data-scope`**: date-picker **`data-part`**: table **`data-columns`**: **`data-view`**: The view of the table ### TableRow #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: date-picker **`data-part`**: table-row **`data-disabled`**: Present when disabled **`data-view`**: The view of the tablerow ### Trigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: date-picker **`data-part`**: trigger **`data-placement`**: The placement of the trigger **`data-state`**: "open" | "closed" ### ViewControl #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: date-picker **`data-part`**: view-control **`data-view`**: The view of the viewcontrol ### View #### Props **`view`** Type: `DateView` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: date-picker **`data-part`**: view **`data-view`**: The view of the view ### ViewTrigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: date-picker **`data-part`**: view-trigger **`data-view`**: The view of the viewtrigger ### YearSelect #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ## Accessibility ### Keyboard Support **`ArrowLeft`** Description: Moves focus to the previous day within the current week. **`ArrowRight`** Description: Moves focus to the next day within the current week. **`ArrowUp`** Description: Moves focus to the same day of the week in the previous week. **`ArrowDown`** Description: Moves focus to the same day of the week in the next week. **`Home`** Description: Moves focus to the first day of the current month. **`End`** Description: Moves focus to the last day of the current month. **`PageUp`** Description: Moves focus to the same day of the month in the previous month. **`PageDown`** Description: Moves focus to the same day of the month in the next month. **`Enter`** Description: Selects the focused date and closes the date picker. **`Esc`** Description: Closes the date picker without selecting any date. # Dialog ## Anatomy To use the dialog component correctly, you'll need to understand its anatomy and how we name its parts. > Each part includes a `data-part` attribute to help identify them in the DOM. ## Examples Learn how to use the `Dialog` component in your project. Let's take a look at the most basic example ```vue ``` ### Controlled Dialog To create a controlled Dialog component, manage the state of the dialog using the `open` and `onOpenChange` props: ```vue ``` ### Lazy Mounting Lazy mounting is a feature that allows the content of a dialog to be rendered only when the dialog is first opened. This is useful for performance optimization, especially when dialog content is large or complex. To enable lazy mounting, use the `lazyMount` prop on the `Dialog.Root` component. In addition, the `unmountOnExit` prop can be used in conjunction with `lazyMount` to unmount the dialog content when the Dialog is closed, freeing up resources. The next time the dialog is activated, its content will be re-rendered. ```vue ``` ### Using Render Function The Dialog component supports the use of a render function as a child for more control. This allows access to dialog states like `isOpen`: ```vue ``` ### Using the Root Provider The `RootProvider` component provides a context for the dialog. It accepts the value of the `useDialog` hook. You can leverage it to access the component state and methods from outside the dialog. ```vue ``` > If you're using the `RootProvider` component, you don't need to use the `Root` component. ## API Reference ### Root #### Props **`aria-label`** Type: `string` Required: false Default Value: `undefined` Description: Human readable label for the dialog, in event the dialog title is not rendered **`closeOnEscape`** Type: `boolean` Required: false Default Value: `true` Description: Whether to close the dialog when the escape key is pressed **`closeOnInteractOutside`** Type: `boolean` Required: false Default Value: `true` Description: Whether to close the dialog when the outside is clicked **`defaultOpen`** Type: `boolean` Required: false Default Value: `false` Description: The initial open state of the dialog when rendered. Use when you don't need to control the open state of the dialog. **`finalFocusEl`** Type: `() => HTMLElement | null` Required: false Default Value: `undefined` Description: Element to receive focus when the dialog is closed **`id`** Type: `string` Required: false Default Value: `undefined` Description: The unique identifier of the machine. **`ids`** Type: `Partial<{ trigger: string positioner: string backdrop: string content: string closeTrigger: string title: string description: string }>` Required: false Default Value: `undefined` Description: The ids of the elements in the dialog. Useful for composition. **`initialFocusEl`** Type: `() => HTMLElement | null` Required: false Default Value: `undefined` Description: Element to receive focus when the dialog is opened **`lazyMount`** Type: `boolean` Required: false Default Value: `false` Description: Whether to enable lazy mounting **`modal`** Type: `boolean` Required: false Default Value: `true` Description: Whether to prevent pointer interaction outside the element and hide all content below it **`open`** Type: `boolean` Required: false Default Value: `undefined` Description: The controlled open state of the dialog **`persistentElements`** Type: `(() => Element | null)[]` Required: false Default Value: `undefined` Description: Returns the persistent elements that: - should not have pointer-events disabled - should not trigger the dismiss event **`preventScroll`** Type: `boolean` Required: false Default Value: `true` Description: Whether to prevent scrolling behind the dialog when it's opened **`restoreFocus`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether to restore focus to the element that had focus before the dialog was opened **`role`** Type: `'dialog' | 'alertdialog'` Required: false Default Value: `"dialog"` Description: The dialog's role **`trapFocus`** Type: `boolean` Required: false Default Value: `true` Description: Whether to trap focus inside the dialog when it's opened **`unmountOnExit`** Type: `boolean` Required: false Default Value: `false` Description: Whether to unmount on exit. #### Emits **`escapeKeyDown`** Type: `[event: KeyboardEvent]` Description: Function called when the escape key is pressed **`focusOutside`** Type: `[event: FocusOutsideEvent]` Description: Function called when the focus is moved outside the component **`interactOutside`** Type: `[event: InteractOutsideEvent]` Description: Function called when an interaction happens outside the component **`openChange`** Type: `[details: OpenChangeDetails]` Description: Function to call when the dialog's open state changes **`pointerDownOutside`** Type: `[event: PointerDownOutsideEvent]` Description: Function called when the pointer is pressed down outside the component **`update:open`** Type: `[open: boolean]` Description: The callback fired when the open state changes. ### Backdrop #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: dialog **`data-part`**: backdrop **`data-state`**: "open" | "closed" ### CloseTrigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Content #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: dialog **`data-part`**: content **`data-state`**: "open" | "closed" ### Description #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Positioner #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### RootProvider #### Props **`value`** Type: `DialogApi` Required: true Default Value: `undefined` Description: undefined **`lazyMount`** Type: `boolean` Required: false Default Value: `false` Description: Whether to enable lazy mounting **`unmountOnExit`** Type: `boolean` Required: false Default Value: `false` Description: Whether to unmount on exit. ### Title #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Trigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: dialog **`data-part`**: trigger **`data-state`**: "open" | "closed" ## Accessibility Complies with the [Dialog WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/). ### Keyboard Support **`Enter`** Description: When focus is on the trigger, opens the dialog. **`Tab`** Description: Moves focus to the next focusable element within the content. Focus is trapped within the dialog. **`Shift + Tab`** Description: Moves focus to the previous focusable element. Focus is trapped within the dialog. **`Esc`** Description: Closes the dialog and moves focus to trigger or the defined final focus element # Editable ## Anatomy To set up the editable correctly, you'll need to understand its anatomy and how we name its parts. > Each part includes a `data-part` attribute to help identify them in the DOM. ## Examples Learn how to use the `Editable` component in your project. Let's take a look at the most basic example: ```vue ``` ### Using custom controls In some cases, you might need to use custom controls to toggle the edit and read mode. We use the render prop pattern to provide access to the internal state of the component. ```vue ``` ### Auto-resizing the editable To auto-grow the editable as the content changes, set the `autoResize` prop to `true`. ```tsx {/*...*/} ``` ### Setting a maxWidth It is a common pattern to set a maximum of the editable as it auto-grows. To achieve this, set the `maxWidth` prop to the desired value. ```tsx {/*...*/} ``` ### Editing with double click The editable supports two modes of activating the "edit" state: - when the preview part is focused (with pointer or keyboard). - when the preview part is double-clicked. To change the mode to double-click, pass the prop `activationMode="dblclick"`. ```tsx {/*...*/} ``` ### Using the Field Component The `Field` component helps manage form-related state and accessibility attributes of an editable. It includes handling ARIA labels, helper text, and error text to ensure proper accessibility. ```vue ``` ### Using the Root Provider The `RootProvider` component provides a context for the editable. It accepts the value of the `useEditable` hook. You can leverage it to access the component state and methods from outside the editable. ```vue ``` > If you're using the `RootProvider` component, you don't need to use the `Root` component. ## API Reference ### Root #### Props **`activationMode`** Type: `ActivationMode` Required: false Default Value: `"focus"` Description: The activation mode for the preview element. - "focus" - Enter edit mode when the preview is focused - "dblclick" - Enter edit mode when the preview is double-clicked - "click" - Enter edit mode when the preview is clicked **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`autoResize`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the editable should auto-resize to fit the content. **`defaultEdit`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the editable is in edit mode by default. **`defaultValue`** Type: `string` Required: false Default Value: `undefined` Description: The initial value of the editable when rendered. Use when you don't need to control the value of the editable. **`disabled`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the editable is disabled. **`edit`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the editable is in edit mode. **`finalFocusEl`** Type: `() => HTMLElement | null` Required: false Default Value: `undefined` Description: The element to receive focus when the editable is closed. **`form`** Type: `string` Required: false Default Value: `undefined` Description: The associate form of the underlying input. **`id`** Type: `string` Required: false Default Value: `undefined` Description: The unique identifier of the machine. **`ids`** Type: `Partial<{ root: string area: string label: string preview: string input: string control: string submitTrigger: string cancelTrigger: string editTrigger: string }>` Required: false Default Value: `undefined` Description: The ids of the elements in the editable. Useful for composition. **`invalid`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the input's value is invalid. **`maxLength`** Type: `number` Required: false Default Value: `undefined` Description: The maximum number of characters allowed in the editable **`modelValue`** Type: `string` Required: false Default Value: `undefined` Description: The v-model value of the editable **`name`** Type: `string` Required: false Default Value: `undefined` Description: The name attribute of the editable component. Used for form submission. **`placeholder`** Type: `string | { edit: string; preview: string }` Required: false Default Value: `undefined` Description: The placeholder text for the editable. **`readOnly`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the editable is read-only. **`required`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the editable is required. **`selectOnFocus`** Type: `boolean` Required: false Default Value: `true` Description: Whether to select the text in the input when it is focused. **`submitMode`** Type: `SubmitMode` Required: false Default Value: `"both"` Description: The action that triggers submit in the edit mode: - "enter" - Trigger submit when the enter key is pressed - "blur" - Trigger submit when the editable is blurred - "none" - No action will trigger submit. You need to use the submit button - "both" - Pressing `Enter` and blurring the input will trigger submit **`translations`** Type: `IntlTranslations` Required: false Default Value: `undefined` Description: The translations for the editable. #### Emits **`editChange`** Type: `[details: EditChangeDetails]` Description: Function to call when the edit mode changes. **`focusOutside`** Type: `[event: FocusOutsideEvent]` Description: Function called when the focus is moved outside the component **`interactOutside`** Type: `[event: InteractOutsideEvent]` Description: Function called when an interaction happens outside the component **`pointerDownOutside`** Type: `[event: PointerDownOutsideEvent]` Description: Function called when the pointer is pressed down outside the component **`update:edit`** Type: `[edit: boolean]` Description: Event handler called when the edit state of the editable changes. **`update:modelValue`** Type: `[value: string]` Description: The callback fired when the model value changes. **`valueChange`** Type: `[details: ValueChangeDetails]` Description: Function to call when the value changes. **`valueCommit`** Type: `[details: ValueChangeDetails]` Description: Function to call when the value is committed. **`valueRevert`** Type: `[details: ValueChangeDetails]` Description: Function to call when the value is reverted. ### Area #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: editable **`data-part`**: area **`data-focus`**: Present when focused **`data-disabled`**: Present when disabled **`data-placeholder-shown`**: Present when placeholder is shown ### CancelTrigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Control #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### EditTrigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Input #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: editable **`data-part`**: input **`data-disabled`**: Present when disabled **`data-readonly`**: Present when read-only **`data-invalid`**: Present when invalid **`data-autoresize`**: ### Label #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: editable **`data-part`**: label **`data-focus`**: Present when focused **`data-invalid`**: Present when invalid ### Preview #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: editable **`data-part`**: preview **`data-placeholder-shown`**: Present when placeholder is shown **`data-readonly`**: Present when read-only **`data-disabled`**: Present when disabled **`data-invalid`**: Present when invalid **`data-autoresize`**: ### RootProvider #### Props **`value`** Type: `EditableApi` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### SubmitTrigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ## Accessibility ### Keyboard Support **`Enter`** Description: Saves the edited content and exits edit mode. **`Escape`** Description: Discards the changes and exits edit mode. # Field ## Examples The `Field` component provides contexts such as `invalid`, `disabled`, `required`, and `readOnly` for form elements. While most Ark UI components natively support these contexts, you can also use the `Field` component with standard HTML form elements. ### Input This example shows how to use the `Field` component with a standard input field. ```vue ``` ### Textarea This example illustrates how to use the `Field` component with a textarea element. ```vue ``` ### Textarea Autoresize Pass the `autoresize` prop to the `Textarea` component to enable automatic resizing as the user types. ```vue ``` ### Select This example demonstrates how to integrate the `Field` component with a select dropdown. ```vue ``` ### Using Ark Components This example demonstrates how to integrate the `Field` and `Checkbox` components. For more examples of using the `Field` component with various Ark UI elements, refer to their respective documentation. ```vue ``` ### Using the Root Provider The `RootProvider` component provides a context for the field. It accepts the value of the `useField` hook. You can leverage it to access the component state and methods from outside the field. ```vue ``` > If you're using the `RootProvider` component, you don't need to use the `Root` component. ## API Reference ### Root #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`disabled`** Type: `boolean` Required: false Default Value: `undefined` Description: Indicates whether the field is disabled. **`id`** Type: `string` Required: false Default Value: `undefined` Description: The id of the field. **`ids`** Type: `ElementIds` Required: false Default Value: `undefined` Description: The ids of the field parts. **`invalid`** Type: `boolean` Required: false Default Value: `undefined` Description: Indicates whether the field is invalid. **`readOnly`** Type: `boolean` Required: false Default Value: `undefined` Description: Indicates whether the field is read-only. **`required`** Type: `boolean` Required: false Default Value: `undefined` Description: Indicates whether the field is required. ### ErrorText #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### HelperText #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Input #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`modelValue`** Type: `any` Required: false Default Value: `undefined` Description: undefined ### Label #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### RequiredIndicator #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### RootProvider #### Props **`value`** Type: `{ ariaDescribedby: string | undefined; ids: { control: string; label: string; errorText: string; helperText: string; }; refs: { rootRef: Ref; }; disabled: boolean | undefined; ... 10 more ...; getRequiredIndicatorProps: () => HTMLAttributes; }` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Select #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`modelValue`** Type: `any` Required: false Default Value: `undefined` Description: undefined ### Textarea #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`autoresize`** Type: `boolean` Required: false Default Value: `false` Description: Whether the textarea should autoresize **`modelValue`** Type: `string | number | readonly string[]` Required: false Default Value: `undefined` Description: undefined # Fieldset ## Examples The `Fieldset` component provides contexts such as `invalid` and `disabled` for form elements. While most Ark UI components natively support these contexts, you can also use the `Field` component with standard HTML form elements. ### Basic Usage Learn how to use the `Fieldset` component in your project. Let's take a look at the most basic example: ```vue ``` ### Fieldset with Fields This example demonstrates how to use the `Field` component with a standard input field within a `Fieldset`. ```vue ``` ### Fieldset with other Form Elements This example shows how to use the `Fieldset` component with other Ark UI form elements like `Checkbox`. ```vue ``` ### Using the Root Provider The `RootProvider` component provides a context for the fieldset. It accepts the value of the `useFieldset` hook. You can leverage it to access the component state and methods from outside the fieldset. ```vue Example not found``` > If you're using the `RootProvider` component, you don't need to use the `Root` component. ## API Reference ### Root #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`disabled`** Type: `boolean | 'true' | 'false'` Required: false Default Value: `undefined` Description: Indicates whether the fieldset is disabled. **`id`** Type: `string` Required: false Default Value: `undefined` Description: The id of the fieldset. **`invalid`** Type: `boolean` Required: false Default Value: `undefined` Description: Indicates whether the fieldset is invalid. ### ErrorText #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### HelperText #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Legend #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### RootProvider #### Props **`value`** Type: `{ refs: { rootRef: Ref; }; disabled: boolean | "true" | "false" | undefined; invalid: boolean | undefined; getRootProps: () => FieldsetHTMLAttributes; getLegendProps: () => { ...; }; getHelperTextProps: () => { ...; }; getErrorTextProps: () => HTMLAttributes; }` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. # File Upload ## Anatomy To set up the file upload component correctly, you'll need to understand its anatomy and how we name its parts. > Each part includes a `data-part` attribute to help identify them in the DOM. ## Examples Learn how to use the `FileUpload` component in your project. Let's take a look at the most basic example: ```vue ``` ### Using the Field Component The `Field` component helps manage form-related state and accessibility attributes of an file upload. It includes handling ARIA labels, helper text, and error text to ensure proper accessibility. ```vue ``` ### Using the Root Provider The `RootProvider` component provides a context for the file-upload. It accepts the value of the `useFile-upload` hook. You can leverage it to access the component state and methods from outside the file-upload. ```vue ``` > If you're using the `RootProvider` component, you don't need to use the `Root` component. ## API Reference ### Root #### Props **`accept`** Type: `Record | FileMimeType | FileMimeType[]` Required: false Default Value: `undefined` Description: The accept file types **`allowDrop`** Type: `boolean` Required: false Default Value: `true` Description: Whether to allow drag and drop in the dropzone element **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`capture`** Type: `'user' | 'environment'` Required: false Default Value: `undefined` Description: The default camera to use when capturing media **`directory`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether to accept directories, only works in webkit browsers **`disabled`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the file input is disabled **`id`** Type: `string` Required: false Default Value: `undefined` Description: The unique identifier of the machine. **`ids`** Type: `Partial<{ root: string dropzone: string hiddenInput: string trigger: string label: string item(id: string): string itemName(id: string): string itemSizeText(id: string): string itemPreview(id: string): string }>` Required: false Default Value: `undefined` Description: The ids of the elements. Useful for composition. **`invalid`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the file input is invalid **`locale`** Type: `string` Required: false Default Value: `"en-US"` Description: The current locale. Based on the BCP 47 definition. **`maxFiles`** Type: `number` Required: false Default Value: `1` Description: The maximum number of files **`maxFileSize`** Type: `number` Required: false Default Value: `Infinity` Description: The maximum file size in bytes **`minFileSize`** Type: `number` Required: false Default Value: `0` Description: The minimum file size in bytes **`name`** Type: `string` Required: false Default Value: `undefined` Description: The name of the underlying file input **`preventDocumentDrop`** Type: `boolean` Required: false Default Value: `true` Description: Whether to prevent the drop event on the document **`required`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the file input is required **`translations`** Type: `IntlTranslations` Required: false Default Value: `undefined` Description: The localized messages to use. **`validate`** Type: `(file: File, details: FileValidateDetails) => FileError[] | null` Required: false Default Value: `undefined` Description: Function to validate a file #### Emits **`fileAccept`** Type: `[details: FileAcceptDetails]` Description: Function called when the file is accepted **`fileChange`** Type: `[details: FileChangeDetails]` Description: Function called when the value changes, whether accepted or rejected **`fileReject`** Type: `[details: FileRejectDetails]` Description: Function called when the file is rejected #### Data Attributes **`data-scope`**: file-upload **`data-part`**: root **`data-disabled`**: Present when disabled **`data-dragging`**: Present when in the dragging state ### ClearTrigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: file-upload **`data-part`**: clear-trigger **`data-disabled`**: Present when disabled ### Dropzone #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`disableClick`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether to disable the click event on the dropzone #### Data Attributes **`data-scope`**: file-upload **`data-part`**: dropzone **`data-invalid`**: Present when invalid **`data-disabled`**: Present when disabled **`data-dragging`**: Present when in the dragging state ### HiddenInput #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### ItemDeleteTrigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: file-upload **`data-part`**: item-delete-trigger **`data-disabled`**: Present when disabled ### ItemGroup #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: file-upload **`data-part`**: item-group **`data-disabled`**: Present when disabled ### ItemName #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: file-upload **`data-part`**: item-name **`data-disabled`**: Present when disabled ### ItemPreviewImage #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: file-upload **`data-part`**: item-preview-image **`data-disabled`**: Present when disabled ### ItemPreview #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`type`** Type: `string` Required: false Default Value: `'.*'` Description: The file type to match against. Matches all file types by default. #### Data Attributes **`data-scope`**: file-upload **`data-part`**: item-preview **`data-disabled`**: Present when disabled ### Item #### Props **`file`** Type: `File` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: file-upload **`data-part`**: item **`data-disabled`**: Present when disabled ### ItemSizeText #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: file-upload **`data-part`**: item-size-text **`data-disabled`**: Present when disabled ### Label #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: file-upload **`data-part`**: label **`data-disabled`**: Present when disabled ### RootProvider #### Props **`value`** Type: `FileUploadApi` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Trigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: file-upload **`data-part`**: trigger **`data-disabled`**: Present when disabled **`data-invalid`**: Present when invalid # Hover Card ## Anatomy To set up the hover card correctly, you'll need to understand its anatomy and how we name its parts. > Each part includes a `data-part` attribute to help identify them in the DOM. ## Examples Learn how to use the `HoverCard` component in your project. Let's take a look at the most basic example: ```vue ``` ### Controlled HoverCard The controlled `HoverCard` component provides an interface for managing the state of the hover card using the `open` and `onOpenChange` props: ```vue ``` ### Custom Positioning The `HoverCard` component can be customized in its placement and distance from the trigger element through the `positioning` prop: ```vue ``` ### Render Prop Usage The `HoverCard` component can also accept a render prop, giving the user more control over rendering behavior. This is useful for dynamically updating the trigger based on the state of the `HoverCard`: ```vue ``` ### Using the Root Provider The `RootProvider` component provides a context for the hover-card. It accepts the value of the `useHover-card` hook. You can leverage it to access the component state and methods from outside the hover-card. ```vue ``` > If you're using the `RootProvider` component, you don't need to use the `Root` component. ## API Reference ### Root #### Props **`closeDelay`** Type: `number` Required: false Default Value: `300` Description: The duration from when the mouse leaves the trigger or content until the hover card closes. **`defaultOpen`** Type: `boolean` Required: false Default Value: `undefined` Description: The initial open state of the hover card when rendered. Use when you don't need to control the open state of the hover card. **`id`** Type: `string` Required: false Default Value: `undefined` Description: The unique identifier of the machine. **`ids`** Type: `Partial<{ trigger: string; content: string; positioner: string; arrow: string }>` Required: false Default Value: `undefined` Description: The ids of the elements in the popover. Useful for composition. **`lazyMount`** Type: `boolean` Required: false Default Value: `false` Description: Whether to enable lazy mounting **`open`** Type: `boolean` Required: false Default Value: `undefined` Description: The controlled open state of the hover card **`openDelay`** Type: `number` Required: false Default Value: `700` Description: The duration from when the mouse enters the trigger until the hover card opens. **`positioning`** Type: `PositioningOptions` Required: false Default Value: `undefined` Description: The user provided options used to position the popover content **`unmountOnExit`** Type: `boolean` Required: false Default Value: `false` Description: Whether to unmount on exit. #### Emits **`focusOutside`** Type: `[event: FocusOutsideEvent]` Description: Function called when the focus is moved outside the component **`interactOutside`** Type: `[event: InteractOutsideEvent]` Description: Function called when an interaction happens outside the component **`openChange`** Type: `[details: OpenChangeDetails]` Description: Function called when the hover card opens or closes. **`pointerDownOutside`** Type: `[event: PointerDownOutsideEvent]` Description: Function called when the pointer is pressed down outside the component **`update:open`** Type: `[open: boolean]` Description: The callback fired when the open state changes. ### Arrow #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### ArrowTip #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Content #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: hover-card **`data-part`**: content **`data-state`**: "open" | "closed" **`data-placement`**: The placement of the content ### Positioner #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### RootProvider #### Props **`value`** Type: `HoverCardApi` Required: true Default Value: `undefined` Description: undefined **`lazyMount`** Type: `boolean` Required: false Default Value: `false` Description: Whether to enable lazy mounting **`unmountOnExit`** Type: `boolean` Required: false Default Value: `false` Description: Whether to unmount on exit. ### Trigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: hover-card **`data-part`**: trigger **`data-placement`**: The placement of the trigger **`data-state`**: "open" | "closed" # Menu ## Anatomy To set up the menu correctly, you'll need to understand its anatomy and how we name its parts. > Each part includes a `data-part` attribute to help identify them in the DOM. ## Examples Learn how to use the `Menu` component in your project. Let's take a look at the most basic example: ```vue ``` ### Listening to item selection Pass the `onSelect` prop to the Menu component to perform some custom logic when an item is selected. The callback is invoked with the `id` of the item. ```vue ``` ### Grouping menu items When the number of menu items gets much, it might be useful to group related menu items. To achieve this, render the `Menu.ItemGroup` component around the `Menu.Item` components. The `Menu.ItemGroupLabel` component can be used to add a label to the group. ```vue ``` ### Separating menu items To separate menu items, render the `Menu.Separator` component. ```vue ``` ### Context menu To show the menu when a trigger element is right-clicked, use the `Menu.ContextTrigger` component. Context menus are also opened during a long-press of roughly `700ms` when the pointer is pen or touch. ```vue ``` ### Nested menu To show a nested menu, render another `Menu` component and use the `Menu.TriggerItem` component to open the submenu. ```vue ``` ### Checkbox To add a checkbox to a menu item, use the `Menu.Checkbox` component. ```vue ``` ### Radio Group To group radio option items, use the `Menu.RadioGroup` component. ```vue ``` ### Using the Root Provider The `RootProvider` component provides a context for the menu. It accepts the value of the `useMenu` hook. You can leverage it to access the component state and methods from outside the menu. ```vue ``` > If you're using the `RootProvider` component, you don't need to use the `Root` component. ## API Reference ### Root #### Props **`anchorPoint`** Type: `Point` Required: false Default Value: `undefined` Description: The positioning point for the menu. Can be set by the context menu trigger or the button trigger. **`aria-label`** Type: `string` Required: false Default Value: `undefined` Description: The accessibility label for the menu **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`closeOnSelect`** Type: `boolean` Required: false Default Value: `true` Description: Whether to close the menu when an option is selected **`composite`** Type: `boolean` Required: false Default Value: `true` Description: Whether the menu is a composed with other composite widgets like a combobox or tabs **`defaultHighlightedValue`** Type: `string` Required: false Default Value: `undefined` Description: The initial highlighted value of the menu item when rendered. Use when you don't need to control the highlighted value of the menu item. **`defaultOpen`** Type: `boolean` Required: false Default Value: `undefined` Description: The initial open state of the menu when rendered. Use when you don't need to control the open state of the menu. **`highlightedValue`** Type: `string` Required: false Default Value: `undefined` Description: The controlled highlighted value of the menu item. **`id`** Type: `string` Required: false Default Value: `undefined` Description: The unique identifier of the machine. **`ids`** Type: `Partial<{ trigger: string contextTrigger: string content: string groupLabel(id: string): string group(id: string): string positioner: string arrow: string }>` Required: false Default Value: `undefined` Description: The ids of the elements in the menu. Useful for composition. **`lazyMount`** Type: `boolean` Required: false Default Value: `false` Description: Whether to enable lazy mounting **`loopFocus`** Type: `boolean` Required: false Default Value: `false` Description: Whether to loop the keyboard navigation. **`navigate`** Type: `(details: NavigateDetails) => void` Required: false Default Value: `undefined` Description: Function to navigate to the selected item if it's an anchor element **`open`** Type: `boolean` Required: false Default Value: `undefined` Description: The controlled open state of the menu **`positioning`** Type: `PositioningOptions` Required: false Default Value: `undefined` Description: The options used to dynamically position the menu **`typeahead`** Type: `boolean` Required: false Default Value: `true` Description: Whether the pressing printable characters should trigger typeahead navigation **`unmountOnExit`** Type: `boolean` Required: false Default Value: `false` Description: Whether to unmount on exit. #### Emits **`escapeKeyDown`** Type: `[event: KeyboardEvent]` Description: Function called when the escape key is pressed **`focusOutside`** Type: `[event: FocusOutsideEvent]` Description: Function called when the focus is moved outside the component **`highlightChange`** Type: `[details: HighlightChangeDetails]` Description: Function called when the highlighted menu item changes. **`interactOutside`** Type: `[event: InteractOutsideEvent]` Description: Function called when an interaction happens outside the component **`openChange`** Type: `[details: OpenChangeDetails]` Description: Function called when the menu opens or closes **`pointerDownOutside`** Type: `[event: PointerDownOutsideEvent]` Description: Function called when the pointer is pressed down outside the component **`select`** Type: `[details: SelectionDetails]` Description: Function called when a menu item is selected. **`update:highlightedValue`** Type: `[highlightedValue: string | null]` Description: Function called when the highlighted menu item changes. **`update:open`** Type: `[open: boolean]` Description: Function called when the menu is opened or closed. ### Arrow #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### ArrowTip #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### CheckboxItem #### Props **`checked`** Type: `boolean` Required: true Default Value: `undefined` Description: Whether the option is checked **`value`** Type: `string` Required: true Default Value: `undefined` Description: The value of the option **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`closeOnSelect`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the menu should be closed when the option is selected. **`disabled`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the menu item is disabled **`valueText`** Type: `string` Required: false Default Value: `undefined` Description: The textual value of the option. Used in typeahead navigation of the menu. If not provided, the text content of the menu item will be used. #### Emits **`update:checked`** Type: `[value: boolean]` Description: undefined ### Content #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: menu **`data-part`**: content **`data-state`**: "open" | "closed" **`data-placement`**: The placement of the content ### ContextTrigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Indicator #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: menu **`data-part`**: indicator **`data-state`**: "open" | "closed" ### ItemGroupLabel #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### ItemGroup #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`id`** Type: `string` Required: false Default Value: `undefined` Description: The `id` of the element that provides accessibility label to the option group ### ItemIndicator #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: menu **`data-part`**: item-indicator **`data-disabled`**: Present when disabled **`data-highlighted`**: Present when highlighted **`data-state`**: "checked" | "unchecked" ### Item #### Props **`value`** Type: `string` Required: true Default Value: `undefined` Description: The unique value of the menu item option. **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`closeOnSelect`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the menu should be closed when the option is selected. **`disabled`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the menu item is disabled **`valueText`** Type: `string` Required: false Default Value: `undefined` Description: The textual value of the option. Used in typeahead navigation of the menu. If not provided, the text content of the menu item will be used. #### Data Attributes **`data-scope`**: menu **`data-part`**: item **`data-disabled`**: Present when disabled **`data-highlighted`**: Present when highlighted **`data-valuetext`**: The human-readable value ### ItemText #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: menu **`data-part`**: item-text **`data-disabled`**: Present when disabled **`data-highlighted`**: Present when highlighted **`data-state`**: "checked" | "unchecked" ### Positioner #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### RadioItemGroup #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`id`** Type: `string` Required: false Default Value: `undefined` Description: undefined **`modelValue`** Type: `string` Required: false Default Value: `undefined` Description: undefined #### Emits **`update:modelValue`** Type: `[value: string]` Description: undefined ### RadioItem #### Props **`value`** Type: `string` Required: true Default Value: `undefined` Description: The value of the option **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`closeOnSelect`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the menu should be closed when the option is selected. **`disabled`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the menu item is disabled **`valueText`** Type: `string` Required: false Default Value: `undefined` Description: The textual value of the option. Used in typeahead navigation of the menu. If not provided, the text content of the menu item will be used. ### RootProvider #### Props **`value`** Type: `UseMenuReturn` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`lazyMount`** Type: `boolean` Required: false Default Value: `false` Description: Whether to enable lazy mounting **`unmountOnExit`** Type: `boolean` Required: false Default Value: `false` Description: Whether to unmount on exit. ### Separator #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### TriggerItem #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Trigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: menu **`data-part`**: trigger **`data-placement`**: The placement of the trigger **`data-state`**: "open" | "closed" ## Accessibility Complies with the [Menu WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/menubar/). ### Keyboard Support **`Space`** Description: Activates/Selects the highlighted item **`Enter`** Description: Activates/Selects the highlighted item **`ArrowDown`** Description: Highlights the next item in the menu **`ArrowUp`** Description: Highlights the previous item in the menu **`ArrowRight + ArrowLeft`** Description: When focus is on trigger, opens or closes the submenu depending on reading direction. **`Esc`** Description: Closes the menu and moves focus to the trigger # Number Input ## Anatomy To set up the number input correctly, you'll need to understand its anatomy and how we name its parts. > Each part includes a `data-part` attribute to help identify them in the DOM. ## Examples Learn how to use the `NumberInput` component in your project. Let's take a look at the most basic example: ```vue ``` ### Setting a minimum and maximum value Pass the `min` prop or `max` prop to set an upper and lower limit for the input. By default, the input will restrict the value to stay within the specified range. ```vue ``` ### Adjusting the precision of the value In some cases, you might need the value to be rounded to specific decimal points. Set the `formatOptions` and provide `Intl.NumberFormatOptions` such as `maximumFractionDigits` or `minimumFractionDigits`. ```vue ``` ### Scrubbing the input value The NumberInput supports the scrubber interaction pattern. To use this pattern, render the `NumberInput.Scrubber` component. It uses the Pointer lock API and tracks the pointer movement. It also renders a virtual cursor which mimics the real cursor's pointer. ```vue ``` ### Using the mouse wheel to change value The NumberInput exposes a way to increment/decrement the value using the mouse wheel event. To activate this, set the `allowMouseWheel` prop to `true`. ```vue ``` ### Clamp value when user blurs the input In most cases, users can type custom values in the input field. If the typed value is greater than the max, the value is reset to max when the user blur out of the input. To disable this behavior, pass `clampValueOnBlur` and set to `false`. ```vue ``` ### Usage within forms To use the number input within forms, set the `name` prop. ```vue ``` ### Format and parse value To apply custom formatting to the input's value, set the `formatOptions` and provide `Intl.NumberFormatOptions` such as `style` and `currency`. ```vue ``` ### Using the Field Component The `Field` component helps manage form-related state and accessibility attributes of a number input. It includes handling ARIA labels, helper text, and error text to ensure proper accessibility. ```vue ``` ### Using the Root Provider The `RootProvider` component provides a context for the number-input. It accepts the value of the `useNumber-input` hook. You can leverage it to access the component state and methods from outside the number-input. ```vue ``` > If you're using the `RootProvider` component, you don't need to use the `Root` component. ## API Reference ### Root #### Props **`allowMouseWheel`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether to allow mouse wheel to change the value **`allowOverflow`** Type: `boolean` Required: false Default Value: `true` Description: Whether to allow the value overflow the min/max range **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`clampValueOnBlur`** Type: `boolean` Required: false Default Value: `true` Description: Whether to clamp the value when the input loses focus (blur) **`defaultValue`** Type: `string` Required: false Default Value: `undefined` Description: The initial value of the input when rendered. Use when you don't need to control the value of the input. **`disabled`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the number input is disabled. **`focusInputOnChange`** Type: `boolean` Required: false Default Value: `true` Description: Whether to focus input when the value changes **`form`** Type: `string` Required: false Default Value: `undefined` Description: The associate form of the input element. **`formatOptions`** Type: `NumberFormatOptions` Required: false Default Value: `undefined` Description: The options to pass to the `Intl.NumberFormat` constructor **`id`** Type: `string` Required: false Default Value: `undefined` Description: The unique identifier of the machine. **`ids`** Type: `Partial<{ root: string label: string input: string incrementTrigger: string decrementTrigger: string scrubber: string }>` Required: false Default Value: `undefined` Description: The ids of the elements in the number input. Useful for composition. **`inputMode`** Type: `'text' | 'tel' | 'numeric' | 'decimal'` Required: false Default Value: `"decimal"` Description: Hints at the type of data that might be entered by the user. It also determines the type of keyboard shown to the user on mobile devices **`invalid`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the number input value is invalid. **`locale`** Type: `string` Required: false Default Value: `"en-US"` Description: The current locale. Based on the BCP 47 definition. **`max`** Type: `number` Required: false Default Value: `Number.MAX_SAFE_INTEGER` Description: The maximum value of the number input **`min`** Type: `number` Required: false Default Value: `Number.MIN_SAFE_INTEGER` Description: The minimum value of the number input **`modelValue`** Type: `string` Required: false Default Value: `undefined` Description: The v-model value of the number input **`name`** Type: `string` Required: false Default Value: `undefined` Description: The name attribute of the number input. Useful for form submission. **`pattern`** Type: `string` Required: false Default Value: `"[0-9]*(.[0-9]+)?"` Description: The pattern used to check the element's value against **`readOnly`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the number input is readonly **`required`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the number input is required **`spinOnPress`** Type: `boolean` Required: false Default Value: `true` Description: Whether to spin the value when the increment/decrement button is pressed **`step`** Type: `number` Required: false Default Value: `1` Description: The amount to increment or decrement the value by **`translations`** Type: `IntlTranslations` Required: false Default Value: `undefined` Description: Specifies the localized strings that identifies the accessibility elements and their states #### Emits **`focusChange`** Type: `[details: FocusChangeDetails]` Description: Function invoked when the number input is focused **`update:modelValue`** Type: `[value: string]` Description: The callback fired when the model value changes. **`valueChange`** Type: `[details: ValueChangeDetails]` Description: Function invoked when the value changes **`valueInvalid`** Type: `[details: ValueInvalidDetails]` Description: Function invoked when the value overflows or underflows the min/max range #### Data Attributes **`data-scope`**: number-input **`data-part`**: root **`data-disabled`**: Present when disabled **`data-focus`**: Present when focused **`data-invalid`**: Present when invalid ### Control #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: number-input **`data-part`**: control **`data-focus`**: Present when focused **`data-disabled`**: Present when disabled **`data-invalid`**: Present when invalid ### DecrementTrigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: number-input **`data-part`**: decrement-trigger **`data-disabled`**: Present when disabled ### IncrementTrigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: number-input **`data-part`**: increment-trigger **`data-disabled`**: Present when disabled ### Input #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: number-input **`data-part`**: input **`data-invalid`**: Present when invalid **`data-disabled`**: Present when disabled ### Label #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: number-input **`data-part`**: label **`data-disabled`**: Present when disabled **`data-focus`**: Present when focused **`data-invalid`**: Present when invalid ### RootProvider #### Props **`value`** Type: `NumberInputApi` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Scrubber #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: number-input **`data-part`**: scrubber **`data-disabled`**: Present when disabled ### ValueText #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: number-input **`data-part`**: value-text **`data-disabled`**: Present when disabled **`data-invalid`**: Present when invalid **`data-focus`**: Present when focused ## Accessibility Complies with the [Spinbutton WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/spinbutton/). ### Keyboard Support **`ArrowUp`** Description: Increments the value of the number input by a predefined step. **`ArrowDown`** Description: Decrements the value of the number input by a predefined step. **`PageUp`** Description: Increments the value of the number input by a larger predefined step. **`PageDown`** Description: Decrements the value of the number input by a larger predefined step. **`Home`** Description: Sets the value of the number input to its minimum allowed value. **`End`** Description: Sets the value of the number input to its maximum allowed value. **`Enter`** Description: Submits the value entered in the number input. # Pagination ## Anatomy To set up the pagination correctly, you'll need to understand its anatomy and how we name its parts. > Each part includes a `data-part` attribute to help identify them in the DOM. ## Examples Learn how to use the `Pagination` component in your project. Let's take a look at the most basic example: ```vue ``` ### Controlled Pagination To create a controlled Pagination component, manage the state of the current page using the `page` prop and update it when the `onPageChange` event handler is called: ```vue Example not found``` ### Customizing Pagination You can customize the Pagination component by setting various props such as `dir`, `pageSize`, `siblingCount`, and `translations`. Here's an example of a customized Pagination: ```vue ``` ### Using the Root Provider The `RootProvider` component provides a context for the pagination. It accepts the value of the `usePagination` hook. You can leverage it to access the component state and methods from outside the pagination. ```vue ``` > If you're using the `RootProvider` component, you don't need to use the `Root` component. ## API Reference ### Root #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`count`** Type: `number` Required: false Default Value: `undefined` Description: Total number of data items **`defaultPage`** Type: `number` Required: false Default Value: `1` Description: The initial active page when rendered. Use when you don't need to control the active page of the pagination. **`defaultPageSize`** Type: `number` Required: false Default Value: `10` Description: The initial number of data items per page when rendered. Use when you don't need to control the page size of the pagination. **`id`** Type: `string` Required: false Default Value: `undefined` Description: The unique identifier of the machine. **`ids`** Type: `Partial<{ root: string ellipsis(index: number): string prevTrigger: string nextTrigger: string item(page: number): string }>` Required: false Default Value: `undefined` Description: The ids of the elements in the accordion. Useful for composition. **`page`** Type: `number` Required: false Default Value: `undefined` Description: The controlled active page **`pageSize`** Type: `number` Required: false Default Value: `undefined` Description: The controlled number of data items per page **`siblingCount`** Type: `number` Required: false Default Value: `1` Description: Number of pages to show beside active page **`translations`** Type: `IntlTranslations` Required: false Default Value: `undefined` Description: Specifies the localized strings that identifies the accessibility elements and their states **`type`** Type: `'button' | 'link'` Required: false Default Value: `"button"` Description: The type of the trigger element #### Emits **`pageChange`** Type: `[details: PageChangeDetails]` Description: Called when the page number is changed **`pageSizeChange`** Type: `[details: PageSizeChangeDetails]` Description: Called when the page size is changed **`update:page`** Type: `[page: number]` Description: The callback fired when the model value changes. **`update:pageSize`** Type: `[pageSize: number]` Description: The callback fired when the model value changes. ### Ellipsis #### Props **`index`** Type: `number` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Item #### Props **`type`** Type: `'page'` Required: true Default Value: `undefined` Description: undefined **`value`** Type: `number` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: pagination **`data-part`**: item **`data-index`**: The index of the item **`data-selected`**: Present when selected ### NextTrigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: pagination **`data-part`**: next-trigger **`data-disabled`**: Present when disabled ### PrevTrigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: pagination **`data-part`**: prev-trigger **`data-disabled`**: Present when disabled ### RootProvider #### Props **`value`** Type: `PaginationApi` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. # Pin Input ## Anatomy To set up the pin input correctly, you'll need to understand its anatomy and how we name its parts. > Each part includes a `data-part` attribute to help identify them in the DOM. ## Examples Learn how to use the `PinInput` component in your project. Let's take a look at the most basic example: ```vue ``` ### Setting a default value To set the initial value of the pin input, set the `defaultValue` prop. ```vue ``` ### Changing the placeholder To customize the default pin input placeholder `○` for each input, pass the placeholder prop and set it to your desired value. ```vue ``` ### Blur on complete By default, the last input maintains focus when filled, and we invoke the `onValueComplete` callback. To blur the last input when the user completes the input, set the prop `blurOnComplete` to `true`. ```vue ``` ### Using OTP mode To trigger smartphone OTP auto-suggestion, it is recommended to set the `autocomplete` attribute to "one-time-code". The pin input component provides support for this automatically when you set the `otp` prop to true. ```vue ``` ### Securing the text input When collecting private or sensitive information using the pin input, you might need to mask the value entered, similar to ``. Pass the `mask` prop to `true`. ```vue ``` ### Listening for changes The pin input component invokes several callback functions when the user enters: - `onValueChange` — Callback invoked when the value is changed. - `onValueComplete` — Callback invoked when all fields have been completed (by typing or pasting). - `onValueInvalid` — Callback invoked when an invalid value is entered into the input. An invalid value is any value that doesn't match the specified "type". ### Using the Field Component The `Field` component helps manage form-related state and accessibility attributes of a pin input. It includes handling ARIA labels, helper text, and error text to ensure proper accessibility. ```vue ``` ### Using the Root Provider The `RootProvider` component provides a context for the pin-input. It accepts the value of the `usePin-input` hook. You can leverage it to access the component state and methods from outside the pin-input. ```vue ``` > If you're using the `RootProvider` component, you don't need to use the `Root` component. ## API Reference ### Root #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`autoFocus`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether to auto-focus the first input. **`blurOnComplete`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether to blur the input when the value is complete **`count`** Type: `number` Required: false Default Value: `undefined` Description: The number of inputs to render to improve SSR aria attributes. This will be required in next major version. **`defaultValue`** Type: `string[]` Required: false Default Value: `undefined` Description: The initial value of the the pin input when rendered. Use when you don't need to control the value of the pin input. **`disabled`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the inputs are disabled **`form`** Type: `string` Required: false Default Value: `undefined` Description: The associate form of the underlying input element. **`id`** Type: `string` Required: false Default Value: `undefined` Description: The unique identifier of the machine. **`ids`** Type: `Partial<{ root: string hiddenInput: string label: string control: string input(id: string): string }>` Required: false Default Value: `undefined` Description: The ids of the elements in the pin input. Useful for composition. **`invalid`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the pin input is in the invalid state **`mask`** Type: `boolean` Required: false Default Value: `undefined` Description: If `true`, the input's value will be masked just like `type=password` **`modelValue`** Type: `string[]` Required: false Default Value: `undefined` Description: The v-model value of the pin input **`name`** Type: `string` Required: false Default Value: `undefined` Description: The name of the input element. Useful for form submission. **`otp`** Type: `boolean` Required: false Default Value: `undefined` Description: If `true`, the pin input component signals to its fields that they should use `autocomplete="one-time-code"`. **`pattern`** Type: `string` Required: false Default Value: `undefined` Description: The regular expression that the user-entered input value is checked against. **`placeholder`** Type: `string` Required: false Default Value: `"○"` Description: The placeholder text for the input **`readOnly`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the pin input is in the valid state **`required`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the pin input is required **`selectOnFocus`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether to select input value when input is focused **`translations`** Type: `IntlTranslations` Required: false Default Value: `undefined` Description: Specifies the localized strings that identifies the accessibility elements and their states **`type`** Type: `'numeric' | 'alphabetic' | 'alphanumeric'` Required: false Default Value: `"numeric"` Description: The type of value the pin-input should allow #### Emits **`update:modelValue`** Type: `[value: string[]]` Description: The callback fired when the model value changes. **`valueChange`** Type: `[details: ValueChangeDetails]` Description: Function called on input change **`valueComplete`** Type: `[details: ValueChangeDetails]` Description: Function called when all inputs have valid values **`valueInvalid`** Type: `[details: ValueInvalidDetails]` Description: Function called when an invalid value is entered #### Data Attributes **`data-scope`**: pin-input **`data-part`**: root **`data-invalid`**: Present when invalid **`data-disabled`**: Present when disabled **`data-complete`**: Present when the pin-input value is complete **`data-readonly`**: Present when read-only ### Control #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### HiddenInput #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Input #### Props **`index`** Type: `number` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: pin-input **`data-part`**: input **`data-disabled`**: Present when disabled **`data-complete`**: Present when the input value is complete **`data-index`**: The index of the item **`data-invalid`**: Present when invalid ### Label #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: pin-input **`data-part`**: label **`data-invalid`**: Present when invalid **`data-disabled`**: Present when disabled **`data-complete`**: Present when the label value is complete **`data-readonly`**: Present when read-only ### RootProvider #### Props **`value`** Type: `PinInputApi` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ## Accessibility ### Keyboard Support **`ArrowLeft`** Description: Moves focus to the previous input **`ArrowRight`** Description: Moves focus to the next input **`Backspace`** Description: Deletes the value in the current input and moves focus to the previous input **`Delete`** Description: Deletes the value in the current input **`Control + V`** Description: Pastes the value into the input fields # Popover ## Anatomy To set up the popover correctly, you'll need to understand its anatomy and how we name its parts. > Each part includes a `data-part` attribute to help identify them in the DOM. ## Examples Learn how to use the `Popover` component in your project. Let's take a look at the most basic example: ```vue ``` ### Using a Portal By default, the popover is rendered in the same DOM hierarchy as the trigger. To render the popover within a portal, set the `portalled` prop to `true`. > Note: This requires that you render the component within a `Portal` based on the framework you use. ```vue ``` ### Adding an arrow To render an arrow within the popover, render the component `Popover.Arrow` and `Popover.ArrowTip` as children of `Popover.Positioner`. ```vue ``` ### Listening for open and close events When the popover is opened or closed, we invoke the `onOpenChange` callback. ```vue ``` ### Control the open state Use the `isOpen` prop to control the open state of the popover. ```vue ``` ### Modifying the close behavior The popover is designed to close on blur and when the esc key is pressed. To prevent it from closing on blur (clicking or focusing outside), pass the `closeOnInteractOutside` prop and set it to `false`. To prevent it from closing when the esc key is pressed, pass the `closeOnEsc` prop and set it to `false`. ```vue ``` ### Changing the placement To change the placement of the popover, set the `positioning` prop. ```vue ``` ### Changing the modality In some cases, you might want the popover to be modal. This means that it'll: - trap focus within its content - block scrolling on the body - disable pointer interactions outside the popover - hide content behind the popover from screen readers To make the popover modal, set the `modal` prop to `true`. When `modal={true}`, we set the `portalled` attribute to `true` as well. ```vue ``` ### Using the Root Provider The `RootProvider` component provides a context for the popover. It accepts the value of the `usePopover` hook. You can leverage it to access the component state and methods from outside the popover. ```vue ``` > If you're using the `RootProvider` component, you don't need to use the `Root` component. ## API Reference ### Root #### Props **`autoFocus`** Type: `boolean` Required: false Default Value: `true` Description: Whether to automatically set focus on the first focusable content within the popover when opened. **`closeOnEscape`** Type: `boolean` Required: false Default Value: `true` Description: Whether to close the popover when the escape key is pressed. **`closeOnInteractOutside`** Type: `boolean` Required: false Default Value: `true` Description: Whether to close the popover when the user clicks outside of the popover. **`defaultOpen`** Type: `boolean` Required: false Default Value: `undefined` Description: The initial open state of the popover when rendered. Use when you don't need to control the open state of the popover. **`id`** Type: `string` Required: false Default Value: `undefined` Description: The unique identifier of the machine. **`ids`** Type: `Partial<{ anchor: string trigger: string content: string title: string description: string closeTrigger: string positioner: string arrow: string }>` Required: false Default Value: `undefined` Description: The ids of the elements in the popover. Useful for composition. **`initialFocusEl`** Type: `() => HTMLElement | null` Required: false Default Value: `undefined` Description: The element to focus on when the popover is opened. **`lazyMount`** Type: `boolean` Required: false Default Value: `false` Description: Whether to enable lazy mounting **`modal`** Type: `boolean` Required: false Default Value: `false` Description: Whether the popover should be modal. When set to `true`: - interaction with outside elements will be disabled - only popover content will be visible to screen readers - scrolling is blocked - focus is trapped within the popover **`open`** Type: `boolean` Required: false Default Value: `undefined` Description: The controlled open state of the popover **`persistentElements`** Type: `(() => Element | null)[]` Required: false Default Value: `undefined` Description: Returns the persistent elements that: - should not have pointer-events disabled - should not trigger the dismiss event **`portalled`** Type: `boolean` Required: false Default Value: `true` Description: Whether the popover is portalled. This will proxy the tabbing behavior regardless of the DOM position of the popover content. **`positioning`** Type: `PositioningOptions` Required: false Default Value: `undefined` Description: The user provided options used to position the popover content **`unmountOnExit`** Type: `boolean` Required: false Default Value: `false` Description: Whether to unmount on exit. #### Emits **`escapeKeyDown`** Type: `[event: KeyboardEvent]` Description: Function called when the escape key is pressed **`focusOutside`** Type: `[event: FocusOutsideEvent]` Description: Function called when the focus is moved outside the component **`interactOutside`** Type: `[event: InteractOutsideEvent]` Description: Function called when an interaction happens outside the component **`openChange`** Type: `[details: OpenChangeDetails]` Description: Function invoked when the popover opens or closes **`pointerDownOutside`** Type: `[event: PointerDownOutsideEvent]` Description: Function called when the pointer is pressed down outside the component **`update:open`** Type: `[open: boolean]` Description: The callback fired when the open state changes. ### Anchor #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Arrow #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### ArrowTip #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### CloseTrigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Content #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: popover **`data-part`**: content **`data-state`**: "open" | "closed" **`data-expanded`**: Present when expanded **`data-placement`**: The placement of the content ### Description #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Indicator #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: popover **`data-part`**: indicator **`data-state`**: "open" | "closed" ### Positioner #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### RootProvider #### Props **`value`** Type: `PopoverApi` Required: true Default Value: `undefined` Description: undefined **`lazyMount`** Type: `boolean` Required: false Default Value: `false` Description: Whether to enable lazy mounting **`unmountOnExit`** Type: `boolean` Required: false Default Value: `false` Description: Whether to unmount on exit. ### Title #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Trigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: popover **`data-part`**: trigger **`data-placement`**: The placement of the trigger **`data-state`**: "open" | "closed" ## Accessibility ### Keyboard Support **`Space`** Description: Opens/closes the popover. **`Enter`** Description: Opens/closes the popover. **`Tab`** Description: Moves focus to the next focusable element within the content.
                Note: If there are no focusable elements, focus is moved to the next focusable element after the trigger.
                **`Shift + Tab`** Description: Moves focus to the previous focusable element within the content
                Note: If there are no focusable elements, focus is moved to the trigger.
                **`Esc`** Description: Closes the popover and moves focus to the trigger. # Progress - Circular ## Anatomy To set up the progress correctly, you'll need to understand its anatomy and how we name its parts. > Each part includes a `data-part` attribute to help identify them in the DOM. ## Examples Learn how to use the `Progress` component in your project. Let's take a look at the most basic example: ```vue ``` ### Set a min and max value By default, the maximum is `100`. If that's not what you want, you can easily specify a different bound by changing the value of the `max` prop. You can do the same with the minimum value by setting the `min` prop. For example, to show the user a progress from `10` to `30`, you can use: ```vue ``` ### Indeterminate value The progress component is determinate by default, with the value and max set to 50 and 100 respectively. To render an indeterminate progress, you will have to set the `value` to `null`. ```vue ``` ### Showing a value text Progress bars can only be interpreted by sighted users. To include a text description to support assistive technologies like screen readers, use the `value` part in `translations`. ```vue ``` ### Using the Root Provider The `RootProvider` component provides a context for the progress. It accepts the value of the `useProgress` hook. You can leverage it to access the component state and methods from outside the progress. ```vue ``` > If you're using the `RootProvider` component, you don't need to use the `Root` component. ## API Reference ### Root #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`defaultValue`** Type: `number` Required: false Default Value: `50` Description: The initial value of the progress bar when rendered. Use when you don't need to control the value of the progress bar. **`formatOptions`** Type: `NumberFormatOptions` Required: false Default Value: `{ style: "percent" }` Description: The options to use for formatting the value. **`id`** Type: `string` Required: false Default Value: `undefined` Description: The unique identifier of the machine. **`ids`** Type: `Partial<{ root: string; track: string; label: string; circle: string }>` Required: false Default Value: `undefined` Description: The ids of the elements in the progress bar. Useful for composition. **`locale`** Type: `string` Required: false Default Value: `"en-US"` Description: The locale to use for formatting the value. **`max`** Type: `number` Required: false Default Value: `100` Description: The maximum allowed value of the progress bar. **`min`** Type: `number` Required: false Default Value: `0` Description: The minimum allowed value of the progress bar. **`modelValue`** Type: `number` Required: false Default Value: `undefined` Description: The v-model value of the progress **`orientation`** Type: `'horizontal' | 'vertical'` Required: false Default Value: `"horizontal"` Description: The orientation of the element. **`translations`** Type: `IntlTranslations` Required: false Default Value: `undefined` Description: The localized messages to use. #### Emits **`update:modelValue`** Type: `[value: number | null]` Description: The callback fired when the model value changes. **`valueChange`** Type: `[details: ValueChangeDetails]` Description: Callback fired when the value changes. #### Data Attributes **`data-scope`**: progress **`data-part`**: root **`data-max`**: **`data-value`**: The value of the item **`data-state`**: **`data-orientation`**: The orientation of the progress ### Circle #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### CircleRange #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: progress **`data-part`**: circle-range **`data-state`**: ### CircleTrack #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: progress **`data-part`**: circle-track **`data-orientation`**: The orientation of the circletrack ### Label #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: progress **`data-part`**: label **`data-orientation`**: The orientation of the label ### Range #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: progress **`data-part`**: range **`data-orientation`**: The orientation of the range **`data-state`**: ### RootProvider #### Props **`value`** Type: `ProgressApi` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Track #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### ValueText #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### View #### Props **`state`** Type: `ProgressState` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: progress **`data-part`**: view **`data-state`**: ## Accessibility Complies with the [the progressbar role requirements.](https://w3c.github.io/aria/#progressbar). # Progress - Linear ## Anatomy To set up the progress correctly, you'll need to understand its anatomy and how we name its parts. > Each part includes a `data-part` attribute to help identify them in the DOM. ## Examples Learn how to use the `Progress` component in your project. Let's take a look at the most basic example: ```vue ``` ### Set a min and max value By default, the maximum is `100`. If that's not what you want, you can easily specify a different bound by changing the value of the `max` prop. You can do the same with the minimum value by setting the `min` prop. For example, to show the user a progress from `10` to `30`, you can use: ```vue ``` ### Indeterminate progress The progress component is determinate by default, with the value and max set to 50 and 100 respectively. To render an indeterminate progress, you will have to set the `value` to `null`. ```vue ``` ### Showing a value text Progress bars can only be interpreted by sighted users. To include a text description to support assistive technologies like screen readers, use the `value` part in `translations`. ```vue ``` ### Changing the orientation By default, the progress is assumed to be horizontal. To change the orientation to vertical, set the orientation property in the machine's context to vertical. > Don't forget to change the styles of the vertical progress by specifying its height ```vue Example not found``` ### Using the Root Provider The `RootProvider` component provides a context for the progress. It accepts the value of the `useProgress` hook. You can leverage it to access the component state and methods from outside the progress. ```vue ``` > If you're using the `RootProvider` component, you don't need to use the `Root` component. ## API Reference ### Root #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`defaultValue`** Type: `number` Required: false Default Value: `50` Description: The initial value of the progress bar when rendered. Use when you don't need to control the value of the progress bar. **`formatOptions`** Type: `NumberFormatOptions` Required: false Default Value: `{ style: "percent" }` Description: The options to use for formatting the value. **`id`** Type: `string` Required: false Default Value: `undefined` Description: The unique identifier of the machine. **`ids`** Type: `Partial<{ root: string; track: string; label: string; circle: string }>` Required: false Default Value: `undefined` Description: The ids of the elements in the progress bar. Useful for composition. **`locale`** Type: `string` Required: false Default Value: `"en-US"` Description: The locale to use for formatting the value. **`max`** Type: `number` Required: false Default Value: `100` Description: The maximum allowed value of the progress bar. **`min`** Type: `number` Required: false Default Value: `0` Description: The minimum allowed value of the progress bar. **`modelValue`** Type: `number` Required: false Default Value: `undefined` Description: The v-model value of the progress **`orientation`** Type: `'horizontal' | 'vertical'` Required: false Default Value: `"horizontal"` Description: The orientation of the element. **`translations`** Type: `IntlTranslations` Required: false Default Value: `undefined` Description: The localized messages to use. #### Emits **`update:modelValue`** Type: `[value: number | null]` Description: The callback fired when the model value changes. **`valueChange`** Type: `[details: ValueChangeDetails]` Description: Callback fired when the value changes. #### Data Attributes **`data-scope`**: progress **`data-part`**: root **`data-max`**: **`data-value`**: The value of the item **`data-state`**: **`data-orientation`**: The orientation of the progress ### Circle #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### CircleRange #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: progress **`data-part`**: circle-range **`data-state`**: ### CircleTrack #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: progress **`data-part`**: circle-track **`data-orientation`**: The orientation of the circletrack ### Label #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: progress **`data-part`**: label **`data-orientation`**: The orientation of the label ### Range #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: progress **`data-part`**: range **`data-orientation`**: The orientation of the range **`data-state`**: ### RootProvider #### Props **`value`** Type: `ProgressApi` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Track #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### ValueText #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### View #### Props **`state`** Type: `ProgressState` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: progress **`data-part`**: view **`data-state`**: ## Accessibility Complies with the [the progressbar role requirements.](https://w3c.github.io/aria/#progressbar). # QR Code ## Anatomy To set up the QR code correctly, you'll need to understand its anatomy and how we name its parts. > Each part includes a `data-part` attribute to help identify them in the DOM. ## Examples Learn how to use the `QR Code` component in your project. Let's take a look at the most basic example: ```vue ``` ### Download a QR Code You can download the QR code by using the `QrCode.DownloadTrigger`. You will have to provide the `fileName` and the `mimeType` of the image. ```tsx Download ``` ### With Overlay You can also add a logo or overlay to the QR code. This is useful when you want to brand the QR code. ```vue ``` ### Error Correction In cases where the link is too long or the logo overlay covers a significant area, the error correction level can be increased. Use the `encoding.ecc` or `encoding.boostEcc` property to set the error correction level: - `L`: Allows recovery of up to 7% data loss (default) - `M`: Allows recovery of up to 15% data loss - `Q`: Allows recovery of up to 25% data loss - `H`: Allows recovery of up to 30% data loss ```vue ``` ### Using the Root Provider The `RootProvider` component provides a context for the QR code. It accepts the value of the `useQrCode` hook. You can leverage it to access the component state and methods from outside the QR code. ```vue ``` > If you're using the `RootProvider` component, you don't need to use the `Root` component. ## API Reference ### Root #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`defaultValue`** Type: `string` Required: false Default Value: `undefined` Description: The initial value to encode when rendered. Use when you don't need to control the value of the qr code. **`encoding`** Type: `QrCodeGenerateOptions` Required: false Default Value: `undefined` Description: The qr code encoding options. **`id`** Type: `string` Required: false Default Value: `undefined` Description: The unique identifier of the machine. **`ids`** Type: `Partial<{ root: string; frame: string }>` Required: false Default Value: `undefined` Description: The element ids. **`modelValue`** Type: `string` Required: false Default Value: `undefined` Description: The v-model value of the qr code **`pixelSize`** Type: `number` Required: false Default Value: `undefined` Description: The pixel size of the qr code. #### Emits **`update:modelValue`** Type: `[value: string]` Description: The callback fired when the model value changes. **`valueChange`** Type: `[details: ValueChangeDetails]` Description: Callback fired when the value changes. ### DownloadTrigger #### Props **`fileName`** Type: `string` Required: true Default Value: `undefined` Description: The name of the file. **`mimeType`** Type: `DataUrlType` Required: true Default Value: `undefined` Description: The mime type of the image. **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`quality`** Type: `number` Required: false Default Value: `undefined` Description: The quality of the image. ### Frame #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Overlay #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Pattern #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### RootProvider #### Props **`value`** Type: `QrCodeApi` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. # Radio Group ## Anatomy To set up the radio group correctly, you'll need to understand its anatomy and how we name its parts. > Each part includes a `data-part` attribute to help identify them in the DOM. ### Design impact on the asChild property The `RadioGroup.Item` element of the radio group is a `label` element. This is because the radio group is a form control and should be associated with a label to provide context and meaning to the user. Otherwise, the HTML and accessibility structure will be invalid. > If you need to use the `asChild` property, make sure that the `label` element is the direct child of the > `RadioGroup.Item` component. ## Examples Learn how to use the `RadioGroup` component in your project. Let's take a look at the most basic example: ```vue ``` ### Disabling the radio group To make a radio group disabled, set the `disabled` prop to `true`. ```vue ``` ### Setting the initial value To set the radio group's initial value, set the `defaultValue` prop to the value of the radio item to be selected by default. ```vue ``` ### Listening for changes When the radio group value changes, the `onValueChange` callback is invoked. ```vue ``` ### Using the Root Provider The `RootProvider` component provides a context for the radio-group. It accepts the value of the `useRadio-group` hook. You can leverage it to access the component state and methods from outside the radio-group. ```vue ``` > If you're using the `RootProvider` component, you don't need to use the `Root` component. ## API Reference ### Root #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`defaultValue`** Type: `string` Required: false Default Value: `undefined` Description: The initial value of the checked radio when rendered. Use when you don't need to control the value of the radio group. **`disabled`** Type: `boolean` Required: false Default Value: `undefined` Description: If `true`, the radio group will be disabled **`form`** Type: `string` Required: false Default Value: `undefined` Description: The associate form of the underlying input. **`id`** Type: `string` Required: false Default Value: `undefined` Description: The unique identifier of the machine. **`ids`** Type: `Partial<{ root: string label: string indicator: string item(value: string): string itemLabel(value: string): string itemControl(value: string): string itemHiddenInput(value: string): string }>` Required: false Default Value: `undefined` Description: The ids of the elements in the radio. Useful for composition. **`modelValue`** Type: `string` Required: false Default Value: `undefined` Description: The v-model value of the radio group **`name`** Type: `string` Required: false Default Value: `undefined` Description: The name of the input fields in the radio (Useful for form submission). **`orientation`** Type: `'horizontal' | 'vertical'` Required: false Default Value: `undefined` Description: Orientation of the radio group **`readOnly`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the checkbox is read-only #### Emits **`update:modelValue`** Type: `[value: string | null]` Description: The callback fired when the model value changes. **`valueChange`** Type: `[details: ValueChangeDetails]` Description: Function called once a radio is checked #### Data Attributes **`data-scope`**: radio-group **`data-part`**: root **`data-orientation`**: The orientation of the radio-group **`data-disabled`**: Present when disabled ### Indicator #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: radio-group **`data-part`**: indicator **`data-disabled`**: Present when disabled **`data-orientation`**: The orientation of the indicator ### ItemControl #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: radio-group **`data-part`**: item-control **`data-active`**: Present when active or pressed ### ItemHiddenInput #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Item #### Props **`value`** Type: `string` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`disabled`** Type: `boolean` Required: false Default Value: `undefined` Description: undefined **`invalid`** Type: `boolean` Required: false Default Value: `undefined` Description: undefined ### ItemText #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Label #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: radio-group **`data-part`**: label **`data-orientation`**: The orientation of the label **`data-disabled`**: Present when disabled ### RootProvider #### Props **`value`** Type: `RadioGroupApi` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ## Accessibility Complies with the [Radio WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/radio/). ### Keyboard Support **`Tab`** Description: Moves focus to either the checked radio item or the first radio item in the group. **`Space`** Description: When focus is on an unchecked radio item, checks it. **`ArrowDown`** Description: Moves focus and checks the next radio item in the group. **`ArrowRight`** Description: Moves focus and checks the next radio item in the group. **`ArrowUp`** Description: Moves focus to the previous radio item in the group. **`ArrowLeft`** Description: Moves focus to the previous radio item in the group. # Rating Group ## Anatomy To set up the rating correctly, you'll need to understand its anatomy and how we name its parts. > Each part includes a `data-part` attribute to help identify them in the DOM. ## Examples Learn how to use the `RatingGroup` component in your project. Let's take a look at the most basic example: ```vue ``` ### Using half ratings Allow `0.5` value steps by setting the `allowHalf` prop to `true`. Ensure to render the correct icon if the `isHalf` value is set in the Rating components render callback. ```vue ``` ### Using a default value ```vue ``` ### Controlled When using the `RatingGroup` component, you can use the `value` and `onValueChange` props to control the state. ```vue ``` ### Disabling the rating group To make the rating group disabled, set the `disabled` prop to `true`. ```vue ``` ### Readonly rating group To make the rating group readonly, set the `readOnly` prop to `true`. ```vue ``` ### Usage within forms To use the rating group within forms, pass the prop `name`. It will render a hidden input and ensure the value changes get propagated to the form correctly. ```vue ``` ### Using the Field Component The `Field` component helps manage form-related state and accessibility attributes of a rating group. It includes handling ARIA labels, helper text, and error text to ensure proper accessibility. ```vue ``` ### Using the Root Provider The `RootProvider` component provides a context for the rating-group. It accepts the value of the `useRating-group` hook. You can leverage it to access the component state and methods from outside the rating-group. ```vue ``` > If you're using the `RootProvider` component, you don't need to use the `Root` component. ## API Reference ### Root #### Props **`allowHalf`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether to allow half stars. **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`autoFocus`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether to autofocus the rating. **`count`** Type: `number` Required: false Default Value: `5` Description: The total number of ratings. **`defaultValue`** Type: `number` Required: false Default Value: `undefined` Description: The initial value of the rating when rendered. Use when you don't need to control the value of the rating. **`disabled`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the rating is disabled. **`form`** Type: `string` Required: false Default Value: `undefined` Description: The associate form of the underlying input element. **`id`** Type: `string` Required: false Default Value: `undefined` Description: The unique identifier of the machine. **`ids`** Type: `Partial<{ root: string label: string hiddenInput: string control: string item(id: string): string }>` Required: false Default Value: `undefined` Description: The ids of the elements in the rating. Useful for composition. **`modelValue`** Type: `number` Required: false Default Value: `undefined` Description: The v-model value of the rating group **`name`** Type: `string` Required: false Default Value: `undefined` Description: The name attribute of the rating element (used in forms). **`readOnly`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the rating is readonly. **`required`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the rating is required. **`translations`** Type: `IntlTranslations` Required: false Default Value: `undefined` Description: Specifies the localized strings that identifies the accessibility elements and their states #### Emits **`hoverChange`** Type: `[details: HoverChangeDetails]` Description: Function to be called when the rating value is hovered. **`update:modelValue`** Type: `[value: number]` Description: The callback fired when the model value changes. **`valueChange`** Type: `[details: ValueChangeDetails]` Description: Function to be called when the rating value changes. ### Control #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: rating-group **`data-part`**: control **`data-readonly`**: Present when read-only **`data-disabled`**: Present when disabled ### HiddenInput #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Item #### Props **`index`** Type: `number` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: rating-group **`data-part`**: item **`data-disabled`**: Present when disabled **`data-readonly`**: Present when read-only **`data-checked`**: Present when checked **`data-highlighted`**: Present when highlighted **`data-half`**: ### Label #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: rating-group **`data-part`**: label **`data-disabled`**: Present when disabled ### RootProvider #### Props **`value`** Type: `RatingGroupApi` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ## Accessibility ### Keyboard Support **`ArrowRight`** Description: Moves focus to the next star, increasing the rating value based on the `allowHalf` property. **`ArrowLeft`** Description: Moves focus to the previous star, decreasing the rating value based on the `allowHalf` property. **`Enter`** Description: Selects the focused star in the rating group. # Segment Group ## Anatomy To set up the segmented control correctly, you'll need to understand its anatomy and how we name its parts. > Each part includes a `data-part` attribute to help identify them in the DOM. ## Examples Learn how to use the `SegmentGroup` component in your project. Let's take a look at the most basic example: ```vue ``` ### Initial Value To set a default segment on initial render, use the `defaultValue` prop: ```vue ``` ### Controlled Segment Group To create a controlled SegmentGroup component, manage the current selected segment using the `value` prop and update it when the `onValueChange` event handler is called: ```vue ``` ### Disabled Segment To disable a segment, simply pass the `disabled` prop to the `SegmentGroup.Item` component: ```vue ``` ### Using the Root Provider The `RootProvider` component provides a context for the radio-group. It accepts the value of the `useRadio-group` hook. You can leverage it to access the component state and methods from outside the radio-group. ```vue ``` > If you're using the `RootProvider` component, you don't need to use the `Root` component. ## API Reference ### Root #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`defaultValue`** Type: `string` Required: false Default Value: `undefined` Description: The initial value of the checked radio when rendered. Use when you don't need to control the value of the radio group. **`disabled`** Type: `boolean` Required: false Default Value: `undefined` Description: If `true`, the radio group will be disabled **`form`** Type: `string` Required: false Default Value: `undefined` Description: The associate form of the underlying input. **`id`** Type: `string` Required: false Default Value: `undefined` Description: The unique identifier of the machine. **`ids`** Type: `Partial<{ root: string label: string indicator: string item(value: string): string itemLabel(value: string): string itemControl(value: string): string itemHiddenInput(value: string): string }>` Required: false Default Value: `undefined` Description: The ids of the elements in the radio. Useful for composition. **`modelValue`** Type: `string` Required: false Default Value: `undefined` Description: The v-model value of the radio group **`name`** Type: `string` Required: false Default Value: `undefined` Description: The name of the input fields in the radio (Useful for form submission). **`orientation`** Type: `'horizontal' | 'vertical'` Required: false Default Value: `undefined` Description: Orientation of the radio group **`readOnly`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the checkbox is read-only #### Emits **`update:modelValue`** Type: `[value: string | null]` Description: The callback fired when the model value changes. **`valueChange`** Type: `[details: ValueChangeDetails]` Description: Function called once a radio is checked #### Data Attributes **`data-scope`**: radio-group **`data-part`**: root **`data-orientation`**: The orientation of the radio-group **`data-disabled`**: Present when disabled ### Indicator #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: radio-group **`data-part`**: indicator **`data-disabled`**: Present when disabled **`data-orientation`**: The orientation of the indicator ### ItemControl #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: radio-group **`data-part`**: item-control **`data-active`**: Present when active or pressed ### ItemHiddenInput #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Item #### Props **`value`** Type: `string` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`disabled`** Type: `boolean` Required: false Default Value: `undefined` Description: undefined **`invalid`** Type: `boolean` Required: false Default Value: `undefined` Description: undefined ### ItemText #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Label #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: radio-group **`data-part`**: label **`data-orientation`**: The orientation of the label **`data-disabled`**: Present when disabled ### RootProvider #### Props **`value`** Type: `RadioGroupApi` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ## Accessibility Complies with the [Radio WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/radio/). ### Keyboard Support **`Tab`** Description: Moves focus to either the checked radio item or the first radio item in the group. **`Space`** Description: When focus is on an unchecked radio item, checks it. **`ArrowDown`** Description: Moves focus and checks the next radio item in the group. **`ArrowRight`** Description: Moves focus and checks the next radio item in the group. **`ArrowUp`** Description: Moves focus to the previous radio item in the group. **`ArrowLeft`** Description: Moves focus to the previous radio item in the group. # Select ## Anatomy To set up the select correctly, you'll need to understand its anatomy and how we name its parts. > Each part includes a `data-part` attribute to help identify them in the DOM. ## Examples Learn how to use the `Select` component in your project. Let's take a look at the most basic example: ```vue ``` ### Advanced Customization For advanced customizations and item properties like `disabled`: ```vue ``` ### Multiple Selection To enable `multiple` item selection: ```vue ``` ### Controlled Component For scenarios where you want to control the Select component's state: ```vue ``` ### Usage with a Form Library See how to use the Select component with popular form libraries: ```vue Example not found``` ### Using the Field Component The `Field` component helps manage form-related state and accessibility attributes of a select. It includes handling ARIA labels, helper text, and error text to ensure proper accessibility. ```vue ``` ### Using the Root Provider The `RootProvider` component provides a context for the select. It accepts the value of the `useSelect` hook. You can leverage it to access the component state and methods from outside the select. ```vue ``` > If you're using the `RootProvider` component, you don't need to use the `Root` component. ## API Reference ### Root #### Props **`collection`** Type: `ListCollection` Required: true Default Value: `undefined` Description: The collection of items **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`closeOnSelect`** Type: `boolean` Required: false Default Value: `true` Description: Whether the select should close after an item is selected **`composite`** Type: `boolean` Required: false Default Value: `true` Description: Whether the select is a composed with other composite widgets like tabs or combobox **`defaultHighlightedValue`** Type: `string` Required: false Default Value: `undefined` Description: The initial value of the highlighted item when opened. Use when you don't need to control the highlighted value of the select. **`defaultOpen`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the select's open state is controlled by the user **`defaultValue`** Type: `string[]` Required: false Default Value: `undefined` Description: The initial default value of the select when rendered. Use when you don't need to control the value of the select. **`deselectable`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the value can be cleared by clicking the selected item. **Note:** this is only applicable for single selection **`disabled`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the select is disabled **`form`** Type: `string` Required: false Default Value: `undefined` Description: The associate form of the underlying select. **`highlightedValue`** Type: `string` Required: false Default Value: `undefined` Description: The controlled key of the highlighted item **`id`** Type: `string` Required: false Default Value: `undefined` Description: The unique identifier of the machine. **`ids`** Type: `Partial<{ root: string content: string control: string trigger: string clearTrigger: string label: string hiddenSelect: string positioner: string item(id: string | number): string itemGroup(id: string | number): string itemGroupLabel(id: string | number): string }>` Required: false Default Value: `undefined` Description: The ids of the elements in the select. Useful for composition. **`invalid`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the select is invalid **`lazyMount`** Type: `boolean` Required: false Default Value: `false` Description: Whether to enable lazy mounting **`loopFocus`** Type: `boolean` Required: false Default Value: `false` Description: Whether to loop the keyboard navigation through the options **`modelValue`** Type: `string[]` Required: false Default Value: `undefined` Description: The model value of the select **`multiple`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether to allow multiple selection **`name`** Type: `string` Required: false Default Value: `undefined` Description: The `name` attribute of the underlying select. **`open`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the select menu is open **`positioning`** Type: `PositioningOptions` Required: false Default Value: `undefined` Description: The positioning options of the menu. **`readOnly`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the select is read-only **`required`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the select is required **`scrollToIndexFn`** Type: `(details: ScrollToIndexDetails) => void` Required: false Default Value: `undefined` Description: Function to scroll to a specific index **`unmountOnExit`** Type: `boolean` Required: false Default Value: `false` Description: Whether to unmount on exit. #### Data Attributes **`data-scope`**: select **`data-part`**: root **`data-invalid`**: Present when invalid **`data-readonly`**: Present when read-only ### ClearTrigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: select **`data-part`**: clear-trigger **`data-invalid`**: Present when invalid ### Content #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: select **`data-part`**: content **`data-state`**: "open" | "closed" **`data-placement`**: The placement of the content **`data-activedescendant`**: ### Control #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: select **`data-part`**: control **`data-state`**: "open" | "closed" **`data-focus`**: Present when focused **`data-disabled`**: Present when disabled **`data-invalid`**: Present when invalid ### HiddenSelect #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Indicator #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: select **`data-part`**: indicator **`data-state`**: "open" | "closed" **`data-disabled`**: Present when disabled **`data-invalid`**: Present when invalid **`data-readonly`**: Present when read-only ### ItemGroupLabel #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### ItemGroup #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`id`** Type: `string` Required: false Default Value: `undefined` Description: undefined #### Data Attributes **`data-scope`**: select **`data-part`**: item-group **`data-disabled`**: Present when disabled ### ItemIndicator #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: select **`data-part`**: item-indicator **`data-state`**: "checked" | "unchecked" ### Item #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`item`** Type: `any` Required: false Default Value: `undefined` Description: The item to render **`persistFocus`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether hovering outside should clear the highlighted state #### Data Attributes **`data-scope`**: select **`data-part`**: item **`data-value`**: The value of the item **`data-state`**: "checked" | "unchecked" **`data-highlighted`**: Present when highlighted **`data-disabled`**: Present when disabled ### ItemText #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: select **`data-part`**: item-text **`data-state`**: "checked" | "unchecked" **`data-disabled`**: Present when disabled **`data-highlighted`**: Present when highlighted ### Label #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: select **`data-part`**: label **`data-disabled`**: Present when disabled **`data-invalid`**: Present when invalid **`data-readonly`**: Present when read-only ### List #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Positioner #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### RootProvider #### Props **`value`** Type: `SelectApi` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`lazyMount`** Type: `boolean` Required: false Default Value: `false` Description: Whether to enable lazy mounting **`unmountOnExit`** Type: `boolean` Required: false Default Value: `false` Description: Whether to unmount on exit. ### Trigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: select **`data-part`**: trigger **`data-state`**: "open" | "closed" **`data-disabled`**: Present when disabled **`data-invalid`**: Present when invalid **`data-readonly`**: Present when read-only **`data-placement`**: The placement of the trigger **`data-placeholder-shown`**: Present when placeholder is shown ### ValueText #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`placeholder`** Type: `string` Required: false Default Value: `undefined` Description: undefined #### Data Attributes **`data-scope`**: select **`data-part`**: value-text **`data-disabled`**: Present when disabled **`data-invalid`**: Present when invalid **`data-focus`**: Present when focused ## Accessibility Complies with the [Listbox WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/listbox/). ### Keyboard Support **`Space`** Description: When focus is on trigger, opens the select and focuses the first selected item.
                When focus is on the content, selects the highlighted item.
                **`Enter`** Description: When focus is on trigger, opens the select and focuses the first selected item.
                When focus is on content, selects the focused item.
                **`ArrowDown`** Description: When focus is on trigger, opens the select.
                When focus is on content, moves focus to the next item.
                **`ArrowUp`** Description: When focus is on trigger, opens the select.
                When focus is on content, moves focus to the previous item.
                **`Esc`** Description: Closes the select and moves focus to trigger. **`A-Z + a-z`** Description: When focus is on trigger, selects the item whose label starts with the typed character.
                When focus is on the listbox, moves focus to the next item with a label that starts with the typed character.
                # Signature Pad ## Anatomy To set up the signature pad correctly, you'll need to understand its anatomy and how we name its parts. > Each part includes a `data-part` attribute to help identify them in the DOM. ## Examples Learn how to use the `Signature Pad` component in your project. Let's take a look at the most basic example: ```vue ``` ### Image Preview After the user draws a signature, you can display a preview of the signature as an image. This is useful when you want to show the user a preview of the signature before saving it. ```vue ``` ### Using the Field Component The `Field` component helps manage form-related state and accessibility attributes of a signature pad. It includes handling ARIA labels, helper text, and error text to ensure proper accessibility. ```vue ``` ### Using the Root Provider The `RootProvider` component provides a context for the signature-pad. It accepts the value of the `useSignature-pad` hook. You can leverage it to access the component state and methods from outside the signature-pad. ```vue ``` > If you're using the `RootProvider` component, you don't need to use the `Root` component. ## API Reference ### Root #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`disabled`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the signature pad is disabled. **`drawing`** Type: `DrawingOptions` Required: false Default Value: `'{ size: 2, simulatePressure: true }'` Description: The drawing options. **`id`** Type: `string` Required: false Default Value: `undefined` Description: The unique identifier of the machine. **`ids`** Type: `Partial<{ root: string; control: string; hiddenInput: string; label: string }>` Required: false Default Value: `undefined` Description: The ids of the signature pad elements. Useful for composition. **`name`** Type: `string` Required: false Default Value: `undefined` Description: The name of the signature pad. Useful for form submission. **`readOnly`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the signature pad is read-only. **`required`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the signature pad is required. **`translations`** Type: `IntlTranslations` Required: false Default Value: `undefined` Description: The translations of the signature pad. Useful for internationalization. #### Data Attributes **`data-scope`**: signature-pad **`data-part`**: root **`data-disabled`**: Present when disabled ### ClearTrigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Control #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: signature-pad **`data-part`**: control **`data-disabled`**: Present when disabled ### Guide #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: signature-pad **`data-part`**: guide **`data-disabled`**: Present when disabled ### HiddenInput #### Props **`value`** Type: `string` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Label #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: signature-pad **`data-part`**: label **`data-disabled`**: Present when disabled ### RootProvider #### Props **`value`** Type: `SignaturePadApi` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Segment #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. # Slider ## Anatomy To set up the slider correctly, you'll need to understand its anatomy and how we name its parts. > Each part includes a `data-part` attribute to help identify them in the DOM. ## Examples Learn how to use the `Slider` component in your project. Let's take a look at the most basic example: ```vue ``` ### Range Slider You can add multiple thumbs to the slider by adding multiple `Slider.Thumb` ```vue ``` ### Adding marks You can add marks to the slider track by using the `Slider.MarkerGroup` and `Slider.Marker` components. Position the `Slider.Marker` components relative to the track by providing the `value` prop. ```vue ``` ### Setting the initial value To set the slider's initial value, set the `defaultValue` prop to the array of numbers. ```vue ``` ### Specifying the minimum and maximum By default, the minimum is `0` and the maximum is `100`. If that's not what you want, you can easily specify different bounds by changing the values of the `min` and/or `max` props. For example, to ask the user for a value between `-10` and `10`, you can use: ```vue ``` ### Setting the value's granularity By default, the granularity, is `1`, meaning that the value is always an integer. You can change the step attribute to control the granularity. For example, If you need a value between `5` and `10`, accurate to two decimal places, you should set the value of step to `0.01`: ```vue ``` ### Listening for changes When the slider value changes, the `onValueChange` and `onValueChangeEnd` callbacks are invoked. You can use this to set up custom behaviors in your app. ```vue ``` ### Changing the orientation By default, the slider is assumed to be horizontal. To change the orientation to vertical, set the orientation property in the machine's context to vertical. In this mode, the slider will use the arrow up and down keys to increment/decrement its value. > Don't forget to change the styles of the vertical slider by specifying its height ```vue ``` ### Changing the origin By default, the slider's origin is at the start of the track. To change the origin to the center of the track, set the `origin` prop to `center`. ```vue ``` ### Using the Root Provider The `RootProvider` component provides a context for the slider. It accepts the value of the `useSlider` hook. You can leverage it to access the component state and methods from outside the slider. ```vue ``` > If you're using the `RootProvider` component, you don't need to use the `Root` component. ## API Reference ### Root #### Props **`aria-label`** Type: `string[]` Required: false Default Value: `undefined` Description: The aria-label of each slider thumb. Useful for providing an accessible name to the slider **`aria-labelledby`** Type: `string[]` Required: false Default Value: `undefined` Description: The `id` of the elements that labels each slider thumb. Useful for providing an accessible name to the slider **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`defaultValue`** Type: `number[]` Required: false Default Value: `undefined` Description: The initial value of the slider when rendered. Use when you don't need to control the value of the slider. **`dir`** Type: `'rtl' | 'ltr'` Required: false Default Value: `"ltr"` Description: The document's text/writing direction. **`disabled`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the slider is disabled **`form`** Type: `string` Required: false Default Value: `undefined` Description: The associate form of the underlying input element. **`getAriaValueText`** Type: `(details: ValueTextDetails) => string` Required: false Default Value: `undefined` Description: Function that returns a human readable value for the slider thumb **`getRootNode`** Type: `() => Node | Document | ShadowRoot` Required: false Default Value: `undefined` Description: A root node to correctly resolve document in custom environments. E.x.: Iframes, Electron. **`id`** Type: `string` Required: false Default Value: `undefined` Description: The unique identifier of the machine. **`ids`** Type: `Partial<{ root: string thumb(index: number): string hiddenInput(index: number): string control: string track: string range: string label: string valueText: string marker(index: number): string }>` Required: false Default Value: `undefined` Description: The ids of the elements in the slider. Useful for composition. **`invalid`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the slider is invalid **`max`** Type: `number` Required: false Default Value: `100` Description: The maximum value of the slider **`min`** Type: `number` Required: false Default Value: `0` Description: The minimum value of the slider **`minStepsBetweenThumbs`** Type: `number` Required: false Default Value: `0` Description: The minimum permitted steps between multiple thumbs. **`modelValue`** Type: `number[]` Required: false Default Value: `undefined` Description: The v-model value of the slider **`name`** Type: `string` Required: false Default Value: `undefined` Description: The name associated with each slider thumb (when used in a form) **`orientation`** Type: `'horizontal' | 'vertical'` Required: false Default Value: `"horizontal"` Description: The orientation of the slider **`origin`** Type: `'start' | 'center'` Required: false Default Value: `"start"` Description: The origin of the slider range - "start": Useful when the value represents an absolute value - "center": Useful when the value represents an offset (relative) **`readOnly`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the slider is read-only **`step`** Type: `number` Required: false Default Value: `1` Description: The step value of the slider **`thumbAlignment`** Type: `'center' | 'contain'` Required: false Default Value: `"contain"` Description: The alignment of the slider thumb relative to the track - `center`: the thumb will extend beyond the bounds of the slider track. - `contain`: the thumb will be contained within the bounds of the track. **`thumbSize`** Type: `{ width: number; height: number }` Required: false Default Value: `undefined` Description: The slider thumbs dimensions #### Emits **`focusChange`** Type: `[details: FocusChangeDetails]` Description: Function invoked when the slider's focused index changes **`update:modelValue`** Type: `[value: number[]]` Description: The callback fired when the model value changes. **`valueChange`** Type: `[details: ValueChangeDetails]` Description: Function invoked when the value of the slider changes **`valueChangeEnd`** Type: `[details: ValueChangeDetails]` Description: Function invoked when the slider value change is done #### Data Attributes **`data-scope`**: slider **`data-part`**: root **`data-disabled`**: Present when disabled **`data-orientation`**: The orientation of the slider **`data-dragging`**: Present when in the dragging state **`data-invalid`**: Present when invalid **`data-focus`**: Present when focused ### Control #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: slider **`data-part`**: control **`data-dragging`**: Present when in the dragging state **`data-disabled`**: Present when disabled **`data-orientation`**: The orientation of the control **`data-invalid`**: Present when invalid **`data-focus`**: Present when focused ### DraggingIndicator #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: slider **`data-part`**: dragging-indicator **`data-orientation`**: The orientation of the draggingindicator **`data-state`**: "open" | "closed" ### HiddenInput #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Label #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: slider **`data-part`**: label **`data-disabled`**: Present when disabled **`data-orientation`**: The orientation of the label **`data-invalid`**: Present when invalid **`data-dragging`**: Present when in the dragging state **`data-focus`**: Present when focused ### MarkerGroup #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: slider **`data-part`**: marker-group **`data-orientation`**: The orientation of the markergroup ### Marker #### Props **`value`** Type: `number` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: slider **`data-part`**: marker **`data-orientation`**: The orientation of the marker **`data-value`**: The value of the item **`data-disabled`**: Present when disabled **`data-state`**: ### Range #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: slider **`data-part`**: range **`data-dragging`**: Present when in the dragging state **`data-focus`**: Present when focused **`data-invalid`**: Present when invalid **`data-disabled`**: Present when disabled **`data-orientation`**: The orientation of the range ### RootProvider #### Props **`value`** Type: `SliderApi` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Thumb #### Props **`index`** Type: `number` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`name`** Type: `string` Required: false Default Value: `undefined` Description: undefined #### Data Attributes **`data-scope`**: slider **`data-part`**: thumb **`data-index`**: The index of the item **`data-name`**: **`data-disabled`**: Present when disabled **`data-orientation`**: The orientation of the thumb **`data-focus`**: Present when focused **`data-dragging`**: Present when in the dragging state ### Track #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: slider **`data-part`**: track **`data-disabled`**: Present when disabled **`data-invalid`**: Present when invalid **`data-dragging`**: Present when in the dragging state **`data-orientation`**: The orientation of the track **`data-focus`**: Present when focused ### ValueText #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: slider **`data-part`**: value-text **`data-disabled`**: Present when disabled **`data-orientation`**: The orientation of the valuetext **`data-invalid`**: Present when invalid **`data-focus`**: Present when focused ## Accessibility Complies with the [Slider WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/slider/). ### Keyboard Support **`ArrowRight`** Description: Increments the slider based on defined step **`ArrowLeft`** Description: Decrements the slider based on defined step **`ArrowUp`** Description: Increases the value by the step amount. **`ArrowDown`** Description: Decreases the value by the step amount. **`PageUp`** Description: Increases the value by a larger step **`PageDown`** Description: Decreases the value by a larger step **`Shift + ArrowUp`** Description: Increases the value by a larger step **`Shift + ArrowDown`** Description: Decreases the value by a larger step **`Home`** Description: Sets the value to its minimum. **`End`** Description: Sets the value to its maximum. # Splitter ## Anatomy To set up the splitter correctly, you'll need to understand its anatomy and how we name its parts. > Each part includes a `data-part` attribute to help identify them in the DOM. ## Examples Learn how to use the `Splitter` component in your project. Let's take a look at the most basic example: ```vue ``` ### Using Render Props The Splitter component allows you to pass a function as a child to gain direct access to its API. This provides more control and allows you to modify the size of the panels programmatically: ```vue ``` ### Handling Events Splitter also provides `onResizeStart`, `onResize`, and `onResizeEnd` events which can be useful to perform some actions during the start and end of the resizing process: ```vue ``` ### Vertical Splitter By default, the Splitter component is horizontal. If you need a vertical splitter, use the `orientation` prop: ```vue ``` ### Collapsible Panels To make a panel collapsible, set the `collapsible` prop to `true` on the panel you want to make collapsible. Additionally, you can use the `collapsedSize` prop to set the size of the panel when it's collapsed. > This can be useful for building sidebar layouts. ```vue ``` ### Multiple Panels Here's an example of how to use the `Splitter` component with multiple panels. ```vue ``` ### Using the Root Provider The `RootProvider` component provides a context for the splitter. It accepts the value of the `useSplitter` hook. You can leverage it to access the component state and methods from outside the splitter. ```vue ``` > If you're using the `RootProvider` component, you don't need to use the `Root` component. ## API Reference ### Root #### Props **`panels`** Type: `PanelData[]` Required: true Default Value: `undefined` Description: The size constraints of the panels. **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`defaultSize`** Type: `number[]` Required: false Default Value: `undefined` Description: The initial size of the panels when rendered. Use when you don't need to control the size of the panels. **`id`** Type: `string` Required: false Default Value: `undefined` Description: The unique identifier of the machine. **`ids`** Type: `Partial<{ root: string resizeTrigger(id: string): string label(id: string): string panel(id: string | number): string }>` Required: false Default Value: `undefined` Description: The ids of the elements in the splitter. Useful for composition. **`keyboardResizeBy`** Type: `number` Required: false Default Value: `undefined` Description: The number of pixels to resize the panel by when the keyboard is used. **`nonce`** Type: `string` Required: false Default Value: `undefined` Description: The nonce for the injected splitter cursor stylesheet. **`orientation`** Type: `'horizontal' | 'vertical'` Required: false Default Value: `"horizontal"` Description: The orientation of the splitter. Can be `horizontal` or `vertical` **`size`** Type: `number[]` Required: false Default Value: `undefined` Description: The controlled size data of the panels #### Emits **`collapse`** Type: `[details: ExpandCollapseDetails]` Description: Function called when a panel is collapsed. **`expand`** Type: `[details: ExpandCollapseDetails]` Description: Function called when a panel is expanded. **`resize`** Type: `[details: ResizeDetails]` Description: Function called when the splitter is resized. **`resizeEnd`** Type: `[details: ResizeEndDetails]` Description: Function called when the splitter resize ends. **`resizeStart`** Type: `[]` Description: Function called when the splitter resize starts. **`update:size`** Type: `[size: number[]]` Description: The callback fired when the model value changes. #### Data Attributes **`data-scope`**: splitter **`data-part`**: root **`data-orientation`**: The orientation of the splitter ### Panel #### Props **`id`** Type: `string` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: splitter **`data-part`**: panel **`data-orientation`**: The orientation of the panel **`data-id`**: **`data-index`**: The index of the item ### ResizeTrigger #### Props **`id`** Type: ``${string}:${string}`` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`disabled`** Type: `boolean` Required: false Default Value: `undefined` Description: undefined #### Data Attributes **`data-scope`**: splitter **`data-part`**: resize-trigger **`data-id`**: **`data-orientation`**: The orientation of the resizetrigger **`data-focus`**: Present when focused **`data-disabled`**: Present when disabled ### RootProvider #### Props **`value`** Type: `SplitterApi` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ## Accessibility Complies with the [Window Splitter WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/windowsplitter/). # Steps ## Usage The `Steps` component is used to guide users through a series of steps in a process. - Supports horizontal and vertical orientations. - Support for changing the active step with the keyboard and pointer. - Support for linear and non-linear steps. ```jsx import { Steps } from '@ark-ui/react/steps' ``` ## Examples ### Basic Here's a basic example of the `Steps` component. ```vue ``` ### Using the Root Provider The `RootProvider` component provides a context for the steps. It accepts the value of the `useSteps` hook. You can leverage it to access the component state and methods from outside the steps. ```vue ``` > If you're using the `RootProvider` component, you don't need to use the `Root` component. ## API Reference ### Root #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`count`** Type: `number` Required: false Default Value: `undefined` Description: The total number of steps **`defaultStep`** Type: `number` Required: false Default Value: `undefined` Description: The initial value of the stepper when rendered. Use when you don't need to control the value of the stepper. **`id`** Type: `string` Required: false Default Value: `undefined` Description: The unique identifier of the machine. **`ids`** Type: `ElementIds` Required: false Default Value: `undefined` Description: The custom ids for the stepper elements **`linear`** Type: `boolean` Required: false Default Value: `undefined` Description: If `true`, the stepper requires the user to complete the steps in order **`orientation`** Type: `'horizontal' | 'vertical'` Required: false Default Value: `"horizontal"` Description: The orientation of the stepper **`step`** Type: `number` Required: false Default Value: `undefined` Description: The controlled value of the stepper #### Data Attributes **`data-scope`**: steps **`data-part`**: root **`data-orientation`**: The orientation of the steps ### CompletedContent #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Content #### Props **`index`** Type: `number` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: steps **`data-part`**: content **`data-state`**: "open" | "closed" **`data-orientation`**: The orientation of the content ### Indicator #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: steps **`data-part`**: indicator **`data-complete`**: Present when the indicator value is complete **`data-current`**: Present when current **`data-incomplete`**: ### Item #### Props **`index`** Type: `number` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: steps **`data-part`**: item **`data-orientation`**: The orientation of the item ### List #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: steps **`data-part`**: list **`data-orientation`**: The orientation of the list ### NextTrigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### PrevTrigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Progress #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: steps **`data-part`**: progress **`data-complete`**: Present when the progress value is complete ### RootProvider #### Props **`value`** Type: `StepsApi` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Separator #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: steps **`data-part`**: separator **`data-orientation`**: The orientation of the separator **`data-complete`**: Present when the separator value is complete **`data-current`**: Present when current **`data-incomplete`**: ### Trigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: steps **`data-part`**: trigger **`data-state`**: "open" | "closed" **`data-orientation`**: The orientation of the trigger **`data-complete`**: Present when the trigger value is complete **`data-current`**: Present when current **`data-incomplete`**: # Switch ## Anatomy To set up the switch correctly, you'll need to understand its anatomy and how we name its parts. > Each part includes a `data-part` attribute to help identify them in the DOM. ### Design impact on the asChild property The `Switch.Root` element of the switch is a `label` element. This is because the switch is a form control and should be associated with a label to provide context and meaning to the user. Otherwise, the HTML and accessibility structure will be invalid. > If you need to use the `asChild` property, make sure that the `label` element is the direct child of the `Switch.Root` > component. ## Examples Learn how to use the `Switch` component in your project. Let's take a look at the most basic example: ```vue ``` ### Controlled Switch For a controlled Switch component, the state of the toggle is managed using the checked prop, and updates when the `onCheckedChange` event handler is called: ```vue ``` ### Render Prop Usage The Switch component also allows for a render prop, granting direct access to its internal state. This enables you to dynamically adjust and customize aspects of the component based on its current state: ```vue ``` ### Using the Field Component The `Field` component helps manage form-related state and accessibility attributes of a switch. It includes handling ARIA labels, helper text, and error text to ensure proper accessibility. ```vue ``` ### Using the Root Provider The `RootProvider` component provides a context for the switch. It accepts the value of the `useSwitch` hook. You can leverage it to access the component state and methods from outside the switch. ```vue ``` > If you're using the `RootProvider` component, you don't need to use the `Root` component. ## API Reference ### Root #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`checked`** Type: `boolean` Required: false Default Value: `undefined` Description: The controlled checked state of the switch **`defaultChecked`** Type: `boolean` Required: false Default Value: `undefined` Description: The initial checked state of the switch when rendered. Use when you don't need to control the checked state of the switch. **`disabled`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the switch is disabled. **`form`** Type: `string` Required: false Default Value: `undefined` Description: The id of the form that the switch belongs to **`id`** Type: `string` Required: false Default Value: `undefined` Description: The unique identifier of the machine. **`ids`** Type: `Partial<{ root: string; hiddenInput: string; control: string; label: string; thumb: string }>` Required: false Default Value: `undefined` Description: The ids of the elements in the switch. Useful for composition. **`invalid`** Type: `boolean` Required: false Default Value: `undefined` Description: If `true`, the switch is marked as invalid. **`label`** Type: `string` Required: false Default Value: `undefined` Description: Specifies the localized strings that identifies the accessibility elements and their states **`name`** Type: `string` Required: false Default Value: `undefined` Description: The name of the input field in a switch (Useful for form submission). **`readOnly`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the switch is read-only **`required`** Type: `boolean` Required: false Default Value: `undefined` Description: If `true`, the switch input is marked as required, **`value`** Type: `string` Required: false Default Value: `"on"` Description: The value of checkbox input. Useful for form submission. #### Emits **`checkedChange`** Type: `[details: CheckedChangeDetails]` Description: Function to call when the switch is clicked. **`update:checked`** Type: `[checked: boolean]` Description: The callback fired when the model value changes. #### Data Attributes **`data-active`**: Present when active or pressed **`data-focus`**: Present when focused **`data-focus-visible`**: Present when focused with keyboard **`data-readonly`**: Present when read-only **`data-hover`**: Present when hovered **`data-disabled`**: Present when disabled **`data-state`**: "checked" | "unchecked" **`data-invalid`**: Present when invalid ### Control #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-active`**: Present when active or pressed **`data-focus`**: Present when focused **`data-focus-visible`**: Present when focused with keyboard **`data-readonly`**: Present when read-only **`data-hover`**: Present when hovered **`data-disabled`**: Present when disabled **`data-state`**: "checked" | "unchecked" **`data-invalid`**: Present when invalid ### HiddenInput #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Label #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-active`**: Present when active or pressed **`data-focus`**: Present when focused **`data-focus-visible`**: Present when focused with keyboard **`data-readonly`**: Present when read-only **`data-hover`**: Present when hovered **`data-disabled`**: Present when disabled **`data-state`**: "checked" | "unchecked" **`data-invalid`**: Present when invalid ### RootProvider #### Props **`value`** Type: `SwitchApi` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Thumb #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-active`**: Present when active or pressed **`data-focus`**: Present when focused **`data-focus-visible`**: Present when focused with keyboard **`data-readonly`**: Present when read-only **`data-hover`**: Present when hovered **`data-disabled`**: Present when disabled **`data-state`**: "checked" | "unchecked" **`data-invalid`**: Present when invalid ## Accessibility Complies with the [Switch WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/switch/). ### Keyboard Support **`Space + Enter`** Description: Toggle the switch # Tabs ## Anatomy To set up the tabs correctly, you'll need to understand its anatomy and how we name its parts. > Each part includes a `data-part` attribute to help identify them in the DOM. ## Examples Learn how to use the `Tabs` component in your project. Let's take a look at the most basic example: ```vue ``` ### Initial Tab To set a default tab on initial render, use the `defaultValue` prop: ```vue ``` ### Tab Indicator To provide a visual cue for the selected tab, use the `Tabs.Indicator` component: ```vue ``` ### Lazy Mounting Lazy mounting is a feature that allows the content of a tab to be rendered only when the tab is first activated. This is useful for performance optimization, especially when tab content is large or complex. To enable lazy mounting, use the `lazyMount` prop on the `Tabs.Content` component. In addition, the `unmountOnExit` prop can be used in conjunction with `lazyMount` to unmount the tab content when the tab is deactivated, freeing up resources. The next time the tab is activated, its content will be re-rendered. ```vue ``` ### Disabled Tab To disable a tab, simply pass the `disabled` prop to the `Tabs.Trigger` component: ```vue ``` ### Controlled Tabs To create a controlled Tabs component, manage the current selected tab using the `value` prop and update it when the `onValueChange` event handler is called: ```vue ``` ### Router Controlled Tabs When using frameworks like Next.js, Remix, or React Router, controlling the active tabs based on the URL can be useful. To achieve this, you need to do two things: - Set the `value` prop to the current URL path. - Listen to the `onValueChange` event and update the URL path. Here's an example using Remix Router ```tsx import { Tabs } from '@ark-ui/react/tabs' import { useLocation, useNavigate, Link } from '@remix-run/react' export default function App() { const { pathname } = useLocation() const navigate = useNavigate() const lastPathFragment = pathname.substring(pathname.lastIndexOf('/') + 1) const activeTab = lastPathFragment.length > 0 ? lastPathFragment : 'homepage' return ( { navigate(`/${value === 'home' ? '' : value}`) }} > Home Page 1 Page 2 ) } ``` ### Vertical Tabs The default orientation of the tabs is `horizontal`. To change the orientation, set the `orientation` prop to `vertical`. ```vue ``` ### Manual Activation By default, the tab can be selected when it receives focus from either the keyboard or pointer interaction. This is called automatic tab activation. In contrast, manual tab activation means the tab is selected with the Enter key or by clicking on the tab. ```vue ``` ### Using the Root Provider The `RootProvider` component provides a context for the tabs. It accepts the value of the `useTabs` hook. You can leverage it to access the component state and methods from outside the tabs. ```vue ``` > If you're using the `RootProvider` component, you don't need to use the `Root` component. ## API Reference ### Root #### Props **`activationMode`** Type: `'manual' | 'automatic'` Required: false Default Value: `"automatic"` Description: The activation mode of the tabs. Can be `manual` or `automatic` - `manual`: Tabs are activated when clicked or press `enter` key. - `automatic`: Tabs are activated when receiving focus **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`composite`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the tab is composite **`defaultValue`** Type: `string` Required: false Default Value: `undefined` Description: The initial selected tab value when rendered. Use when you don't need to control the selected tab value. **`deselectable`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the active tab can be deselected when clicking on it. **`id`** Type: `string` Required: false Default Value: `undefined` Description: The unique identifier of the machine. **`ids`** Type: `Partial<{ root: string; trigger: string; list: string; content: string; indicator: string }>` Required: false Default Value: `undefined` Description: The ids of the elements in the tabs. Useful for composition. **`lazyMount`** Type: `boolean` Required: false Default Value: `false` Description: Whether to enable lazy mounting **`loopFocus`** Type: `boolean` Required: false Default Value: `true` Description: Whether the keyboard navigation will loop from last tab to first, and vice versa. **`modelValue`** Type: `string` Required: false Default Value: `undefined` Description: The v-model value of the tabs **`navigate`** Type: `(details: NavigateDetails) => void` Required: false Default Value: `undefined` Description: Function to navigate to the selected tab when clicking on it. Useful if tab triggers are anchor elements. **`orientation`** Type: `'horizontal' | 'vertical'` Required: false Default Value: `"horizontal"` Description: The orientation of the tabs. Can be `horizontal` or `vertical` - `horizontal`: only left and right arrow key navigation will work. - `vertical`: only up and down arrow key navigation will work. **`translations`** Type: `IntlTranslations` Required: false Default Value: `undefined` Description: Specifies the localized strings that identifies the accessibility elements and their states **`unmountOnExit`** Type: `boolean` Required: false Default Value: `false` Description: Whether to unmount on exit. #### Emits **`focusChange`** Type: `[details: FocusChangeDetails]` Description: Callback to be called when the focused tab changes **`update:modelValue`** Type: `[value: string]` Description: The callback fired when the model value changes. **`valueChange`** Type: `[details: ValueChangeDetails]` Description: Callback to be called when the selected/active tab changes #### Data Attributes **`data-scope`**: tabs **`data-part`**: root **`data-orientation`**: The orientation of the tabs **`data-focus`**: Present when focused ### TabContent #### Props **`value`** Type: `string` Required: true Default Value: `undefined` Description: The value of the tab **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### TabIndicator #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### TabList #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### TabTrigger #### Props **`value`** Type: `string` Required: true Default Value: `undefined` Description: The value of the tab **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`disabled`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the tab is disabled ### RootProvider #### Props **`value`** Type: `TabsApi` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`lazyMount`** Type: `boolean` Required: false Default Value: `false` Description: Whether to enable lazy mounting **`unmountOnExit`** Type: `boolean` Required: false Default Value: `false` Description: Whether to unmount on exit. ## Accessibility Complies with the [Tabs WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/tabs/). ### Keyboard Support **`Tab`** Description: When focus moves onto the tabs, focuses the active trigger. When a trigger is focused, moves focus to the active content. **`ArrowDown`** Description: Moves focus to the next trigger in vertical orientation and activates its associated content. **`ArrowRight`** Description: Moves focus to the next trigger in horizontal orientation and activates its associated content. **`ArrowUp`** Description: Moves focus to the previous trigger in vertical orientation and activates its associated content. **`ArrowLeft`** Description: Moves focus to the previous trigger in horizontal orientation and activates its associated content. **`Home`** Description: Moves focus to the first trigger and activates its associated content. **`End`** Description: Moves focus to the last trigger and activates its associated content. **`Enter + Space`** Description: In manual mode, when a trigger is focused, moves focus to its associated content. # Tags Input ## Anatomy To set up the tags input correctly, you'll need to understand its anatomy and how we name its parts. > Each part includes a `data-part` attribute to help identify them in the DOM. ## Examples Learn how to use the `TagsInput` component in your project. Let's take a look at the most basic example: ```vue ``` ### Navigating and Editing tags When the input has an empty value or the caret is at the start position, the tags can be selected by using the arrow left and arrow right keys. When "visual" focus in on any tag: - Pressing Enter or double-clicking on the tag will put it in edit mode, allowing the user change its value and press Enter to commit the changes. - Pressing Delete or Backspace will delete the tag that has _visual_ focus. ### Setting the initial tags To set the initial tag values, set the `defaultValue` prop. ```vue ``` ### Limiting the number of tags To limit the number of tags within the component, you can set the `max` property to the limit you want. The default value is `Infinity`. When the tag reaches the limit, new tags cannot be added except the `allowOverflow` prop is set to `true`. ```vue ``` ### Validating Tags Before a tag is added, the `validate` function is called to determine whether to accept or reject a tag. A common use-case for validating tags is preventing duplicates or validating the data type. ```vue ``` ### Blur behavior When the tags input is blurred, you can configure the action the component should take by passing the `blurBehavior` prop. - `add` — Adds the tag to the list of tags. - `clear` — Clears the tags input value. ```vue ``` ### Paste behavior To add a tag when a arbitrary value is pasted in the input element, pass the `addOnPaste` prop. When a value is pasted, the component will: - check if the value is a valid tag based on the `validate` option - split the value by the `delimiter` option passed ```vue ``` ### Disable tag editing by default the tags can be edited by double-clicking on the tag or focusing on them and pressing Enter. To disable this behavior, pass `editable={false}` ```vue ``` ### Events During the lifetime of the tags input interaction, here's a list of events we emit: - `onValueChange` — invoked when the tag value changes. - `onHighlightChange` — invoked when a tag has visual focus. - `onValueInvalid` — invoked when the max tag count is reached or the `validate` function returns `false`. ```vue ``` ### Using the Field Component The `Field` component helps manage form-related state and accessibility attributes of a tags input. It includes handling ARIA labels, helper text, and error text to ensure proper accessibility. ```vue ``` ### Using the Root Provider The `RootProvider` component provides a context for the tags-input. It accepts the value of the `useTags-input` hook. You can leverage it to access the component state and methods from outside the tags-input. ```vue ``` > If you're using the `RootProvider` component, you don't need to use the `Root` component. ## API Reference ### Root #### Props **`addOnPaste`** Type: `boolean` Required: false Default Value: `false` Description: Whether to add a tag when you paste values into the tag input **`allowOverflow`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether to allow tags to exceed max. In this case, we'll attach `data-invalid` to the root **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`autoFocus`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the input should be auto-focused **`blurBehavior`** Type: `'add' | 'clear'` Required: false Default Value: `undefined` Description: The behavior of the tags input when the input is blurred - `"add"`: add the input value as a new tag - `"clear"`: clear the input value **`defaultInputValue`** Type: `string` Required: false Default Value: `undefined` Description: The initial tag input value when rendered. Use when you don't need to control the tag input value. **`defaultValue`** Type: `string[]` Required: false Default Value: `undefined` Description: The initial tag value when rendered. Use when you don't need to control the tag value. **`delimiter`** Type: `string | RegExp` Required: false Default Value: `","` Description: The character that serves has: - event key to trigger the addition of a new tag - character used to split tags when pasting into the input **`disabled`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the tags input should be disabled **`editable`** Type: `boolean` Required: false Default Value: `true` Description: Whether a tag can be edited after creation, by pressing `Enter` or double clicking. **`form`** Type: `string` Required: false Default Value: `undefined` Description: The associate form of the underlying input element. **`id`** Type: `string` Required: false Default Value: `undefined` Description: The unique identifier of the machine. **`ids`** Type: `Partial<{ root: string input: string hiddenInput: string clearBtn: string label: string control: string item(opts: ItemProps): string itemDeleteTrigger(opts: ItemProps): string itemInput(opts: ItemProps): string }>` Required: false Default Value: `undefined` Description: The ids of the elements in the tags input. Useful for composition. **`inputValue`** Type: `string` Required: false Default Value: `undefined` Description: The controlled tag input's value **`invalid`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the tags input is invalid **`max`** Type: `number` Required: false Default Value: `Infinity` Description: The max number of tags **`maxLength`** Type: `number` Required: false Default Value: `undefined` Description: The max length of the input. **`modelValue`** Type: `string[]` Required: false Default Value: `undefined` Description: The v-model value of the tags input **`name`** Type: `string` Required: false Default Value: `undefined` Description: The name attribute for the input. Useful for form submissions **`readOnly`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the tags input should be read-only **`required`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the tags input is required **`translations`** Type: `IntlTranslations` Required: false Default Value: `undefined` Description: Specifies the localized strings that identifies the accessibility elements and their states **`validate`** Type: `(details: ValidateArgs) => boolean` Required: false Default Value: `undefined` Description: Returns a boolean that determines whether a tag can be added. Useful for preventing duplicates or invalid tag values. #### Emits **`focusOutside`** Type: `[event: FocusOutsideEvent]` Description: Function called when the focus is moved outside the component **`highlightChange`** Type: `[details: HighlightChangeDetails]` Description: Callback fired when a tag is highlighted by pointer or keyboard navigation **`inputValueChange`** Type: `[details: InputValueChangeDetails]` Description: Callback fired when the input value is updated **`interactOutside`** Type: `[event: InteractOutsideEvent]` Description: Function called when an interaction happens outside the component **`pointerDownOutside`** Type: `[event: PointerDownOutsideEvent]` Description: Function called when the pointer is pressed down outside the component **`update:inputValue`** Type: `[value: string]` Description: The callback fired when the input value changes. **`update:modelValue`** Type: `[value: string[]]` Description: The callback fired when the model value changes. **`valueChange`** Type: `[details: ValueChangeDetails]` Description: Callback fired when the tag values is updated **`valueInvalid`** Type: `[details: ValidityChangeDetails]` Description: Callback fired when the max tag count is reached or the `validateTag` function returns `false` #### Data Attributes **`data-scope`**: tags-input **`data-part`**: root **`data-invalid`**: Present when invalid **`data-readonly`**: Present when read-only **`data-disabled`**: Present when disabled **`data-focus`**: Present when focused **`data-empty`**: ### ClearTrigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: tags-input **`data-part`**: clear-trigger **`data-readonly`**: Present when read-only ### Control #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: tags-input **`data-part`**: control **`data-disabled`**: Present when disabled **`data-readonly`**: Present when read-only **`data-invalid`**: Present when invalid **`data-focus`**: Present when focused ### HiddenInput #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Input #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: tags-input **`data-part`**: input **`data-invalid`**: Present when invalid **`data-readonly`**: Present when read-only ### ItemDeleteTrigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### ItemInput #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### ItemPreview #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: tags-input **`data-part`**: item-preview **`data-value`**: The value of the item **`data-disabled`**: Present when disabled **`data-highlighted`**: Present when highlighted ### Item #### Props **`index`** Type: `string | number` Required: true Default Value: `undefined` Description: undefined **`value`** Type: `string` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`disabled`** Type: `boolean` Required: false Default Value: `undefined` Description: undefined #### Data Attributes **`data-scope`**: tags-input **`data-part`**: item **`data-value`**: The value of the item **`data-disabled`**: Present when disabled ### ItemText #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: tags-input **`data-part`**: item-text **`data-disabled`**: Present when disabled **`data-highlighted`**: Present when highlighted ### Label #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: tags-input **`data-part`**: label **`data-disabled`**: Present when disabled **`data-invalid`**: Present when invalid **`data-readonly`**: Present when read-only ### RootProvider #### Props **`value`** Type: `TagsInputApi` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ## Accessibility ### Keyboard Support **`ArrowLeft`** Description: Moves focus to the previous tag item **`ArrowRight`** Description: Moves focus to the next tag item **`Backspace`** Description: Deletes the tag item that has visual focus or the last tag item **`Enter`** Description: When a tag item has visual focus, it puts the tag in edit mode.
                When the input has focus, it adds the value to the list of tags
                **`Delete`** Description: Deletes the tag item that has visual focus **`Control + V`** Description: When `addOnPaste` is set. Adds the pasted value as a tags # Timer ## Examples Learn how to use the `Timer` component in your project. Let's take a look at the most basic example: ```vue ``` ### Countdown Timer You can create a countdown timer by setting the `targetMs` prop to a future timestamp: ```vue ``` ### Timer Events The Timer component provides events that you can listen to for various timer-related actions. - The `onComplete` event is triggered when the timer reaches its target time. - The `onTick` event is called on each timer update, providing details about the current timer state. ```vue ``` ### Using the Root Provider The `RootProvider` component provides a context for the timer. It accepts the value of the `useTimer` hook. You can leverage it to access the component state and methods from outside the timer. ```vue ``` > If you're using the `RootProvider` component, you don't need to use the `Root` component. ## API Reference ### Root #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`autoStart`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the timer should start automatically **`countdown`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the timer should countdown, decrementing the timer on each tick. **`id`** Type: `string` Required: false Default Value: `undefined` Description: The unique identifier of the machine. **`ids`** Type: `Partial<{ root: string; area: string }>` Required: false Default Value: `undefined` Description: The ids of the timer parts **`interval`** Type: `number` Required: false Default Value: `250` Description: The interval in milliseconds to update the timer count. **`startMs`** Type: `number` Required: false Default Value: `undefined` Description: The total duration of the timer in milliseconds. **`targetMs`** Type: `number` Required: false Default Value: `undefined` Description: The minimum count of the timer in milliseconds. #### Emits **`complete`** Type: `[]` Description: Function invoked when the timer is completed **`tick`** Type: `[details: TickDetails]` Description: Function invoked when the timer ticks ### ActionTrigger #### Props **`action`** Type: `TimerAction` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Area #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Control #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Item #### Props **`type`** Type: `keyof Time` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: timer **`data-part`**: item **`data-type`**: The type of the item ### RootProvider #### Props **`value`** Type: `TimerApi` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Separator #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. # Toast ## Anatomy To set up the toast correctly, you'll need to understand its anatomy and how we name its parts. > Each part includes a `data-part` attribute to help identify them in the DOM. ## Setup To use the Toast component, create the toast engine using the `createToaster` function. This function manages the placement and grouping of toasts, and provides a `toast` object needed to create toast notification. ```ts const toaster = createToaster({ placement: 'bottom-end', overlap: true, gap: 24, }) ``` ## Examples Here's an example of creating a toast using the `toast.create` method. ```vue ``` ### Update Toast To update a toast, use the `toast.update` method. ```vue ``` ### Action To add an action to a toast, use the `toast.action` property. ```vue ``` ## API Reference ### Root #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: toast **`data-part`**: root **`data-state`**: "open" | "closed" **`data-type`**: The type of the item **`data-placement`**: The placement of the toast **`data-align`**: **`data-side`**: **`data-mounted`**: Present when mounted **`data-paused`**: Present when paused **`data-first`**: **`data-sibling`**: **`data-stack`**: **`data-overlap`**: Present when overlapping ### ActionTrigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### CloseTrigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Description #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Title #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Toaster #### Props **`toaster`** Type: `CreateToasterReturn` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. # Toggle Group ## Anatomy To set up the toggle group correctly, you'll need to understand its anatomy and how we name its parts. > Each part includes a `data-part` attribute to help identify them in the DOM. ## Examples Learn how to use the `ToggleGroup` component in your project. Let's take a look at the most basic example: ```vue ``` ### Multiple Selection Demonstrates how to enable `multiple` selection within the group. ```vue ``` ### Initial Value Shows how to set an initial value in the toggle group. ```vue ``` ### Using the Root Provider The `RootProvider` component provides a context for the toggle-group. It accepts the value of the `useToggle-group` hook. You can leverage it to access the component state and methods from outside the toggle-group. ```vue ``` > If you're using the `RootProvider` component, you don't need to use the `Root` component. ## API Reference ### Root #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`defaultValue`** Type: `string[]` Required: false Default Value: `undefined` Description: The initial selected value of the toggle group when rendered. Use when you don't need to control the selected value of the toggle group. **`disabled`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the toggle is disabled. **`id`** Type: `string` Required: false Default Value: `undefined` Description: The unique identifier of the machine. **`ids`** Type: `Partial<{ root: string; item(value: string): string }>` Required: false Default Value: `undefined` Description: The ids of the elements in the toggle. Useful for composition. **`loopFocus`** Type: `boolean` Required: false Default Value: `true` Description: Whether to loop focus inside the toggle group. **`modelValue`** Type: `string[]` Required: false Default Value: `undefined` Description: The v-model value of the toggle group **`multiple`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether to allow multiple toggles to be selected. **`orientation`** Type: `Orientation` Required: false Default Value: `"horizontal"` Description: The orientation of the toggle group. **`rovingFocus`** Type: `boolean` Required: false Default Value: `true` Description: Whether to use roving tab index to manage focus. #### Emits **`update:modelValue`** Type: `[value: string[]]` Description: The callback fired when the model value changes. **`valueChange`** Type: `[details: ValueChangeDetails]` Description: Function to call when the toggle is clicked. #### Data Attributes **`data-scope`**: toggle-group **`data-part`**: root **`data-disabled`**: Present when disabled **`data-orientation`**: The orientation of the toggle-group **`data-focus`**: Present when focused ### Item #### Props **`value`** Type: `string` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`disabled`** Type: `boolean` Required: false Default Value: `undefined` Description: undefined #### Data Attributes **`data-scope`**: toggle-group **`data-part`**: item **`data-focus`**: Present when focused **`data-disabled`**: Present when disabled **`data-orientation`**: The orientation of the item **`data-state`**: "on" | "off" ### RootProvider #### Props **`value`** Type: `ToggleGroupApi` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ## Accessibility ### Keyboard Support **`Tab`** Description: Moves focus to either the pressed item or the first item in the group. **`Space`** Description: Activates/deactivates the item. **`Enter`** Description: Activates/deactivates the item. **`ArrowDown`** Description: Moves focus to the next item in the group. **`ArrowRight`** Description: Moves focus to the next item in the group. **`ArrowUp`** Description: Moves focus to the previous item in the group. **`ArrowLeft`** Description: Moves focus to the previous item in the group. **`Home`** Description: Moves focus to the first item. **`End`** Description: Moves focus to the last item. # Toggle ## Examples Here's a basic example of how to use the `Toggle` component: ```vue ``` ### Controlled Use the `pressed` and `onPressedChange` props to control the toggle's state. ```vue ``` ### Disabled Use the `disabled` prop to disable the toggle. ```vue ``` ### Indicator Use the `Toggle.Indicator` component to render different indicators based on the state of the toggle. ```vue ``` ## API Reference ### Root #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`defaultPressed`** Type: `boolean` Required: false Default Value: `undefined` Description: The default pressed state of the toggle. **`onPressedChange`** Type: `(pressed: boolean) => void` Required: false Default Value: `undefined` Description: Event handler called when the pressed state of the toggle changes. **`pressed`** Type: `boolean` Required: false Default Value: `undefined` Description: The pressed state of the toggle. #### Data Attributes **`data-scope`**: toggle **`data-part`**: root **`data-state`**: "on" | "off" **`data-pressed`**: Present when pressed **`data-disabled`**: Present when disabled ### Indicator #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`fallback`** Type: `slot` Required: false Default Value: `undefined` Description: The fallback content to render when the toggle is not pressed. #### Data Attributes **`data-scope`**: toggle **`data-part`**: indicator **`data-disabled`**: Present when disabled **`data-pressed`**: Present when pressed **`data-state`**: "on" | "off" # Tooltip ## Anatomy To set up the tooltip correctly, you'll need to understand its anatomy and how we name its parts. > Each part includes a `data-part` attribute to help identify them in the DOM. ## Examples Learn how to use the `Tooltip` component in your project. Let's take a look at the most basic example: ```vue ``` ### Controlled Tooltip To create a controlled Tooltip component, manage the state of whether the tooltip is open using the `open` prop: ```vue ``` ### Using a Render Function For more control over the Tooltip's functionality, you can use a function as a child, which provides access to the Tooltip API: ```vue ``` ### Adding an Arrow To display an arrow pointing to the trigger from the tooltip, use the `Tooltip.Arrow` and `Tooltip.ArrowTip` components: ```vue ``` ### Configuring Delay Timings To configure the delay timings for the Tooltip, use the `closeDelay` and `openDelay` props: ```vue ``` ### Custom Positioning To customize the position of the Tooltip relative to the trigger, use the `positioning` prop: ```vue ``` ### Using the Root Provider The `RootProvider` component provides a context for the tooltip. It accepts the value of the `useTooltip` hook. You can leverage it to access the component state and methods from outside the tooltip. ```vue ``` > If you're using the `RootProvider` component, you don't need to use the `Root` component. ## API Reference ### Root #### Props **`aria-label`** Type: `string` Required: false Default Value: `undefined` Description: Custom label for the tooltip. **`closeDelay`** Type: `number` Required: false Default Value: `500` Description: The close delay of the tooltip. **`closeOnClick`** Type: `boolean` Required: false Default Value: `true` Description: Whether the tooltip should close on click **`closeOnEscape`** Type: `boolean` Required: false Default Value: `true` Description: Whether to close the tooltip when the Escape key is pressed. **`closeOnPointerDown`** Type: `boolean` Required: false Default Value: `true` Description: Whether to close the tooltip on pointerdown. **`closeOnScroll`** Type: `boolean` Required: false Default Value: `true` Description: Whether the tooltip should close on scroll **`defaultOpen`** Type: `boolean` Required: false Default Value: `undefined` Description: The initial open state of the tooltip when rendered. Use when you don't need to control the open state of the tooltip. **`disabled`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the tooltip is disabled **`id`** Type: `string` Required: false Default Value: `undefined` Description: The unique identifier of the machine. **`ids`** Type: `Partial<{ trigger: string; content: string; arrow: string; positioner: string }>` Required: false Default Value: `undefined` Description: The ids of the elements in the tooltip. Useful for composition. **`interactive`** Type: `boolean` Required: false Default Value: `false` Description: Whether the tooltip's content is interactive. In this mode, the tooltip will remain open when user hovers over the content. **`lazyMount`** Type: `boolean` Required: false Default Value: `false` Description: Whether to enable lazy mounting **`open`** Type: `boolean` Required: false Default Value: `undefined` Description: The controlled open state of the tooltip **`openDelay`** Type: `number` Required: false Default Value: `1000` Description: The open delay of the tooltip. **`positioning`** Type: `PositioningOptions` Required: false Default Value: `undefined` Description: The user provided options used to position the popover content **`unmountOnExit`** Type: `boolean` Required: false Default Value: `false` Description: Whether to unmount on exit. #### Emits **`openChange`** Type: `[details: OpenChangeDetails]` Description: Function called when the tooltip is opened. **`update:open`** Type: `[open: boolean]` Description: The callback fired when the open state changes. ### Arrow #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### ArrowTip #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Content #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: tooltip **`data-part`**: content **`data-state`**: "open" | "closed" **`data-placement`**: The placement of the content ### Positioner #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### RootProvider #### Props **`value`** Type: `TooltipApi` Required: true Default Value: `undefined` Description: undefined **`lazyMount`** Type: `boolean` Required: false Default Value: `false` Description: Whether to enable lazy mounting **`unmountOnExit`** Type: `boolean` Required: false Default Value: `false` Description: Whether to unmount on exit. ### Trigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: tooltip **`data-part`**: trigger **`data-expanded`**: Present when expanded **`data-state`**: "open" | "closed" ## Accessibility Complies with the [Tooltip WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/tooltip/). ### Keyboard Support **`Tab`** Description: Opens/closes the tooltip without delay. **`Escape`** Description: If open, closes the tooltip without delay. # Tour ## Features - Support for different step types such as "dialog", "floating", "tooltip" or "wait" - Support for customizable content per step - Wait steps for waiting for a specific selector to appear on the page before showing the next step - Flexible positioning of the tour dialog per step - Progress tracking shows users their progress through the tour ## Anatomy To set up the tour correctly, it's essential to understand its anatomy and the naming of its parts. > Each part includes a `data-part` attribute to help identify them in the DOM. ## Steps ### Using step types The tour machine supports different types of steps, allowing you to create a diverse and interactive tour experience. The available step types are defined in the `StepType` type: - `tooltip`: Displays the step content as a tooltip, typically positioned near the target element. - `dialog`: Shows the step content in a modal dialog centered on screen, useful for starting or ending the tour. This usually don't have a `target` defined. - `floating`: Presents the step content as a floating element, which can be positioned flexibly on the screen. This usually don't have a `target` defined. - `wait`: A special type that waits for a specific condition before proceeding to the next step. ```tsx const steps: TourStepDetails[] = [ { id: 'step-1', type: 'tooltip', placement: 'top-start', target: () => document.querySelector('#target-1'), title: 'Tooltip Step', description: 'This is a tooltip step', }, { id: 'step-2', type: 'dialog', title: 'Dialog Step', description: 'This is a dialog step', }, { id: 'step-3', type: 'floating', placement: 'top-start', title: 'Floating Step', description: 'This is a floating step', }, { id: 'step-4', type: 'wait', title: 'Wait Step', description: 'This is a wait step', effect({ next }) { // do something and go next // you can also return a cleanup }, }, ] ``` ### Configuring actions Every step supports a list of actions that are rendered in the step footer.Use the `actions` property to define each action. ```tsx const steps: TourStepDetails[] = [ { id: 'step-1', type: 'dialog', title: 'Dialog Step', description: 'This is a dialog step', actions: [{ label: 'Show me a tour!', action: 'next' }], }, ] ``` ### Changing tooltip placement Use the `placement` property to define the placement of the tooltip. ```tsx {5} const steps: TourStepDetails[] = [ { id: 'step-1', type: 'tooltip', placement: 'top-start', // ... }, ] ``` ### Hiding the arrow Set `arrow: false` in the step property to hide the tooltip arrow. This is only useful for tooltip steps. ```tsx {5} const steps: TourStepDetails[] = [ { id: 'step-1', type: 'tooltip', arrow: false, }, ] ``` ### Hiding the backdrop Set `backdrop: false` in the step property to hide the backdrop. This applies to all step types except the `wait` step. ```tsx {5} const steps: TourStepDetails[] = [ { id: 'step-1', type: 'dialog', backdrop: false, }, ] ``` ### Step Effects Step effects are functions that are called before a step is opened. They are useful for adding custom logic to a step. This function provides the following methods: - `next()`: Call this method to move to the next step. - `show()`: Call this method to show the current step. - `update(details: StepDetails)`: Call this method to update the details of the current step (say, after data has been fetched). ```tsx const steps: TourStepDetails[] = [ { id: 'step-1', type: 'tooltip', effect({ next, show, update }) { fetchData().then((res) => { // update the step details update({ title: res.title }) // then show show the step show() }) return () => { // cleanup fetch data } }, }, ] ``` ### Wait Steps Wait steps are useful when you need to wait for a specific condition before proceeding to the next step. Use the step `effect` function to perform an action and then call `next()` to move to the next step. > **Note:** You cannot call `show()` in a wait step. ```tsx const steps: TourStepDetails[] = [ { id: 'step-1', type: 'wait', effect({ next }) { const button = document.querySelector('#button') const listener = () => next() button.addEventListener('click', listener) return () => button.removeEventListener('click', listener) }, }, ] ``` ## Styling guide Ensure the `box-sizing` is set to `border-box` for the means of measuring the tour target. ```css * { box-sizing: border-box; } ``` Ensure the `body` has a `position` of `relative`. ```css body { position: relative; } ``` ## API Reference ### Root #### Props **`tour`** Type: `TourApi` Required: true Default Value: `undefined` Description: undefined **`lazyMount`** Type: `boolean` Required: false Default Value: `false` Description: Whether to enable lazy mounting **`unmountOnExit`** Type: `boolean` Required: false Default Value: `false` Description: Whether to unmount on exit. #### Emits **`focusOutside`** Type: `[event: FocusOutsideEvent]` Description: Function called when the focus is moved outside the component **`interactOutside`** Type: `[event: InteractOutsideEvent]` Description: Function called when an interaction happens outside the component **`pointerDownOutside`** Type: `[event: PointerDownOutsideEvent]` Description: Function called when the pointer is pressed down outside the component **`statusChange`** Type: `[details: StatusChangeDetails]` Description: Callback when the tour is opened or closed **`stepChange`** Type: `[details: StepChangeDetails]` Description: Callback when the highlighted step changes **`stepsChange`** Type: `[details: { steps: StepDetails[] }]` Description: Callback when the steps change ### ActionTrigger #### Props **`action`** Type: `StepAction` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: tour **`data-part`**: action-trigger **`data-type`**: The type of the item **`data-disabled`**: Present when disabled ### Arrow #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### ArrowTip #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Backdrop #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: tour **`data-part`**: backdrop **`data-state`**: "open" | "closed" **`data-type`**: The type of the item ### CloseTrigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: tour **`data-part`**: close-trigger **`data-type`**: The type of the item ### Content #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: tour **`data-part`**: content **`data-state`**: "open" | "closed" **`data-type`**: The type of the item **`data-placement`**: The placement of the content **`data-step`**: ### Control #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Description #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: tour **`data-part`**: description **`data-placement`**: The placement of the description ### Positioner #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: tour **`data-part`**: positioner **`data-type`**: The type of the item **`data-placement`**: The placement of the positioner ### ProgressText #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Spotlight #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### Title #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: tour **`data-part`**: title **`data-placement`**: The placement of the title # Tree View ## Anatomy To set up the tree view component correctly, you'll need to understand its anatomy and how we name its parts. > Each part includes a `data-part` attribute to help identify them in the DOM. ## Examples Learn how to use the `TreeView` component in your project. Let's take a look at the most basic example: ```vue ``` ### Using the Root Provider The `RootProvider` component provides a context for the tree-view. It accepts the value of the `useTree-view` hook. You can leverage it to access the component state and methods from outside the tree-view. ```vue Example not found``` > If you're using the `RootProvider` component, you don't need to use the `Root` component. ## API Reference ### Root #### Props **`collection`** Type: `TreeCollection` Required: true Default Value: `undefined` Description: The collection of tree nodes **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`defaultExpandedValue`** Type: `string[]` Required: false Default Value: `undefined` Description: The initial expanded node ids when rendered. Use when you don't need to control the expanded node ids. **`defaultSelectedValue`** Type: `string[]` Required: false Default Value: `undefined` Description: The initial selected node ids when rendered. Use when you don't need to control the selected node ids. **`expandedValue`** Type: `string[]` Required: false Default Value: `undefined` Description: The controlled expanded node ids **`expandOnClick`** Type: `boolean` Required: false Default Value: `true` Description: Whether clicking on a branch should open it or not **`focusedValue`** Type: `string` Required: false Default Value: `undefined` Description: The id of the focused node **`id`** Type: `string` Required: false Default Value: `undefined` Description: The unique identifier of the machine. **`ids`** Type: `Partial<{ root: string; tree: string; label: string; node(value: string): string }>` Required: false Default Value: `undefined` Description: The ids of the tree elements. Useful for composition. **`lazyMount`** Type: `boolean` Required: false Default Value: `false` Description: Whether to enable lazy mounting **`selectedValue`** Type: `string[]` Required: false Default Value: `undefined` Description: The controlled selected node ids **`selectionMode`** Type: `'multiple' | 'single'` Required: false Default Value: `"single"` Description: Whether the tree supports multiple selection - "single": only one node can be selected - "multiple": multiple nodes can be selected **`typeahead`** Type: `boolean` Required: false Default Value: `true` Description: Whether the tree supports typeahead search **`unmountOnExit`** Type: `boolean` Required: false Default Value: `false` Description: Whether to unmount on exit. ### BranchContent #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: tree-view **`data-part`**: branch-content **`data-state`**: "open" | "closed" **`data-depth`**: The depth of the item **`data-path`**: The path of the item **`data-value`**: The value of the item ### BranchControl #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: tree-view **`data-part`**: branch-control **`data-path`**: The path of the item **`data-state`**: "open" | "closed" **`data-disabled`**: Present when disabled **`data-selected`**: Present when selected **`data-focus`**: Present when focused **`data-value`**: The value of the item **`data-depth`**: The depth of the item ### BranchIndentGuide #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: tree-view **`data-part`**: branch-indent-guide **`data-depth`**: The depth of the item ### BranchIndicator #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: tree-view **`data-part`**: branch-indicator **`data-state`**: "open" | "closed" **`data-disabled`**: Present when disabled **`data-selected`**: Present when selected **`data-focus`**: Present when focused ### Branch #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: tree-view **`data-part`**: branch **`data-depth`**: The depth of the item **`data-branch`**: **`data-value`**: The value of the item **`data-path`**: The path of the item **`data-selected`**: Present when selected **`data-state`**: "open" | "closed" **`data-disabled`**: Present when disabled ### BranchText #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: tree-view **`data-part`**: branch-text **`data-disabled`**: Present when disabled **`data-state`**: "open" | "closed" ### BranchTrigger #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: tree-view **`data-part`**: branch-trigger **`data-disabled`**: Present when disabled **`data-state`**: "open" | "closed" **`data-value`**: The value of the item ### ItemIndicator #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: tree-view **`data-part`**: item-indicator **`data-disabled`**: Present when disabled **`data-selected`**: Present when selected **`data-focus`**: Present when focused ### Item #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: tree-view **`data-part`**: item **`data-path`**: The path of the item **`data-value`**: The value of the item **`data-focus`**: Present when focused **`data-selected`**: Present when selected **`data-disabled`**: Present when disabled **`data-depth`**: The depth of the item ### ItemText #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. #### Data Attributes **`data-scope`**: tree-view **`data-part`**: item-text **`data-disabled`**: Present when disabled **`data-selected`**: Present when selected **`data-focus`**: Present when focused ### Label #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ### NodeProvider #### Props **`indexPath`** Type: `number[]` Required: true Default Value: `undefined` Description: The index path of the tree node **`node`** Type: `NonNullable` Required: false Default Value: `undefined` Description: The tree node ### RootProvider #### Props **`value`** Type: `TreeViewApi` Required: true Default Value: `undefined` Description: undefined **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. **`lazyMount`** Type: `boolean` Required: false Default Value: `false` Description: Whether to enable lazy mounting **`unmountOnExit`** Type: `boolean` Required: false Default Value: `false` Description: Whether to unmount on exit. ### Tree #### Props **`asChild`** Type: `boolean` Required: false Default Value: `undefined` Description: Use the provided child element as the default rendered element, combining their props and behavior. ## Accessibility Complies with the [Tree View WAI-ARIA design pattern](https://www.w3.org/WAI/ARIA/apg/patterns/treeview/). ### Keyboard Support **`Tab`** Description: Moves focus to the tree view, placing the first tree view item in focus. **`Enter + Space`** Description: Selects the item or branch node **`ArrowDown`** Description: Moves focus to the next node **`ArrowUp`** Description: Moves focus to the previous node **`ArrowRight`** Description: When focus is on a closed branch node, opens the branch.
                When focus is on an open branch node, moves focus to the first item node. **`ArrowLeft`** Description: When focus is on an open branch node, closes the node.
                When focus is on an item or branch node, moves focus to its parent branch node. **`Home`** Description: Moves focus to first node without opening or closing a node. **`End`** Description: Moves focus to the last node that can be focused without expanding any nodes that are closed. **`a-z + A-Z`** Description: Focus moves to the next node with a name that starts with the typed character. The search logic ignores nodes that are descendants of closed branch. **`*`** Description: Expands all sibling nodes that are at the same depth as the focused node. **`Shift + ArrowDown`** Description: Moves focus to and toggles the selection state of the next node. **`Shift + ArrowUp`** Description: Moves focus to and toggles the selection state of the previous node. **`Ctrl + A`** Description: Selects all nodes in the tree. If all nodes are selected, unselects all nodes. # UTILITIES --- # Download Trigger ## Motivation The `DownloadTrigger` component provides a convenient way to programmatically trigger file downloads in web applications. It handles the complexities of downloading files, whether they are URLs, Blobs, or other data types. ## Examples ### Basic Pass the data you want to download to the `data` prop, and specify the `fileName` and `mimeType` of the file. ```vue ``` ### Download SVG Here's an example of how to download an SVG file. ```vue ``` ### Promise You can also trigger downloads from a promise that returns a `Blob`, `File`, or `string`. ```vue ``` ## API Reference # Environment ## Motivation We use [Zag.js](https://zagjs.com/overview/composition#custom-window-environment) internally, which relies on DOM query methods like `document.querySelectorAll` and `document.getElementById`. In custom environments like iframes, Shadow DOM, or Electron, these methods might not work as expected. To handle this, Ark UI includes the `EnvironmentProvider`, allowing you to set the appropriate root node or document, ensuring correct DOM queries. ## Setup To support custom environments like an iframe, Shadow DOM or Electron, render the `EnvironmentProvider` component to provide the environment context to all Ark UI components. ```vue ``` ### Usage in iframe The `EnvironmentProvider` component will automatically detect the current environment and set the correct environment context. However, you can also manually set the `Document` like shown in this React example below: ```jsx import Frame, { FrameContextConsumer } from 'react-frame-component' import { EnvironmentProvider } from '@ark-ui/react' export const App = () => ( {({ document }) => {/* Your App */}} ) ``` ### Usage in Shadow DOM Here's an example of how to set the `EnvironmentProvider`'s value with Shadow DOM in Solid.js `Portal` component. ```jsx import { EnvironmentProvider } from '@ark-ui/react' import { Index, Portal } from 'solid-js/web' export const App = () => { let portalNode return ( portalNode?.shadowRoot ?? document}>{/* Your App */} ) } ``` ## Context Use the `useEnvironmentContext` hook to access the `RootNode`, `Document`, and `Window`. ```vue ``` ## API Reference ### EnvironmentProvider #### Props **`value`** Type: `RootNode | (() => RootNode)` Required: false Default Value: `undefined` Description: undefined # Focus Trap ## Motivation Focus trapping is essential for modal interfaces and other interactive elements that require user attention. The `FocusTrap` component helps maintain accessibility by ensuring keyboard focus remains within a designated container until explicitly released. ## Examples ```vue