# 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.24.0] - 2025-09-11 ### Added - **Dismissable**: Add support for layer types in dismissable layer stack. Layers can now be categorized as `dialog`, `popover`, `menu`, or `listbox`. This enables: - `data-nested` attribute on nested layers of the same type - `data-has-nested` attribute on parent layers with nested children of the same type - `--nested-layer-count` CSS variable indicating the number of nested layers of the same type ### Fixed - **Menu**: Fix issue where hovering a partially visible item with pointer causes it to scroll into view - **Tabs**: Fix issue where `ids` for `item` and `content` could not be customized - **Toast**: Allow creating a toast store without any arguments ## [5.23.0] - 2025-09-08 ### Added - **Field**: Add `data-required` attribute to `Field.Label` - **Select, Combobox, Listbox, TreeView**: Export `RootComponent` and `RootProviderComponent` types which are useful when building compositions that wrap the `Root` and `RootProvider` components and you still want type-safety for the collection. ### Fixed - **Menu**: Fix `Menu.ItemText` not working inside `Menu.TriggerItem` ```tsx import { Select } from '@ark-ui/react/select' import { styled } from 'styling-lib' const Root = styled(Select.Root) as Select.RootComponent<{}> ``` ## [5.22.0] - 2025-08-28 ### Added - **Combobox**: Add `ComboboxEmpty` component to display content when the combobox has no items - **Listbox**: Add `ListboxEmpty` component to display content when the listbox has no items - **Hover Card**: Add support for `disabled` prop ### Fixed - **Collection**: Fix issue where disabled items could be reached via typeahead - **Color Picker**: Fix issue where color picker was not working correctly in RTL mode - **Date Picker**: Fix issue where datepicker doesn't revert to a valid value when the input value exceeds the min/max and blurred - **Dismissable**: Expose `onRequestDismiss` custom event handler for event a parent layer requests the child layer to dismiss. If prevented via `event.preventDefault()`, the child layer will not dismiss when the parent layer is dismissed. - **Number Input** - Omit the input `pattern` when `formatOptions` is provided. This prevents native pattern validation from conflicting with formatted values (e.g., currency or percent). - Handle empty values consistently across all format options. - Add `data-scrubbing` attribute to the number input parts. - **Tags Input**: Fix issue where highlighted item doesn't clear when tabbing out of the input to an external button within the `control` part. - **Tooltip** - Set `closeOnPointerdown` to `false` when `closeOnClick` is set to `false` - Reduce bundle size by replacing `@zag-js/store` dependency with a lightweight store implementation. ## [5.21.0] - 2025-08-24 ### Added - **Hooks**: Add `useAsyncList` and `useCollator` hooks for managing asynchronous list operations and locale-aware string comparison - **Toast**: Export type definitions `ToastActionOptions`, `ToastPlacement`, `ToastPromiseOptions`, `ToastStatus`, `ToastStatusChangeDetails`, and `ToastType` ### Changed - **Fieldset** - Update Legend component to render as `div` instead of `legend` element for improved styling flexibility - Add `aria-labelledby` attribute to fieldset root for better accessibility by linking to legend ### Fixed - **Date Picker** - Clear hovered range state after completing range selection instead of waiting for pointer to leave the calendar area. - Fix issue where month and year select labels don't update correctly when using `min`/`max` constraints. - Expose `disabled` on `api.getMonths()` and `api.getYears()` results to indicate options out of range for current constraints. - **Listbox** - Fix issue where first enabled item should be highlighted by default when listbox receives focus and no item is currently highlighted. - Add `getElement` to `scrollToIndexFn` details - Track collection changes and clear `highlightedValue` if the item is no longer in the collection. - **Scroll Area** - Avoid detecting hover state from portalled descendants. - Add `data-dragging` attribute to scroll area parts. - **Select**: Add `getElement` to `scrollToIndexFn` details - **Combobox**: Add `getElement` to `scrollToIndexFn` details - **Tabs**: Fix inconsistent keyboard navigation where TabPanel intermittently receives focus before focusable elements ## [5.20.0] - 2025-08-20 ### Added - **Highlight Word**: Add `exactMatch` option that enables whole-word matching using regex word boundaries. ### Fixed - **Menu**: Fix context menu repositioning logic - **ScrollArea**: Add `data-hover` to scroll area ## [5.19.0] - 2025-08-18 ### Added - **ScrollArea [NEW]**: Add support for new scroll area component. ### Fixed - **ListCollection** - Avoid recomputing groups on every call to `at()` and `indexOf()` - Fixed bug in `find()` method (was checking `!= null` instead of `!== -1`) - **GridCollection**: Avoid recomputing rows on every call to `getRows()` - **Menu** - Add `data-state` attribute for context menu trigger - Fix context menu positioning bug where reopening at the same coordinates fails to reposition ## [5.18.4] - 2025-08-14 ### Fixed - **Listbox**: Add support for navigating grid collections - **Carousel**: - Fix an issue where the carousel would not update when `slideCount` or `autoplay` props change. - Fix an issue where `loop: false` was ignored when using autoplay. Now, the carousel will stop when it gets to the last slide. - **Date Picker**: Expose `data-inline` attribute on Content part to enable distinct styling for inline date pickers versus popover date pickers. - **Menu**: Fix issue where `onCheckedChange` could be called twice on checkbox or radio item - **Radio Group**: Fixed issue where arrow key navigation doesn't apply `data-focus-visible` on the newly focused item. - **TagsInput**: Export `InputValueChangeDetails` type ### Changed - **Async List**: Improve type inference for descriptors ## [5.18.3] - 2025-08-01 ### Fixed - **Factory**: Check if `children` is a valid React element before calling `Children.only()` - **Carousel**: Fix issue where controlled carousel ignores last slide ## [5.18.2] - 2025-07-26 ### Fixed - **Dialog** - Sync content `--layer-index` with positioner and backdrop - Decouple `trapFocus` from `modal` so it's possible to set `modal=false` and `trapFocus=true` ## [5.18.1] - 2025-07-23 ### Fixed - **Date Picker**: Fixed issue where hovered range was connect to selected values, when it shouldn't - **Tree View**: Fixed issue where tree view doesn't scroll into view when content overflows. ## [5.18.0] - 2025-07-22 ### Added - **Collection**: Add `useListSelection` hook for managing collection item selection with support for single/multiple selection modes ```jsx const collection = createListCollection({ items: ['React', 'Vue', 'Angular'] }) const selection = useListSelection({ collection }) // Check if item is selected const isSelected = selection.isSelected('React') // Select/deselect items selection.select('React') selection.toggle('Vue') ``` - **File Upload**: Add support for programmatically controlling the accepted files via `acceptedFiles` and `defaultAcceptedFiles` - **Signature Pad**: Add support for programmatically controlling the paths via `paths` and `defaultPaths` props. - **Date Picker**: Added hover range preview support for date picker range selection. Added `inHoveredRange`, `firstInHoveredRange`, and `lastInHoveredRange` properties to `DayTableCellState` with corresponding data attributes `data-in-hover-range`, `data-hover-range-start`, and `data-hover-range-end`. Hover range states are only active when not overlapping with actual selected range, enabling distinct styling for hover preview vs actual selection in range mode. ### Fixed - **Date Picker**: Fix date comparison issues when time components are involved. This resolves critical issues with date comparison operations when different date types (`CalendarDate`, `CalendarDateTime`, `ZonedDateTime`) are mixed, particularly in scenarios involving time components. ## [5.17.0] - 2025-07-18 ### Added - **Checkbox**: Add `CheckboxGroupProvider` component for external checkbox group state management ### Fixed - **Carousel**: Fix issue where full page carousel could trap scrolling - **ListCollection**:Export `UseListCollectionReturn` type - **TreeCollection**: Fix issue where the `filter` method completely deletes the children key from the node when there are no matching children - **Number Input**: Fix issue where default pattern does not allow negative numbers with decimal point - **File Upload** - Export `FileError`, `FileMimeType`, and `FileRejection` types - Fix issue where calling `api.setFiles` invokes validation with incorrect `acceptedFiles` - Fix issue where the browser might not be able to infer the mime type of a file due to limitations, drag source or security restrictions. As a fallback in the file validation logic, we now infer the mime type from the file extension. ## [5.16.1] - 2025-07-05 ### Fixed - **Combobox** - Expose `reason` to `onOpenChange` and `onInputValueChange` callbacks - Expose `api.clearHighlightedValue` function to clear highlighted value - **Date Picker** - Fix issue where datepicker errors when setting `selectionMode=range` and `minView=year` - Fix issue where `focusedValue` could not be fully controlled - **Toast**: Fix issue where toast `title` or `description` could not accept React element - **Listbox**: Select highlighted item only if it exists in the collection - **Progress**: Improve `valueAsString` formatting - **Select** - Select highlighted item only if it exists in the collection - Expose `api.clearHighlightedValue` function to clear highlighted value - **Tour**: Fix an issue where the `goto` function in `StepActionMap` doesn't work when passing step IDs (string) - **Tree View**: Expose `id` in the tree node state - **ClientOnly**: Support `children` as a function ## [5.16.0] - 2025-07-01 ### Added - **Color Picker**: Add support for `inline` prop to render color picker inline - **Date Picker**: Add support for `inline` prop to render the date calendar inline ### Fixed - **Color Picker**: Auto-prefix Hex values with `#` if missing when using the `hex` channel input - **Menu**: Fix interaction outside detection for focusable context trigger - **Tree View**: Improve support for rendering tree items as links ## [5.15.4] - 2025-06-27 ### Fixed - **Combobox, Select, Listbox**: Fix issue where rehydrating `defaultValue` or `value` after fetching items doesn't update the `valueAsString` ## [5.15.3] - 2025-06-27 ### Fixed - **Tree View**: Fix tree traversal for querying last node ## [5.15.2] - 2025-06-26 ### Fixed - **Date Picker**: Fix issue with keyboard selection where setting unavailable date causes month view to behave differently from clicking with mouse - **Toast**: Fix issue where app crashes when `toaster.promise` is called without loading option. The `loading` option is now required. A warning will be logged if it is not provided - **Tree View** - Fix issue where clicking a branch with indeterminate state doesn't check its child nodes - Remove `aria-busy` attribute from branch trigger when not loading children - Expose node details in `onExpandChange`, `onSelectionChange` and `onFocusChange` - **Angle Slider**: Fix issue where scrubbing doesn't feel smooth on touch devices - **Timer**: - Fix issue where timer could continue beyond `targetMs` when window is not visible - Add validation to ensure `startMs` and `targetMs` are configured correctly - Fix `progressPercent` calculation for countdown timers ## [5.15.1] - 2025-06-23 ### Fixed - **Listbox**: Fix issue where `Listbox.ItemContext` was not exported ## [5.15.0] - 2025-06-23 ### Added - **Tree View** - Add support for checkbox state for checkbox trees via `defaultCheckedValue`, `checkedValue`, `onCheckedChange` props - Add callback for when `loadChildren` fails via `onLoadChildrenError` prop ### Fixed - **Progress** - Fix issue where setting orientation to `vertical` don't work - Fix issue where setting `defaultValue` to `null` doesn't show indeterminate state ## [5.14.2] - 2025-06-19 ### Fixed - **General**: Ensure pointerdown or click event handlers only execute when the main button is clicked - **Tree View**: Exported `TreeViewNodeState` and `TreeViewNodeProps` types from `@zag-js/tree-view` ### Changed - **Collection**: Improve the APIs around `tree.flatten(...)` and `flattenedToTree` to ensure the original node properties are preserved. > Previously, `tree.flatten()` would return an array of objects with `value` and `label` stripping out the original > node properties. ```ts const tree = new TreeCollection({ rootNode: { value: 'ROOT', children: [{ value: 'child1' }, { value: 'child2' }], }, }) const flattened = tree.flatten() const reconstructed = flattenedToTree(flattened) console.log(reconstructed.rootNode) // { // value: "ROOT", // children: [{ value: "child1" }, { value: "child2" }], // } ``` ## [5.14.1] - 2025-06-17 ### Fixed - **Popover**: Fixed issue where `onOpenChange` could be called twice when controlled - **File Utils**: Improved `downloadFile` function to handle webview scenarios - **Combobox**: - Fixed issue where `onInputValueChange` could be called twice when selecting an item - Fixed issue where combobox with `allowCustomValue: true` used within in a form requires two enter keypress to submit ## [5.14.0] - 2025-06-10 ### Added - **Editable**: Added support for `activationMode=none` - **Collection** - Exposed `copy` method - Added support for `getParentNodes` to accept a value or index path ### Fixed - **Collection**: Fixed issue where entrypoint `@ark-ui/react/collection` was not working as expected - **Carousel**: Fixed issue where carousel crashes when `slidesPerPage` is 0 - **File Upload**: Prevented `undefined` in `acceptedFiles` when no files accepted - **Select**: Fixed issue where highlighted item could be cleared when navigating up/down the list with keyboard - **Tabs**: Fixed issue where tabs with links should not trigger tab change upon cmd/middle click - **Menu**: Fixed issue where `Menu.ItemText` could not be used with `Menu.Item` ## [5.13.0] - 2025-06-07 ### Added - **Collection**: Added new `useListCollection` hook to create a dynamic list collection. ### Fixed - **Progress**: Exported `ProgressValueChangeDetails` and `ProgressValueTranslationDetails` types from `@zag-js/progress` ## [5.12.0] - 2025-06-05 ### Added - **Tree View**: Added support for lazy loading node children. To use this, you need to provide: - `loadChildren` is a function that is used to load the children of a node. - `onLoadChildrenComplete` is a callback that is called when the children of a node are loaded. Used to update the tree collection. - Add `childrenCount` to the node object to indicate the number of children. ### Fixed - **Slider** - Fixed issue where `Shift` + `ArrowRight` set value to `0` instead of `max` when step is too large (e.g. `20`) - Fixed issue where `onValueChangeEnd` doesn't return the latest value when dragging very fast ## [5.11.0] - 2025-05-30 ### Added - **File Upload**: Added support for transforming uploaded files via `transformFiles` context property. ### Fixed - **Slider**: Fixed issue where `minStepsBetweenThumbs` isn't computed correctly when interacting with pointer or keyboard. ## [5.10.0] - 2025-05-29 ### Added - **[NEW] Password Input**: Added `PasswordInput` component for creating password inputs ```tsx import { PasswordInput } from '@ark-ui/react/password-input' import { EyeIcon, EyeOffIcon } from 'lucide-react' export const Basic = () => ( Password }> ) ``` - **Select**: Added `onSelect` callback that gets fired when an item is selected via keyboard/mouse. ### Fixed - **Color Picker**: Fixed issue where value change end event is invoked when committing via an input. - **Toast**: Fixed issue where calling `toast.remove()` without an id shows a TypeScript error. - **Field**: Fixed issue where helper text and error text could not be detected in shadow DOM environments. ## [5.9.2] - 2025-05-24 ### Fixed - **Collection**: Export `CollectionOptions`, `TreeCollectionOptions`, `GridCollectionOptions` types. - **Carousel** - Fixed issue where focusing on carousel region and navigating with keyboard doesn't work as expected - Fixed issue when `allowMouseDrag` is set where carousel no longer snaps after mouse interaction - **Combobox**: Fixed issue where `onInputValueChange` doesn't get called when `autoFocus` is set to `true` - **Slider**: Fixed issue where slider could throw a error when rendered in an popover or dialog - **Tour**: Fixed issue where calling `api.start()` with a step id doesn't work as expected ## [5.9.1] - 2025-05-12 ### Fixed - **Combobox**: Fixed issue where `focusable` prop was not being applied to the trigger element. - **Collection**: Fixed issue where `getNextValue` and `getPreviousValue` doesn't work as expected when `groupBy` is used. ## [5.9.0] - 2025-05-05 ### Added - **Locale**: Added `useFilter` hook to filter data based on the current locale. - **Format**: Added `FormatRelativeTime` component for formatting relative time. ## [5.8.0] - 2025-05-01 ### Added - **Date Picker**: Added support for `outsideDaySelectable` prop to allow selecting days outside the current month (on the same visible date range) ### Fixed - **Collapsible**: Fixed issue in React.js <= v18.x where collapse animation might not work as expected ## [5.7.0] - 2025-04-25 ### Added - **[NEW] Listbox**: Introduced the `Listbox` component for selecting a single or multiple items from a list. See the [documentation](https://ark-ui.com/docs/components/listbox) for details. - Improved support for grouping collection items. Check the `Listbox`, `Select` or `Combobox` documentation for more details. ### Changed - Added `package.json` to `exports` for improved compatibility with tools like Vite. ## [5.6.0] - 2025-04-15 ### Added - **[NEW] AngleSlider**: Introduced the `AngleSlider` component for selecting an angle. See the [documentation](https://ark-ui.com/docs/components/angle-slider) for details. - **[NEW] FloatingPanel**: Introduced the `FloatingPanel` component for creating floating windows. See the [documentation](https://ark-ui.com/docs/components/floating-panel) for details. - **Toast**: Added toast queuing when the max limit is reached: - New toasts were queued instead of dropped - Queued toasts were shown when space became available - Queue cleared when all toasts were removed - **Combobox**: - Fallbacked to the trigger element as the positioning anchor - Added `data-empty` attribute to indicate an empty listbox or content ## [5.5.0] - 2025-04-05 ### Added - **Presence**: Added support for skipping the initial animation when the component is mounted. This can be used in all disclosure components (e.g., `Dialog`, `DatePicker`, `Menu` etc). ### Fixed - **Tabs**: Fixed issue where tabs indicator animation behaves inconsistently. - **Date Picker** - Fixed issue where datepicker throws error when navigating month view. - Fixed issue where range selection doesn't reset correctly when clicking the same start date. - **Disclosure Components** - Fixed issue where pointerdown outside doesn't work consistently on mobile devices. - Improved pointerdown outside click detection in shadow DOM environments. ## [5.4.0] - 2025-03-28 ### Added - **Slider** - Add support for `origin: end` to align the thumb to the end of the track. - Expose `thumbSize` as CSS variables in the root element. Can be useful for styling the slider. - **Menu** - Added `onSelect` event to the `Menu.Item` component. ### Fixed - Ensured each component's state machine starts before processing events. - **HoverCard, ColorPicker**: Added missing `tabIndex` for better dialog support. - **Menu**: Assigned unique IDs to menu items to improve accessibility and HTML validation. ## [5.3.1] - 2025-03-24 ### Fixed - Fixed an issue where a function was imported from a package that wasn't declared as a dependency. ## [5.3.0] - 2025-03-24 ### Added - **Collapsible**: Added an `Indicator` part to display whether the collapsible was open or closed. - **ColorPicker**: Added support for formatting the `ValueText` component. ```tsx // #ff0000 ``` ### Fixed - **Combobox**: Fixed an issue where `onOpenChange` was called with the same `open` value. - **DownloadTrigger**: Added the missing `use client` directive. - **Splitter**: Fixed an issue where `onResizeStart` and `onResizeEnd` callbacks weren't triggered during keyboard interactions. ## [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/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.24.0] - 2025-09-11 ### Added - **Dismissable**: Add support for layer types in dismissable layer stack. Layers can now be categorized as `dialog`, `popover`, `menu`, or `listbox`. This enables: - `data-nested` attribute on nested layers of the same type - `data-has-nested` attribute on parent layers with nested children of the same type - `--nested-layer-count` CSS variable indicating the number of nested layers of the same type ### Fixed - **Menu**: Fix issue where hovering a partially visible item with pointer causes it to scroll into view - **Tabs**: Fix issue where `ids` for `item` and `content` could not be customized - **Toast**: Allow creating a toast store without any arguments ## [5.23.0] - 2025-09-08 ### Added - **Field**: Add `data-required` attribute to `Field.Label` - **Select, Combobox, Listbox, TreeView**: Export `RootComponent` and `RootProviderComponent` types which are useful when building compositions that wrap the `Root` and `RootProvider` components and you still want type-safety for the collection. ```tsx import { Select } from '@ark-ui/solid/select' import { styled } from 'styling-lib' const Root = styled(Select.Root) as Select.RootComponent<{}> ``` ### Fixed - **Menu**: Fix `Menu.ItemText` not working inside `Menu.TriggerItem` ## [5.22.0] - 2025-08-28 ### Added - **Combobox**: Add `ComboboxEmpty` component to display content when the combobox has no items - **Listbox**: Add `ListboxEmpty` component to display content when the listbox has no items - **Hover Card**: Add support for `disabled` prop ### Fixed - **Collection**: Fix issue where disabled items could be reached via typeahead - **Color Picker**: Fix issue where color picker was not working correctly in RTL mode - **Date Picker**: Fix issue where datepicker doesn't revert to a valid value when the input value exceeds the min/max and blurred - **Dismissable**: Expose `onRequestDismiss` custom event handler for event a parent layer requests the child layer to dismiss. If prevented via `event.preventDefault()`, the child layer will not dismiss when the parent layer is dismissed. - **Number Input** - Omit the input `pattern` when `formatOptions` is provided. This prevents native pattern validation from conflicting with formatted values (e.g., currency or percent). - Handle empty values consistently across all format options. - Add `data-scrubbing` attribute to the number input parts. - **Tags Input**: Fix issue where highlighted item doesn't clear when tabbing out of the input to an external button within the `control` part. - **Tooltip** - Set `closeOnPointerdown` to `false` when `closeOnClick` is set to `false` - Reduce bundle size by replacing `@zag-js/store` dependency with a lightweight store implementation. ## [5.21.0] - 2025-08-24 ### Added - **Hooks**: Add `useAsyncList` and `useCollator` hooks for managing asynchronous list operations and locale-aware string comparison - **Toast**: Export type definitions `ToastActionOptions`, `ToastPlacement`, `ToastPromiseOptions`, `ToastStatus`, `ToastStatusChangeDetails`, and `ToastType` ### Changed - **Fieldset**: - Update Legend component to render as `div` instead of `legend` element for improved styling flexibility - Add `aria-labelledby` attribute to fieldset root for better accessibility by linking to legend ### Fixed - **Date Picker** - Clear hovered range state after completing range selection instead of waiting for pointer to leave the calendar area. - Fix issue where month and year select labels don't update correctly when using `min`/`max` constraints. - Expose `disabled` on `api.getMonths()` and `api.getYears()` results to indicate options out of range for current constraints. - **Listbox** - Fix issue where first enabled item should be highlighted by default when listbox receives focus and no item is currently highlighted. - Add `getElement` to `scrollToIndexFn` details - Track collection changes and clear `highlightedValue` if the item is no longer in the collection. - **ScrollArea** - Avoid detecting hover state from portalled descendants. - Add `data-dragging` attribute to scroll area parts. - **Select**: Add `getElement` to `scrollToIndexFn` details - **Combobox**: Add `getElement` to `scrollToIndexFn` details ## [5.20.0] - 2025-08-20 ### Added - **Highlight Word**: Add `exactMatch` option that enables whole-word matching using regex word boundaries. ### Fixed - **Menu**: Fix context menu repositioning logic - **Scroll Area**: Add `data-hover` to scroll area ## [5.19.0] - 2025-08-18 ### Added - **ScrollArea [NEW]**: Add support for new scroll area component. ### Fixed - **ListCollection** - Avoid recomputing groups on every call to `at()` and `indexOf()` - Fixed bug in `find()` method (was checking `!= null` instead of `!== -1`) - **GridCollection**: Avoid recomputing rows on every call to `getRows()` - **Menu** - Add `data-state` attribute for context menu trigger - Fix context menu positioning bug where reopening at the same coordinates fails to reposition - **ClientOnly**: Fixed issue where `ClientOnly` component was not exported correctly. ## [5.18.4] - 2025-08-14 ### Fixed - **Listbox**: Add support for navigating grid collections - **Carousel**: - Fix an issue where the carousel would not update when `slideCount` or `autoplay` props change. - Fix an issue where `loop: false` was ignored when using autoplay. Now, the carousel will stop when it gets to the last slide. - **Date Picker**: Expose `data-inline` attribute on Content part to enable distinct styling for inline date pickers versus popover date pickers. - **Menu**: Fix issue where `onCheckedChange` could be called twice on checkbox or radio item - **Radio Group**: Fixed issue where arrow key navigation doesn't apply `data-focus-visible` on the newly focused item. - **TagsInput**: Export `InputValueChangeDetails` type ### Changed - **Async List**: Improve type inference for descriptors - **Framework Components**: Improve runtime performance of components ## [5.18.3] - 2025-08-01 ### Fixed - **General**: Fix issue where presence closing animation doesn't work as expected - **Carousel**: Fix issue where controlled carousel ignores last slide ## [5.18.2] - 2025-07-26 ### Fixed - **Dialog** - Sync content `--layer-index` with positioner and backdrop - Decouple `trapFocus` from `modal` so it's possible to set `modal=false` and `trapFocus=true` ## [5.18.1] - 2025-07-23 ### Fixed - **Date Picker**: Fixed issue where hovered range was connect to selected values, when it shouldn't - **Tree View**: Fixed issue where tree view doesn't scroll into view when content overflows. ## [5.18.0] - 2025-07-22 ### Added - **Collection**: Add `useListSelection` hook for managing collection item selection with support for single/multiple selection modes ```jsx const collection = createListCollection({ items: ['React', 'Vue', 'Angular'] }) const selection = useListSelection({ collection }) // Check if item is selected const isSelected = selection.isSelected('React') // Select/deselect items selection.select('React') selection.toggle('Vue') ``` - **File Upload**: Add support for programmatically controlling the accepted files via `acceptedFiles` and `defaultAcceptedFiles` - **Signature Pad**: Add support for programmatically controlling the paths via `paths` and `defaultPaths` props. - **Date Picker**: Added hover range preview support for date picker range selection. Added `inHoveredRange`, `firstInHoveredRange`, and `lastInHoveredRange` properties to `DayTableCellState` with corresponding data attributes `data-in-hover-range`, `data-hover-range-start`, and `data-hover-range-end`. Hover range states are only active when not overlapping with actual selected range, enabling distinct styling for hover preview vs actual selection in range mode. ### Fixed - **Date Picker**: Fix date comparison issues when time components are involved. This resolves critical issues with date comparison operations when different date types (`CalendarDate`, `CalendarDateTime`, `ZonedDateTime`) are mixed, particularly in scenarios involving time components. ## [5.17.0] - 2025-07-18 ### Added - **Checkbox**: Add `CheckboxGroupProvider` component for external checkbox group state management ### Fixed - **Carousel**: Fix issue where full page carousel could trap scrolling - **ListCollection**: Export `UseListCollectionReturn` type - **TreeCollection**: Fix issue where the `filter` method completely deletes the children key from the node when there are no matching children - **Number Input**: Fix issue where default pattern does not allow negative numbers with decimal point - **File Upload** - Export `FileError`, `FileMimeType`, and `FileRejection` types - Fix issue where calling `api.setFiles` invokes validation with incorrect `acceptedFiles` - Fix issue where the browser might not be able to infer the mime type of a file due to limitations, drag source or security restrictions. As a fallback in the file validation logic, we now infer the mime type from the file extension. ## [5.16.1] - 2025-07-05 ### Fixed - **Combobox** - Expose `reason` to `onOpenChange` and `onInputValueChange` callbacks - Expose `api.clearHighlightedValue` function to clear highlighted value - **Date Picker** - Fix issue where datepicker errors when setting `selectionMode=range` and `minView=year` - Fix issue where `focusedValue` could not be fully controlled - **Listbox**: Select highlighted item only if it exists in the collection - **Progress**: Improve `valueAsString` formatting - **Select** - Select highlighted item only if it exists in the collection - Expose `api.clearHighlightedValue` function to clear highlighted value - **Tour**: Fix an issue where the `goto` function in `StepActionMap` doesn't work when passing step IDs (string) - **Tree View**: Expose `id` in the tree node state ## [5.16.0] - 2025-07-01 ### Added - **Color Picker**: Add support for `inline` prop to render color picker inline - **Date Picker**: Add support for `inline` prop to render the date calendar inline ### Fixed - **Color Picker**: Auto-prefix Hex values with `#` if missing when using the `hex` channel input - **Menu**: Fix interaction outside detection for focusable context trigger - **Tree View**: Improve support for rendering tree items as links ## [5.15.4] - 2025-06-27 ### Fixed - **Combobox, Select, Listbox**: Fix issue where rehydrating `defaultValue` or `value` after fetching items doesn't update the `valueAsString` ## [5.15.3] - 2025-06-27 ### Fixed - **Tree View**: Fix tree traversal for querying last node ## [5.15.2] - 2025-06-26 ### Fixed - **Date Picker**: Fix issue with keyboard selection where setting unavailable date causes month view to behave differently from clicking with mouse - **Toast**: Fix issue where app crashes when `toaster.promise` is called without loading option. The `loading` option is now required. A warning will be logged if it is not provided - **Tree View** - Fix issue where clicking a branch with indeterminate state doesn't check its child nodes - Remove `aria-busy` attribute from branch trigger when not loading children - Expose node details in `onExpandChange`, `onSelectionChange` and `onFocusChange` - **Angle Slider**: Fix issue where scrubbing doesn't feel smooth on touch devices - **Timer** - Fix issue where timer could continue beyond `targetMs` when window is not visible - Add validation to ensure `startMs` and `targetMs` are configured correctly - Fix `progressPercent` calculation for countdown timers ## [5.15.1] - 2025-06-23 ### Fixed - **Listbox**: Fix issue where `Listbox.ItemContext` was not exported ## [5.15.0] - 2025-06-23 ### Added - **Tree View** - Add support for checkbox state for checkbox trees via `defaultCheckedValue`, `checkedValue`, `onCheckedChange` props - Add callback for when `loadChildren` fails via `onLoadChildrenError` prop ### Fixed - **Progress** - Fix issue where setting orientation to `vertical` don't work - Fix issue where setting `defaultValue` to `null` doesn't show indeterminate state ## [5.14.2] - 2025-06-19 ### Fixed - **General**: Ensure pointerdown or click event handlers only execute when the main button is clicked - **Tree View**: Exported `TreeViewNodeState` and `TreeViewNodeProps` types from `@zag-js/tree-view` ### Changed - **Collection**: Improve the APIs around `tree.flatten(...)` and `flattenedToTree` to ensure the original node properties are preserved. > Previously, `tree.flatten()` would return an array of objects with `value` and `label` stripping out the original > node properties. ```ts const tree = new TreeCollection({ rootNode: { value: 'ROOT', children: [{ value: 'child1' }, { value: 'child2' }], }, }) const flattened = tree.flatten() const reconstructed = flattenedToTree(flattened) console.log(reconstructed.rootNode) // { // value: "ROOT", // children: [{ value: "child1" }, { value: "child2" }], // } ``` ## [5.14.1] - 2025-06-17 ### Fixed - **Popover**: Fixed issue where `onOpenChange` could be called twice when controlled - **File Utils**: Improved `downloadFile` function to handle webview scenarios - **Combobox**: - Fixed issue where `onInputValueChange` could be called twice when selecting an item - Fixed issue where combobox with `allowCustomValue: true` used within in a form requires two enter keypress to submit ## [5.14.0] - 2025-06-10 ### Added - **Editable**: Added support for `activationMode=none` - **Collection** - Exposed `copy` method - Added support for `getParentNodes` to accept a value or index path ### Fixed - **Collection**: Fixed issue where entrypoint `@ark-ui/solid/collection` was not working as expected - **Carousel**: Fixed issue where carousel crashes when `slidesPerPage` is 0 - **File Upload**: Prevented `undefined` in `acceptedFiles` when no files accepted - **Select**: Fixed issue where highlighted item could be cleared when navigating up/down the list with keyboard - **Tabs**: Fixed issue where tabs with links should not trigger tab change upon cmd/middle click - **Menu**: Fixed issue where `Menu.ItemText` could not be used with `Menu.Item` ## [5.13.0] - 2025-06-07 ### Added - **Collection**: Add new `useListCollection` hook to create a dynamic list collection. ### Fixed - **Progress**: Export `ProgressValueChangeDetails` and `ProgressValueTranslationDetails` types from `@zag-js/progress` ## [5.12.0] - 2025-06-05 ### Added - **Tree View**: Add support for lazy loading node children. To use this, you need to provide: - `loadChildren` is a function that is used to load the children of a node. - `onLoadChildrenComplete` is a callback that is called when the children of a node are loaded. Used to update the tree collection. - Add `childrenCount` to the node object to indicate the number of children. ### Fixed - **Slider** - Fixed issue where `Shift` + `ArrowRight` set value to `0` instead of `max` when step is too large (e.g. `20`) - Fixed issue where `onValueChangeEnd` doesn't return the latest value when dragging very fast ## [5.11.0] - 2025-05-30 ### Added - **File Upload**: Added support for transforming uploaded files via `transformFiles` context property. ### Fixed - **Slider**: Fixed issue where `minStepsBetweenThumbs` isn't computed correctly when interacting with pointer or keyboard. ## [5.10.0] - 2025-05-29 ### Added - **[NEW] Password Input**: Added `PasswordInput` component for collecting secure text inputs. ```tsx import { PasswordInput } from '@ark-ui/solid/password-input' import { EyeIcon, EyeOffIcon } from 'lucide-solid' export const Basic = () => ( Password }> ) ``` - **Select**: Added `onSelect` callback that gets fired when an item is selected via keyboard/mouse. ### Fixed - **Color Picker**: Fixed issue where value change end event is invoked when committing via an input. - **Toast**: Fixed issue where calling `toast.remove()` without an id shows a TypeScript error. - **Field**: Fixed issue where helper text and error text could not be detected in shadow DOM environments. ## [5.9.2] - 2025-05-24 ### Fixed - **Collection**: Export `CollectionOptions`, `TreeCollectionOptions`, `GridCollectionOptions` types. - **Carousel** - Fix issue where focusing on carousel region and navigating with keyboard doesn't work as expected - Fix issue when `allowMouseDrag` is set where carousel no longer snaps after mouse interaction - **Combobox**: Fix issue where `onInputValueChange` doesn't get called when `autoFocus` is set to `true` - **Slider**: Fix issue where slider could throw a error when rendered in an popover or dialog - **Tour**: Fix issue where calling `api.start()` with a step id doesn't work as expected ## [5.9.1] - 2025-05-12 ### Fixed - **Collection**: Fix issue where `getNextValue` and `getPreviousValue` doesn't work as expected when `groupBy` is used. ## [5.9.0] - 2025-05-05 ### Added - **Locale**: Added `useFilter` hook to filter data based on the current locale. - **Format**: Added `FormatRelativeTime` component for formatting relative time. ## [5.8.0] - 2025-05-01 ### Added - **Date Picker**: Added support for `outsideDaySelectable` prop to allow selecting days outside the current month (on the same visible date range) ## [5.7.0] - 2025-04-25 ### Added - **[NEW] Listbox**: Introduced the `Listbox` component for selecting a single or multiple items from a list. See the [documentation](https://ark-ui.com/docs/components/listbox) for details. - Improved support for grouping collection items. Check the `Listbox`, `Select` or `Combobox` documentation for more details. ### Changed - Added `package.json` to `exports` for improved compatibility with tools like Vite. ## [5.6.0] - 2025-04-15 ### Added - **[NEW] AngleSlider**: Introduced the `AngleSlider` component for selecting an angle. See the [documentation](https://ark-ui.com/docs/components/angle-slider) for details. - **[NEW] FloatingPanel**: Introduced the `FloatingPanel` component for creating floating windows. See the [documentation](https://ark-ui.com/docs/components/floating-panel) for details. - **Toast**: Added toast queuing when the max limit is reached: - New toasts were queued instead of dropped - Queued toasts were shown when space became available - Queue cleared when all toasts were removed - **Combobox**: - Fallbacked to the trigger element as the positioning anchor - Added `data-empty` attribute to indicate an empty listbox or content ## [5.5.0] - 2025-04-05 ### Added - **Presence**: Added support for skipping the initial animation when the component is mounted. This can be used in all disclosure components (e.g., `Dialog`, `DatePicker`, `Menu` etc). ### Fixed - **Tabs**: Fixed issue where tabs indicator animation behaves inconsistently. - **Date Picker** - Fixed issue where datepicker throws error when navigating month view. - Fixed issue where range selection doesn't reset correctly when clicking the same start date. - **Disclosure Components** - Fixed issue where pointerdown outside doesn't work consistently on mobile devices. - Improved pointerdown outside click detection in shadow DOM environments. ## [5.4.0] - 2025-03-28 ### Added - **Slider** - Add support for `origin: end` to align the thumb to the end of the track. - Expose `thumbSize` as CSS variables in the root element. Can be useful for styling the slider. - **Menu** - Added `onSelect` event to the `Menu.Item` component. ### Fixed - Ensured each component's state machine starts before processing events. - **HoverCard, ColorPicker**: Added missing `tabIndex` for better dialog support. - **Menu**: Assigned unique IDs to menu items to improve accessibility and HTML validation. - **DatePicker**: Improved reactivity of the `columns` prop in `DatePicker.Table`. - **Field**: Improved reactivity of the `value` prop in `Field.Textarea`. - **Toggle**: Improved reactivity of the `children` and `fallback` props in `Toggle.Indicator`. ## [5.3.1] - 2025-03-24 ### Fixed - Fixed an issue where a function was imported from a package that wasn't declared as a dependency. ## [5.3.0] - 2025-03-24 ### Added - **Collapsible**: Added an `Indicator` part to display whether the collapsible was open or closed. - **ColorPicker**: Added support for formatting the `ValueText` component. ```tsx // #ff0000 ``` ### Fixed - **Combobox**: Fixed an issue where `onOpenChange` was called with the same `open` value. - **Splitter**: Fixed an issue where `onResizeStart` and `onResizeEnd` callbacks weren't triggered during keyboard interactions. ## [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/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] ## [5.9.0] - 2025-09-11 ### Added - **Dismissable**: Add support for layer types in dismissable layer stack. Layers can now be categorized as `dialog`, `popover`, `menu`, or `listbox`. This enables: - `data-nested` attribute on nested layers of the same type - `data-has-nested` attribute on parent layers with nested children of the same type - `--nested-layer-count` CSS variable indicating the number of nested layers of the same type ### Fixed - **Menu**: Fix issue where hovering a partially visible item with pointer causes it to scroll into view - **Tabs**: Fix issue where `ids` for `item` and `content` could not be customized - **Toast**: Allow creating a toast store without any arguments ## [5.8.0] - 2025-09-08 ### Added - **Field**: Add `data-required` attribute to `Field.Label` - **Select, Combobox, Listbox, TreeView**: Export `RootComponent` and `RootProviderComponent` types which are useful when building compositions that wrap the `Root` and `RootProvider` components and you still want type-safety for the collection. ### Fixed - **Menu**: Fix `Menu.ItemText` not working inside `Menu.TriggerItem` ## [5.7.0] - 2025-08-28 ### Added - **Combobox**: Add `ComboboxEmpty` component to display content when the combobox has no items - **Listbox**: Add `ListboxEmpty` component to display content when the listbox has no items - **Hover Card**: Add support for `disabled` prop ### Fixed - **Collection**: Fix issue where disabled items could be reached via typeahead - **Color Picker**: Fix issue where color picker was not working correctly in RTL mode - **Date Picker**: Fix issue where datepicker doesn't revert to a valid value when the input value exceeds the min/max and blurred - **Dismissable**: Expose `onRequestDismiss` custom event handler for event a parent layer requests the child layer to dismiss. If prevented via `event.preventDefault()`, the child layer will not dismiss when the parent layer is dismissed. - **Number Input** - Omit the input `pattern` when `formatOptions` is provided. This prevents native pattern validation from conflicting with formatted values (e.g., currency or percent). - Handle empty values consistently across all format options. - Add `data-scrubbing` attribute to the number input parts. - **Tags Input**: Fix issue where highlighted item doesn't clear when tabbing out of the input to an external button within the `control` part. - **Tooltip** - Set `closeOnPointerdown` to `false` when `closeOnClick` is set to `false` - Reduce bundle size by replacing `@zag-js/store` dependency with a lightweight store implementation. ## [5.6.0] - 2025-08-24 ### Added - **Functions**: Add `useAsyncList` and `useCollator` functions for managing asynchronous list operations and locale-aware string comparison - **Toast**: Export type definitions `ToastActionOptions`, `ToastPlacement`, `ToastPromiseOptions`, `ToastStatus`, `ToastStatusChangeDetails`, and `ToastType` ### Changed - **Fieldset** - Update Legend component to render as `div` instead of `legend` element for improved styling flexibility - Add `aria-labelledby` attribute to fieldset root for better accessibility by linking to legend ### Fixed - **Date Picker** - Clear hovered range state after completing range selection instead of waiting for pointer to leave the calendar area. - Fix issue where month and year select labels don't update correctly when using `min`/`max` constraints. - Expose `disabled` on `api.getMonths()` and `api.getYears()` results to indicate options out of range for current constraints. - **Listbox** - Fix issue where first enabled item should be highlighted by default when listbox receives focus and no item is currently highlighted. - Add `getElement` to `scrollToIndexFn` details - Track collection changes and clear `highlightedValue` if the item is no longer in the collection. - **ScrollArea** - Avoid detecting hover state from portalled descendants. - Add `data-dragging` attribute to scroll area parts. - **Select**: Add `getElement` to `scrollToIndexFn` details - **Combobox**: Add `getElement` to `scrollToIndexFn` details ## [5.5.0] - 2025-08-20 ### Added - **Highlight Word**: Add `exactMatch` option that enables whole-word matching using regex word boundaries. ### Fixed - **Menu**: Fix context menu repositioning logic - **Scroll Area**: Add `data-hover` to scroll area ## [5.4.0] - 2025-08-18 ### Added - **ScrollArea [NEW]**: Add support for new scroll area component. ### Fixed - **ListCollection** - Avoid recomputing groups on every call to `at()` and `indexOf()` - Fixed bug in `find()` method (was checking `!= null` instead of `!== -1`) - **GridCollection**: Avoid recomputing rows on every call to `getRows()` - **Menu** - Add `data-state` attribute for context menu trigger - Fix context menu positioning bug where reopening at the same coordinates fails to reposition ## [5.3.4] - 2025-08-14 ### Fixed - **Listbox**: Add support for navigating grid collections - **Carousel**: - Fix an issue where the carousel would not update when `slideCount` or `autoplay` props change. - Fix an issue where `loop: false` was ignored when using autoplay. Now, the carousel will stop when it gets to the last slide. - **Date Picker**: Expose `data-inline` attribute on Content part to enable distinct styling for inline date pickers versus popover date pickers. - **Menu**: Fix issue where `onCheckedChange` could be called twice on checkbox or radio item - **Radio Group**: Fixed issue where arrow key navigation doesn't apply `data-focus-visible` on the newly focused item. - **TagsInput**: Export `InputValueChangeDetails` type ### Changed - **Async List**: Improve type inference for descriptors - **Framework Components**: Improve runtime performance of components ## [5.3.3] - 2025-08-01 ### Fixed - **Carousel**: Fix issue where controlled carousel ignores last slide ## [5.3.2] - 2025-07-26 ### Fixed - **Dialog** - Sync content `--layer-index` with positioner and backdrop - Decouple `trapFocus` from `modal` so it's possible to set `modal=false` and `trapFocus=true` ## [5.3.1] - 2025-07-23 ### Fixed - **Date Picker**: Fixed issue where hovered range was connect to selected values, when it shouldn't - **Tree View**: Fixed issue where tree view doesn't scroll into view when content overflows. - **Portal**: Fix issue in SvelteKit where `Portal` component doesn't work as expected. ## [5.3.0] - 2025-07-22 ### Added - **Collection**: Add `useListSelection` function for managing collection item selection with support for single/multiple selection modes ```js const collection = createListCollection({ items: ['React', 'Vue', 'Angular'] }) const selection = useListSelection({ collection }) // Check if item is selected const isSelected = selection.isSelected('Svelte') // Select/deselect items selection.select('Svelte') selection.toggle('Angular') ``` - **File Upload**: Add support for `bind:acceptedFiles` and `defaultAcceptedFiles` to programmatically control the accepted files - **Signature Pad**: Add support for `bind:paths` and `defaultPaths` to programmatically control the paths - **Date Picker**: Added hover range preview support for date picker range selection. Added `inHoveredRange`, `firstInHoveredRange`, and `lastInHoveredRange` properties to `DayTableCellState` with corresponding data attributes `data-in-hover-range`, `data-hover-range-start`, and `data-hover-range-end`. Hover range states are only active when not overlapping with actual selected range, enabling distinct styling for hover preview vs actual selection in range mode. ### Fixed - **Date Picker**: Fix date comparison issues when time components are involved. This resolves critical issues with date comparison operations when different date types (`CalendarDate`, `CalendarDateTime`, `ZonedDateTime`) are mixed, particularly in scenarios involving time components. ## [5.2.0] - 2025-07-18 ### Added - **Checkbox**: Add `CheckboxGroupProvider` component for external checkbox group state management ### Fixed - **Carousel**: Fix issue where full page carousel could trap scrolling - **ListCollection**: Export `UseListCollectionReturn` type - **TreeCollection**: Fix issue where the `filter` method completely deletes the children key from the node when there are no matching children - **Number Input**: Fix issue where default pattern does not allow negative numbers with decimal point - **File Upload** - Export `FileError`, `FileMimeType`, and `FileRejection` types - Fix issue where calling `api.setFiles` invokes validation with incorrect `acceptedFiles` - Fix issue where the browser might not be able to infer the mime type of a file due to limitations, drag source or security restrictions. As a fallback in the file validation logic, we now infer the mime type from the file extension. - **Portal**: Fix issue where `lifecycle_double_unmount` warning could be triggered. ## [5.1.1] - 2025-07-05 ### Fixed - **Combobox** - Expose `reason` to `onOpenChange` and `onInputValueChange` callbacks - Expose `api.clearHighlightedValue` function to clear highlighted value - **Date Picker** - Fix issue where datepicker errors when setting `selectionMode=range` and `minView=year` - Fix issue where `focusedValue` could not be fully controlled - **Listbox**: Select highlighted item only if it exists in the collection - **Progress**: Improve `valueAsString` formatting - **Select** - Select highlighted item only if it exists in the collection - Expose `api.clearHighlightedValue` function to clear highlighted value - **Tour**: Fix an issue where the `goto` function in `StepActionMap` doesn't work when passing step IDs (string) - **Tree View**: Expose `id` in the tree node state ## [5.1.0] - 2025-07-01 ### Added - **Angle Slider [New]**: Add support for angle slider component for angle selection. - **Color Picker**: Add support for `inline` prop to render color picker inline - **Date Picker**: Add support for `inline` prop to render the date calendar inline ### Fixed - **Color Picker**: Auto-prefix Hex values with `#` if missing when using the `hex` channel input - **Menu**: Fix interaction outside detection for focusable context trigger - **Tree View**: Improve support for rendering tree items as links ## [5.0.5] - 2025-06-28 ### Fixed - Fix issue where `bind:ref` doesn't work with components, making it impossible to access the underlying DOM element. Now, you can pass `bind:ref` to all components. ```svelte Item 1 Content 1 ``` - Improve prop reactivity across all components. ## [5.0.4] - 2025-06-27 ### Fixed - **Combobox, Select, Listbox**: Fix issue where rehydrating `defaultValue` or `value` after fetching items doesn't update the `valueAsString` ## [5.0.3] - 2025-06-27 ### Fixed - **Tree View**: Fix tree traversal for querying last node ## [5.0.2] - 2025-06-26 ### Fixed - **Date Picker**: Fix issue with keyboard selection where setting unavailable date causes month view to behave differently from clicking with mouse - **Toast**: Fix issue where app crashes when `toaster.promise` is called without loading option. The `loading` option is now required. A warning will be logged if it is not provided - **Tree View** - Fix issue where clicking a branch with indeterminate state doesn't check its child nodes - Remove `aria-busy` attribute from branch trigger when not loading children - Expose node details in `onExpandChange`, `onSelectionChange` and `onFocusChange` - **Angle Slider**: Fix issue where scrubbing doesn't feel smooth on touch devices - **Timer** - Fix issue where timer could continue beyond `targetMs` when window is not visible - Add validation to ensure `startMs` and `targetMs` are configured correctly - Fix `progressPercent` calculation for countdown timers ## [5.0.1] - 2025-06-23 ### Fixed - **Accordion**: Fix issue where `Accordion.ItemContext` doesn't work - **Listbox**: Fix issue where `Listbox.ItemContext` was not exported ## [5.0.0] - 2025-06-23 ### Added - **Tree View** - Add support for checkbox state for checkbox trees via `defaultCheckedValue`, `checkedValue`, `onCheckedChange` props - Add callback for when `loadChildren` fails via `onLoadChildrenError` prop ### Fixed - **Progress** - Fix issue where setting orientation to `vertical` don't work - Fix issue where setting `defaultValue` to `null` doesn't show indeterminate state ## [5.0.0-0] - 2025-06-19 ### Added - Added all components to match React and Vue packages. ## [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.24.0] - 2025-09-11 ### Added - **Dismissable**: Add support for layer types in dismissable layer stack. Layers can now be categorized as `dialog`, `popover`, `menu`, or `listbox`. This enables: - `data-nested` attribute on nested layers of the same type - `data-has-nested` attribute on parent layers with nested children of the same type - `--nested-layer-count` CSS variable indicating the number of nested layers of the same type ### Fixed - **Menu**: Fix issue where hovering a partially visible item with pointer causes it to scroll into view - **Tabs**: Fix issue where `ids` for `item` and `content` could not be customized - **Toast**: Allow creating a toast store without any arguments ## [5.23.0] - 2025-09-08 ### Added - **Field**: Add `data-required` attribute to `Field.Label` - **Select, Combobox, Listbox, TreeView**: Export `RootComponent` and `RootProviderComponent` types which are useful when building compositions that wrap the `Root` and `RootProvider` components and you still want type-safety for the collection. ### Fixed - **Menu**: Fix `Menu.ItemText` not working inside `Menu.TriggerItem` ## [5.22.0] - 2025-08-28 ### Added - **Combobox**: Add `ComboboxEmpty` component to display content when the combobox has no items - **Listbox**: Add `ListboxEmpty` component to display content when the listbox has no items - **Hover Card**: Add support for `disabled` prop ### Fixed - **Collection**: Fix issue where disabled items could be reached via typeahead - **Color Picker**: Fix issue where color picker was not working correctly in RTL mode - **Date Picker**: Fix issue where datepicker doesn't revert to a valid value when the input value exceeds the min/max and blurred - **Dismissable**: Expose `onRequestDismiss` custom event handler for event a parent layer requests the child layer to dismiss. If prevented via `event.preventDefault()`, the child layer will not dismiss when the parent layer is dismissed. - **Number Input** - Omit the input `pattern` when `formatOptions` is provided. This prevents native pattern validation from conflicting with formatted values (e.g., currency or percent). - Handle empty values consistently across all format options. - Add `data-scrubbing` attribute to the number input parts. - **Tags Input**: Fix issue where highlighted item doesn't clear when tabbing out of the input to an external button within the `control` part. - **Tooltip** - Set `closeOnPointerdown` to `false` when `closeOnClick` is set to `false` - Reduce bundle size by replacing `@zag-js/store` dependency with a lightweight store implementation. ## [5.21.0] - 2025-08-24 ### Added - **Composables**: Add `useAsyncList` and `useCollator` composables for managing asynchronous list operations and locale-aware string comparison - **Toast**: Export type definitions `ToastActionOptions`, `ToastPlacement`, `ToastPromiseOptions`, `ToastStatus`, `ToastStatusChangeDetails`, and `ToastType` ### Changed - **Fieldset** - Update Legend component to render as `div` instead of `legend` element for improved styling flexibility - Add `aria-labelledby` attribute to fieldset root for better accessibility by linking to legend ### Fixed - **Date Picker** - Clear hovered range state after completing range selection instead of waiting for pointer to leave the calendar area. - Fix issue where month and year select labels don't update correctly when using `min`/`max` constraints. - Expose `disabled` on `api.getMonths()` and `api.getYears()` results to indicate options out of range for current constraints. - **Listbox** - Fix issue where first enabled item should be highlighted by default when listbox receives focus and no item is currently highlighted. - Add `getElement` to `scrollToIndexFn` details - Track collection changes and clear `highlightedValue` if the item is no longer in the collection. - **ScrollArea** - Avoid detecting hover state from portalled descendants. - Add `data-dragging` attribute to scroll area parts. - **Select**: Add `getElement` to `scrollToIndexFn` details - **Combobox**: Add `getElement` to `scrollToIndexFn` details ## [5.20.0] - 2025-08-20 ### Added - **Highlight Word**: Add `exactMatch` option that enables whole-word matching using regex word boundaries. ### Fixed - **Menu**: Fix context menu repositioning logic - **Scroll Area**: Add `data-hover` to scroll area ## [5.19.0] - 2025-08-18 ### Added - **ScrollArea [NEW]**: Add support for new scroll area component. ### Fixed - **ListCollection** - Avoid recomputing groups on every call to `at()` and `indexOf()` - Fixed bug in `find()` method (was checking `!= null` instead of `!== -1`) - **GridCollection**: Avoid recomputing rows on every call to `getRows()` - **Menu** - Add `data-state` attribute for context menu trigger - Fix context menu positioning bug where reopening at the same coordinates fails to reposition ## [5.18.4] - 2025-08-14 ### Fixed - **Listbox**: Add support for navigating grid collections - **Carousel**: - Fix an issue where the carousel would not update when `slideCount` or `autoplay` props change. - Fix an issue where `loop: false` was ignored when using autoplay. Now, the carousel will stop when it gets to the last slide. - **Date Picker**: Expose `data-inline` attribute on Content part to enable distinct styling for inline date pickers versus popover date pickers. - **Menu**: Fix issue where `onCheckedChange` could be called twice on checkbox or radio item - **Radio Group**: Fixed issue where arrow key navigation doesn't apply `data-focus-visible` on the newly focused item. - **TagsInput**: Export `InputValueChangeDetails` type - **Field**: Fix issue where `asChild` prop is not being applied to the input and select components, leading to hydration mismatch. ### Changed - **Async List**: Improve type inference for descriptors - **Framework Components**: Improve runtime performance of components ## [5.18.3] - 2025-08-01 ### Fixed - **Carousel**: Fix issue where controlled carousel ignores last slide ## [5.18.2] - 2025-07-26 ### Fixed - **Dialog** - Sync content `--layer-index` with positioner and backdrop - Decouple `trapFocus` from `modal` so it's possible to set `modal=false` and `trapFocus=true` ## [5.18.1] - 2025-07-23 ### Fixed - **Menu**: Fixed hydration issue when rendering `Menu.Separator` - **Date Picker**: Fixed issue where hovered range was connect to selected values, when it shouldn't - **Tree View**: Fixed issue where tree view doesn't scroll into view when content overflows. ## [5.18.0] - 2025-07-22 ### Added - **Collection**: Add `useListSelection` composable for managing collection item selection with support for single/multiple selection modes ```vue ``` - **File Upload**: Add support for `v-model:acceptedFiles` and `defaultAcceptedFiles` to programmatically control the accepted files - **Signature Pad**: Add support for `v-model:paths` and `defaultPaths` to programmatically control the paths - **Date Picker**: Added hover range preview support for date picker range selection. Added `inHoveredRange`, `firstInHoveredRange`, and `lastInHoveredRange` properties to `DayTableCellState` with corresponding data attributes `data-in-hover-range`, `data-hover-range-start`, and `data-hover-range-end`. Hover range states are only active when not overlapping with actual selected range, enabling distinct styling for hover preview vs actual selection in range mode. ### Fixed - **Date Picker**: Fix date comparison issues when time components are involved. This resolves critical issues with date comparison operations when different date types (`CalendarDate`, `CalendarDateTime`, `ZonedDateTime`) are mixed, particularly in scenarios involving time components. ## [5.17.0] - 2025-07-18 ### Added - **Checkbox**: Add `CheckboxGroupProvider` component for external checkbox group state management ### Fixed - **Carousel**: Fix issue where full page carousel could trap scrolling - **ListCollection**: Export `UseListCollectionReturn` type - **TreeCollection**: Fix issue where the `filter` method completely deletes the children key from the node when there are no matching children - **Number Input**: Fix issue where default pattern does not allow negative numbers with decimal point - **File Upload** - Export `FileError`, `FileMimeType`, and `FileRejection` types - Fix issue where calling `api.setFiles` invokes validation with incorrect `acceptedFiles` - Fix issue where the browser might not be able to infer the mime type of a file due to limitations, drag source or security restrictions. As a fallback in the file validation logic, we now infer the mime type from the file extension. ## [5.16.1] - 2025-07-05 ### Fixed - **Combobox** - Expose `reason` to `onOpenChange` and `onInputValueChange` callbacks - Expose `api.clearHighlightedValue` function to clear highlighted value - **Date Picker** - Fix issue where datepicker errors when setting `selectionMode=range` and `minView=year` - Fix issue where `focusedValue` could not be fully controlled - **Toast**: Fix issue where toast `title` or `description` could not accept VNodes. - **Listbox**: Select highlighted item only if it exists in the collection - **Progress**: Improve `valueAsString` formatting - **Select** - Select highlighted item only if it exists in the collection - Expose `api.clearHighlightedValue` function to clear highlighted value - **Tour**: Fix an issue where the `goto` function in `StepActionMap` doesn't work when passing step IDs (string) - **Tree View**: Expose `id` in the tree node state ## [5.16.0] - 2025-07-01 ### Added - **Color Picker**: Add support for `inline` prop to render color picker inline - **Date Picker**: Add support for `inline` prop to render the date calendar inline ### Fixed - **Color Picker**: Auto-prefix Hex values with `#` if missing when using the `hex` channel input - **Menu**: Fix interaction outside detection for focusable context trigger - **Tree View**: Improve support for rendering tree items as links ## [5.15.3] - 2025-06-27 ### Fixed - **Combobox, Select, Listbox**: Fix issue where rehydrating `defaultValue` or `value` after fetching items doesn't update the `valueAsString` ## [5.15.2] - 2025-06-26 ### Fixed - **General**: Fix issue where some Zag packages were not included in the package.json `dependencies` and `devDependencies`. This causes import errors when using the `@ark-ui/vue` package. - **Date Picker**: Fix issue with keyboard selection where setting unavailable date causes month view to behave differently from clicking with mouse - **Toast**: Fix issue where app crashes when `toaster.promise` is called without loading option. The `loading` option is now required. A warning will be logged if it is not provided - **Tree View** - Fix issue where clicking a branch with indeterminate state doesn't check its child nodes - Remove `aria-busy` attribute from branch trigger when not loading children - Expose node details in `onExpandChange`, `onSelectionChange` and `onFocusChange` - **Angle Slider**: Fix issue where scrubbing doesn't feel smooth on touch devices - **Timer**: - Fix issue where timer could continue beyond `targetMs` when window is not visible - Add validation to ensure `startMs` and `targetMs` are configured correctly - Fix `progressPercent` calculation for countdown timers ## [5.15.1] - 2025-06-23 ### Fixed - **Listbox**: Fix issue where `Listbox.ItemContext` was not exported ## [5.15.0] - 2025-06-23 ### Added - **Tree View** - Add support for checkbox state for checkbox trees via `defaultCheckedValue`, `checkedValue`, `onCheckedChange` props - Add callback for when `loadChildren` fails via `onLoadChildrenError` prop ### Fixed - **Progress** - Fix issue where setting orientation to `vertical` don't work - Fix issue where setting `defaultValue` to `null` doesn't show indeterminate state ## [5.14.2] - 2025-06-19 ### Fixed - **General**: Ensure pointerdown or click event handlers only execute when the main button is clicked - **Tree View**: Exported `TreeViewNodeState` and `TreeViewNodeProps` types from `@zag-js/tree-view` ### Changed - **Collection**: Improve the APIs around `tree.flatten(...)` and `flattenedToTree` to ensure the original node properties are preserved. > Previously, `tree.flatten()` would return an array of objects with `value` and `label` stripping out the original > node properties. ```ts const tree = new TreeCollection({ rootNode: { value: 'ROOT', children: [{ value: 'child1' }, { value: 'child2' }], }, }) const flattened = tree.flatten() const reconstructed = flattenedToTree(flattened) console.log(reconstructed.rootNode) // { // value: "ROOT", // children: [{ value: "child1" }, { value: "child2" }], // } ``` ## [5.14.1] - 2025-06-17 ### Fixed - **Popover**: Fixed issue where `onOpenChange` could be called twice when controlled - **File Utils**: Improved `downloadFile` function to handle webview scenarios - **Toast**: Fixed issue where toast's CSS variables don't apply correctly - **Combobox**: - Fixed issue where `onInputValueChange` could be called twice when selecting an item - Fixed issue where combobox with `allowCustomValue: true` used within in a form requires two enter keypress to submit ## [5.14.0] - 2025-06-10 ### Added - **Editable**: Added support for `activationMode=none` - **Collection** - Exposed `copy` method - Added support for `getParentNodes` to accept a value or index path ### Fixed - **Collection**: Fixed issue where entrypoint `@ark-ui/vue/collection` was not working as expected - **Carousel**: Fixed issue where carousel crashes when `slidesPerPage` is 0 - **File Upload**: Prevented `undefined` in `acceptedFiles` when no files accepted - **Select**: Fixed issue where highlighted item could be cleared when navigating up/down the list with keyboard - **Tabs**: Fixed issue where tabs with links should not trigger tab change upon cmd/middle click - **Menu**: Fixed issue where `Menu.ItemText` could not be used with `Menu.Item` ## [5.13.0] - 2025-06-07 ### Added - **Collection**: Add new `useListCollection` hook to create a dynamic list collection. ### Fixed - **Progress**: Export `ProgressValueChangeDetails` and `ProgressValueTranslationDetails` types from `@zag-js/progress` ## [5.12.0] - 2025-06-05 ### Added - **Tree View**: Add support for lazy loading node children. To use this, you need to provide: - `loadChildren` is a function that is used to load the children of a node. - `onLoadChildrenComplete` is a callback that is called when the children of a node are loaded. Used to update the tree collection. - Add `childrenCount` to the node object to indicate the number of children. ### Fixed - **Slider** - Fixed issue where `Shift` + `ArrowRight` set value to `0` instead of `max` when step is too large (e.g. `20`) - Fixed issue where `onValueChangeEnd` doesn't return the latest value when dragging very fast ## [5.11.0] - 2025-05-30 ### Added - **File Upload**: Added support for transforming uploaded files via `transformFiles` context property. ### Fixed - **Slider**: Fixed issue where `minStepsBetweenThumbs` isn't computed correctly when interacting with pointer or keyboard. ## [5.10.0] - 2025-05-29 ### Added - **[NEW] Password Input**: Added `PasswordInput` component for collecting secure text inputs. ```tsx import { PasswordInput } from '@ark-ui/vue/password-input' import { EyeIcon, EyeOffIcon } from 'lucide-vue-next' export const Basic = () => ( Password }> ) ``` - **Select**: Added `onSelect` callback that gets fired when an item is selected via keyboard/mouse. ### Fixed - **Color Picker**: Fixed issue where value change end event is invoked when committing via an input. - **Toast**: Fixed issue where calling `toast.remove()` without an id shows a TypeScript error. - **Field**: Fixed issue where helper text and error text could not be detected in shadow DOM environments. ## [5.9.2] - 2025-05-24 ### Fixed - **Collection**: Export `CollectionOptions`, `TreeCollectionOptions`, `GridCollectionOptions` types. - **Carousel** - Fix issue where focusing on carousel region and navigating with keyboard doesn't work as expected - Fix issue when `allowMouseDrag` is set where carousel no longer snaps after mouse interaction - **Combobox**: Fix issue where `onInputValueChange` doesn't get called when `autoFocus` is set to `true` - **Slider**: Fix issue where slider could throw a error when rendered in an popover or dialog - **Tour**: Fix issue where calling `api.start()` with a step id doesn't work as expected - **Menu**: Fix issue where `Menu.Item` throws a `document is not defined` error when used in a Nuxt app. ## [5.9.1] - 2025-05-12 ### Fixed - **Combobox** - Fixed issue where `focusable` prop was not being applied to the trigger element. - Fixed issue where combobox doesn't work for items rendered as links. - **Collection**: Fix issue where `getNextValue` and `getPreviousValue` doesn't work as expected when `groupBy` is used. ## [5.9.0] - 2025-05-05 ### Added - **Locale**: Added `useFilter` composable to filter data based on the current locale. - **Format**: Added `FormatRelativeTime` component for formatting relative time. ## [5.8.0] - 2025-05-01 ### Added - **Date Picker**: Added support for `outsideDaySelectable` prop to allow selecting days outside the current month (on the same visible date range) ## [5.7.0] - 2025-04-25 ### Added - **[NEW] Listbox**: Introduced the `Listbox` component for selecting a single or multiple items from a list. See the [documentation](https://ark-ui.com/docs/components/listbox) for details. - Improved support for grouping collection items. Check the `Listbox`, `Select` or `Combobox` documentation for more details. ### Changed - Added `package.json` to `exports` for improved compatibility with tools like Vite. ## [5.6.0] - 2025-04-15 ### Added - **[NEW] AngleSlider**: Introduced the `AngleSlider` component for selecting an angle. See the [documentation](https://ark-ui.com/docs/components/angle-slider) for details. - **[NEW] FloatingPanel**: Introduced the `FloatingPanel` component for creating floating windows. See the [documentation](https://ark-ui.com/docs/components/floating-panel) for details. - **Toast**: Added toast queuing when the max limit is reached: - New toasts were queued instead of dropped - Queued toasts were shown when space became available - Queue cleared when all toasts were removed - **Combobox**: - Fallbacked to the trigger element as the positioning anchor - Added `data-empty` attribute to indicate an empty listbox or content ### Fixed - **CheckboxGroup**: Fixed issue where `v-model` doesn't work as expected. ## [5.5.0] - 2025-04-05 ### Added - **Presence**: Added support for skipping the initial animation when the component is mounted. This can be used in all disclosure components (e.g., `Dialog`, `DatePicker`, `Menu` etc). ### Fixed - **Tabs**: Fixed issue where tabs indicator animation behaves inconsistently. - **Date Picker** - Fixed issue where datepicker throws error when navigating month view. - Fixed issue where range selection doesn't reset correctly when clicking the same start date. - **Disclosure Components** - Fixed issue where pointerdown outside doesn't work consistently on mobile devices. - Improved pointerdown outside click detection in shadow DOM environments. ## [5.4.0] - 2025-03-28 ### Added - **Slider** - Add support for `origin: end` to align the thumb to the end of the track. - Expose `thumbSize` as CSS variables in the root element. Can be useful for styling the slider. - **Menu** - Added `select` emit event to the `Menu.Item` component. ### Fixed - Ensured each component's state machine starts before processing events. - **HoverCard, ColorPicker**: Added missing `tabIndex` for better dialog support. - **Menu**: Assigned unique IDs to menu items to improve accessibility and HTML validation. - **Field**: Fixed `Textarea` to use `ark.textarea`, ensuring support for the `asChild` prop. ## [5.3.0] - 2025-03-24 ### Added - **Collapsible**: Added an `Indicator` part to display whether the collapsible was open or closed. - **ColorPicker**: Added support for formatting the `ValueText` component. ```tsx // #ff0000 ``` ### Fixed - **Combobox**: Fixed an issue where `onOpenChange` was called with the same `open` value. - **Splitter**: Fixed an issue where `onResizeStart` and `onResizeEnd` callbacks weren't triggered during keyboard interactions. ## [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/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). # 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 ``` # 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. They are used alongside component hooks. ```vue ``` > When using the `RootProvider` component, you don't need to use the `Root` component. See more in [Examples](/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 ``` ## ID Composition When composing components that need to work together, share IDs between them using the `ids` prop for proper accessibility and interaction. ```tsx import { Avatar } from '@ark-ui/react/avatar' import { Tooltip } from '@ark-ui/react/tooltip' import { useId } from 'react' export const TooltipWithAvatar = () => { const id = useId() return ( SA Segun Adebayo is online ) } ``` Both components share the same `id` through their `ids` props, creating proper accessibility bindings, `aria-*` attributes and interaction behavior. ## 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. # Refs ## React In React, the `ref` prop can be used to access the rendered element. Use the `useRef` hook to create a reference and pass it to the component. ```tsx import { Slider } from '@ark-ui/react/slider' import { useRef } from 'react' export const MySlider = () => { const rootRef = useRef(null) return {/* ... */} } ``` ## Solid In Solid, the `ref` prop can be used to access the rendered element. ```tsx import { Slider } from '@ark-ui/solid/slider' export const MySlider = () => { let rootRef!: HTMLDivElement return (rootRef = el)}>{/* ... */} } ``` Alternatively, you can assign refs to Solid.js signals via the `createSignal` function. ```tsx import { Slider } from '@ark-ui/solid/slider' import { createSignal } from 'solid-js' export const MySlider = () => { const [rootRef, setRootRef] = createSignal(null) return {/* ... */} } ``` ## Vue In Vue, pass the `ref` prop to the component to access the rendered element via the `$el` property. ```vue ``` ## Svelte In Svelte 5, use the `bind:ref` directive to access the rendered element. ```svelte {/* ... */} ``` # 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. ### Class Names If you prefer using classes instead of data attributes, utilize `class` or `className` prop to add custom classes to Ark UI components. Pass a class: ```jsx {/* … */} ``` Then use in styles: ```css .AccordionItem { border-bottom: 1px solid #e5e5e5; &[data-state='open'] { background-color: #f5f5f5; } } ``` ## 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 {/* … */} ``` # AI --- # 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. # MCP Server The Ark UI MCP Server is a specialized [Model Context Protocol](https://modelcontextprotocol.io/introduction) server that empowers AI agents to build design system components with full knowledge of Ark UI. Ark UI MCP Server It works with tools like Claude Code, Cursor, and Copilot to generate code and apply design system logic consistently across React, Vue, Solid, and Svelte. ## Tools The Ark UI MCP exposes the following tools to AI agents: - **`list_components`**: Returns a full list of all available components - **`list_examples`**: Lists various component examples - **`get_example`**: Retrieves code examples and usage patterns - **`styling_guide`**: Provides styling guidelines for components (data attributes and CSS variables) ## Setup The MCP server currently supports only [stdio transport](https://modelcontextprotocol.io/specification/2025-06-18/basic/transports#stdio) and is published at `@ark-ui/mcp`. ### Visual Studio Code > Make sure you have the [GitHub Copilot](https://marketplace.visualstudio.com/items?itemName=GitHub.copilot) and > [GitHub Copilot Chat](https://marketplace.visualstudio.com/items?itemName=GitHub.copilot-chat) extensions installed. - In the `.vscode/mcp.json` file at the root of your project, add the MCP server block: ```json title=".vscode/mcp.json" { "servers": { "ark-ui": { "command": "npx", "args": ["-y", "@ark-ui/mcp"] } } } ``` - The MCP server is now ready to use. Click the **"Start"** button in the `mcp.json` file. - Start a new chat VSCode Copilot like _"Build me a checkbox with ark ui"_ ### Cursor - In the `.cursor/mcp.json` file at the root of your project, add the following configuration: ```json { "mcpServers": { "ark-ui": { "command": "npx", "args": ["-y", "@ark-ui/mcp"] } } } ``` - Go to **Settings** > **Cursor Settings** > **MCP & Integrations** and enable the Ark UI server. - Start a new chat Cursor chat like _"Build me a checkbox with ark ui"_ ### Claude Code > Make sure you have Claude Code installed. Visit [Anthropic docs](https://docs.anthropic.com/en/docs/claude-code/mcp) > for installation instructions. - Run the following command in your terminal to add the Ark UI MCP server: ```bash claude mcp add ark-ui -- npx -y @ark-ui/mcp ``` - Start a Claude Code session by running `claude` - Type a prompt like _"Build me a checkbox with ark ui"_ ### Windsurf - Navigate to **Settings** > **Windsurf Settings** > **Cascade** - Click the **Manage MCPs** button, then click the **"View raw config"** button. - Add the following to the MCP configuration file: ```json title=".codeium/windsurf/mcp_config.json" { "mcpServers": { "ark-ui": { "command": "npx", "args": ["-y", "@ark-ui/mcp"] } } } ``` > You might need to click the **Refresh** button to see the MCP server in the list. - Start a new chat Windsurf like _"Build me a checkbox with ark ui"_ ### Zed - Go to **Settings** > **Open Settings** - In the `settings.json` file, add MCP server as a new **context server**: ```json title=".config/zed/settings.json" { "context_servers": { "ark-ui": { "source": "custom", "command": "npx", "args": ["-y", "@ark-ui/mcp"] } } } ``` - Start a new chat Zed like _"Build me a checkbox with ark ui"_ ### Custom MCP Client To run the MCP server in a local or development environment using a custom MCP client, you need to add the MCP server to the client's configuration file. ```json { "mcpServers": { "ark-ui": { "command": "npx", "args": ["-y", "@ark-ui/mcp"] } } } ``` # COLLECTIONS --- # Async List The `useAsyncList` hook manages asynchronous data operations for list collections. It provides a comprehensive solution for loading, filtering, sorting, and paginating data with built-in loading states, error handling, and request cancellation. ```tsx import { useAsyncList } from '@ark-ui/react/collection' const list = useAsyncList({ async load({ signal }) { const response = await fetch('/api/users', { signal }) const users = await response.json() return { items: users } }, }) console.log(list.items) // User[] console.log(list.loading) // boolean console.log(list.error) // Error | null ``` ## Examples ### Basic Usage The most basic usage involves providing a `load` function that returns data. ```vue ``` ### Infinite Loading Implement pagination by returning a cursor that indicates more data is available. ```vue ``` ### Filtering Filter data based on user input with automatic debouncing and loading states. ```vue ``` ### Sorting (Client-side) Sort data on the client side after loading from the server. ```vue ``` ### Sorting (Server-side) Send sort parameters to the server and reload data when sorting changes. ```vue ``` ### Dependencies Automatically reload data when dependencies change, such as filter selections or external state. ```vue ``` ## API Reference ### Props - **load** (`(params: LoadParams) => Promise>`) - Function to load data asynchronously - **sort** (`(params: SortParams) => Promise> | SortResult`) - Optional function for client-side sorting - **autoReload** (`boolean`, default: `false`) - Whether to automatically reload data on mount - **initialItems** (`T[]`, default: `[]`) - Initial items to display before first load - **dependencies** (`any[]`, default: `[]`) - Values that trigger a reload when changed - **initialFilterText** (`string`, default: `''`) - Initial filter text value - **initialSortDescriptor** (`SortDescriptor | null`) - Initial sort configuration ### Load Parameters The `load` function receives an object with the following properties: - **cursor** (`C | undefined`) - Current cursor for pagination - **filterText** (`string`) - Current filter text - **sortDescriptor** (`SortDescriptor | null`) - Current sort configuration - **signal** (`AbortSignal`) - AbortController signal for request cancellation ### Load Result The `load` function should return an object with: - **items** (`T[]`) - The loaded items - **cursor** (`C | undefined`) - Optional cursor for next page ### Sort Parameters The `sort` function receives an object with: - **items** (`T[]`) - Current items to sort - **descriptor** (`SortDescriptor`) - Sort configuration with `column` and `direction` ### Return Value The hook returns an object with the following properties and methods: #### State Properties - **items** (`T[]`) - Current list of items - **loading** (`boolean`) - Whether a load operation is in progress - **error** (`Error | null`) - Any error from the last operation - **cursor** (`C | undefined`) - Current cursor for pagination - **filterText** (`string`) - Current filter text - **sortDescriptor** (`SortDescriptor | null`) - Current sort configuration #### Methods - **reload** (`() => void`) - Reload data from the beginning - **loadMore** (`() => void`) - Load more items (when cursor is available) - **setFilterText** (`(text: string) => void`) - Set filter text and reload - **sort** (`(descriptor: SortDescriptor) => void`) - Apply sorting #### Types ```tsx interface SortDescriptor { column: string direction: 'ascending' | 'descending' } interface LoadParams { cursor?: C filterText: string sortDescriptor?: SortDescriptor | null signal: AbortSignal } interface LoadResult { items: T[] cursor?: C } ``` # 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" }] ``` # List Selection The `useListSelection` hook manages selection state in lists and collections. It supports single and multiple selection modes with operations like select, deselect, toggle, and clear. ```tsx import { createListCollection, useListSelection } from '@ark-ui/react/collection' const collection = createListCollection({ items: [ { label: 'Apple', value: 'apple' }, { label: 'Banana', value: 'banana' }, { label: 'Cherry', value: 'cherry' }, ], }) const selection = useListSelection({ collection, selectionMode: 'single', deselectable: true, }) console.log(selection.selectedValues) // ['apple', 'banana', 'cherry'] ``` ## Examples ### Basic By default, the hook supports single selection mode that can be deselected. > Set `deselectable` to `false` to prevent deselecting the current selection. ```vue ``` ### Multiple Selection Set `selectionMode` to `multiple` to allow multiple items to be selected. ```vue ``` ### Range Selection Here's an example of how to implement range selection that extends the selection from the first selected item to the clicked item. ```vue ``` ## API Reference ### Props - **collection** (`ListCollection`) - The collection to manage selection for - **selectionMode** (`'single' | 'multiple' | 'none'`, default: `'single'`) - The selection mode - **deselectable** (`boolean`, default: `true`) - Whether selected items can be deselected - **initialSelectedValues** (`string[]`, default: `[]`) - Initial selected values - **resetOnCollectionChange** (`boolean`, default: `false`) - Whether to reset selection when collection changes ### Return Value The hook returns an object with the following properties and methods: #### State Properties - **selectedValues** (`string[]`) - Array of currently selected values - **isEmpty** (`boolean`) - Whether no items are selected - **firstSelectedValue** (`string | null`) - The first selected value in collection order - **lastSelectedValue** (`string | null`) - The last selected value in collection order #### Query Methods - **isSelected** (`(value: string | null) => boolean`) - Check if a value is selected - **canSelect** (`(value: string) => boolean`) - Check if a value can be selected - **isAllSelected** (`() => boolean`) - Check if all items are selected - **isSomeSelected** (`() => boolean`) - Check if some items are selected #### Selection Methods - **select** (`(value: string, forceToggle?: boolean) => void`) - Select a value - **deselect** (`(value: string) => void`) - Deselect a value - **toggle** (`(value: string) => void`) - Toggle selection of a value - **replace** (`(value: string | null) => void`) - Replace selection with a single value - **extend** (`(anchorValue: string, targetValue: string) => void`) - Extend selection from anchor to target - **setSelectedValues** (`(values: string[]) => void`) - Set the selected values - **setSelection** (`(values: string[]) => void`) - Set the selection (alias for setSelectedValues) - **clear** (`() => void`) - Clear all selections - **resetSelection** (`() => void`) - Reset selection to initial state # Tree Collection A tree collection is designed to manage hierarchical data structures like file systems, navigation menus, or organization charts. It provides powerful methods for traversing, manipulating, and querying tree structures. ```ts import { createTreeCollection } from '@ark-ui/react/collection' const treeData = { value: 'root', label: 'Root', children: [ { value: 'folder1', label: 'Folder 1', children: [ { value: 'file1', label: 'File 1.txt' }, { value: 'file2', label: 'File 2.txt' }, ], }, { value: 'folder2', label: 'Folder 2', children: [ { value: 'subfolder1', label: 'Subfolder 1', children: [{ value: 'file3', label: 'File 3.txt' }], }, ], }, ], } const tree = createTreeCollection({ rootNode: treeData }) ``` ### Navigation Methods The tree collection provides various methods to navigate through the hierarchical structure. #### Getting First and Last Nodes ```ts const firstNode = tree.getFirstNode() console.log(firstNode?.value) // "folder1" const lastNode = tree.getLastNode() console.log(lastNode?.value) // "folder2" ``` #### Sequential Navigation Navigate to the next or previous node in the tree traversal order: ```ts const nextNode = tree.getNextNode('file1') console.log(nextNode?.value) // "file2" const previousNode = tree.getPreviousNode('file2') console.log(previousNode?.value) // "file1" ``` ### Hierarchical Relationships #### Parent and Children Get parent and descendant nodes: ```ts // Get parent node const parentNode = tree.getParentNode('file1') console.log(parentNode?.value) // "folder1" // Get all ancestor nodes const ancestors = tree.getParentNodes('file3') console.log(ancestors.map((n) => n.value)) // ["folder2", "subfolder1"] // Get all descendant nodes const descendants = tree.getDescendantNodes('folder1') console.log(descendants.map((n) => n.value)) // ["file1", "file2"] // Get descendant values only const descendantValues = tree.getDescendantValues('folder2') console.log(descendantValues) // ["subfolder1", "file3"] ``` #### Sibling Navigation Navigate between sibling nodes: ```ts // Assuming we have the index path of "file1" const indexPath = tree.getIndexPath('file1') // [0, 0] const nextSibling = tree.getNextSibling(indexPath) console.log(nextSibling?.value) // "file2" const previousSibling = tree.getPreviousSibling(indexPath) console.log(previousSibling) // undefined (no previous sibling) // Get all siblings const siblings = tree.getSiblingNodes(indexPath) console.log(siblings.map((n) => n.value)) // ["file1", "file2"] ``` ### Index Path Operations Work with index paths to identify node positions: ```ts // Get index path for a value const indexPath = tree.getIndexPath('file3') console.log(indexPath) // [1, 0, 0] // Get value from index path const value = tree.getValue([1, 0, 0]) console.log(value) // "file3" // Get full value path (all ancestors + node) const valuePath = tree.getValuePath([1, 0, 0]) console.log(valuePath) // ["folder2", "subfolder1", "file3"] // Get node at specific index path const node = tree.at([1, 0]) console.log(node?.value) // "subfolder1" ``` ### Tree Queries #### Branch and Leaf Detection ```ts // Check if a node is a branch (has children) const folder1Node = tree.findNode('folder1') const isBranch = tree.isBranchNode(folder1Node!) console.log(isBranch) // true // Get all branch values const branchValues = tree.getBranchValues() console.log(branchValues) // ["folder1", "folder2", "subfolder1"] ``` #### Tree Traversal Visit all nodes with custom logic: ```ts tree.visit({ onEnter: (node, indexPath) => { console.log(`Visiting: ${node.value} at depth ${indexPath.length}`) // Skip certain branches if (node.value === 'folder2') { return 'skip' // Skip this branch and its children } }, }) ``` #### Filtering Create a new tree with filtered nodes: ```ts // Keep only nodes that match criteria const filteredTree = tree.filter((node, indexPath) => { return node.value.includes('file') // Only keep files }) console.log(filteredTree.getValues()) // ["file1", "file2", "file3"] ``` ### Tree Manipulation #### Adding Nodes ```ts const newFile = { value: 'newfile', label: 'New File.txt' } // Insert after a specific node const indexPath = tree.getIndexPath('file1') const updatedTree = tree.insertAfter(indexPath!, [newFile]) // Insert before a specific node const updatedTree2 = tree.insertBefore(indexPath!, [newFile]) ``` #### Removing Nodes ```ts const indexPath = tree.getIndexPath('file2') const updatedTree = tree.remove([indexPath!]) console.log(updatedTree.getValues()) // file2 is removed ``` #### Moving Nodes ```ts const fromIndexPaths = [tree.getIndexPath('file1')!] const toIndexPath = tree.getIndexPath('folder2')! const updatedTree = tree.move(fromIndexPaths, toIndexPath) // file1 is now moved under folder2 ``` #### Replacing Nodes ```ts const indexPath = tree.getIndexPath('file1')! const newNode = { value: 'replacedfile', label: 'Replaced File.txt' } const updatedTree = tree.replace(indexPath, newNode) ``` ### Utility Methods #### Flattening Convert the tree to a flat structure: ```ts const flatNodes = tree.flatten() console.log(flatNodes.map((n) => ({ value: n.value, depth: n._indexPath.length }))) // [{ value: "folder1", depth: 1 }, { value: "file1", depth: 2 }, ...] ``` #### Getting All Values ```ts const allValues = tree.getValues() console.log(allValues) // ["folder1", "file1", "file2", "folder2", "subfolder1", "file3"] ``` #### Depth Calculation ```ts const depth = tree.getDepth('file3') console.log(depth) // 3 (root -> folder2 -> subfolder1 -> file3) ``` ### Working with Custom Node Types You can customize how the tree collection interprets your data: ```ts interface CustomNode { id: string name: string items?: CustomNode[] isDisabled?: boolean } const customTree = createTreeCollection({ rootNode: { id: 'root', name: 'Root', items: [ { id: '1', name: 'Item 1', isDisabled: false }, { id: '2', name: 'Item 2', isDisabled: true }, ], }, nodeToValue: (node) => node.id, nodeToString: (node) => node.name, nodeToChildren: (node) => node.items, isNodeDisabled: (node) => node.isDisabled ?? false, }) ``` ### Creating Trees from File Paths Create a tree structure from file paths: ```ts import { createFileTreeCollection } from '@ark-ui/react/collection' const paths = ['src/components/Button.tsx', 'src/components/Input.tsx', 'src/utils/helpers.ts', 'docs/README.md'] const fileTree = createFileTreeCollection(paths) console.log(fileTree.getBranchValues()) // ["src", "components", "utils", "docs"] ``` > **Good to know**: Tree collections are immutable - all modification methods return a new tree instance rather than > modifying the original. # 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 context Use the `Accordion.Context` component or `useAccordionContext` hook to access the state of an accordion. It exposes the following properties: - `focusedValue`: The value of the focused accordion item. - `value`: The value of the selected accordion items. - `setValue`: A method to set the selected accordion items. ```vue ``` ### Accessing the item context Use the `Accordion.ItemContext` component or `useAccordionItemContext` hook to access the state of an accordion item. It exposes the following properties: - `expanded`: Whether the accordion item is expanded. - `focused`: Whether the accordion item is focused. - `disabled`: Whether the accordion item is disabled. ```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. # Angle Slider ## Examples ### Basic Here's a basic example of the Angle Slider component. ```vue ``` ### Controlled Use the `value` and `onValueChange` props to control the value of the Angle Slider. ```vue ``` ### Steps Use the `step` prop to set the discrete steps of the Angle Slider. ```vue Example not found``` ## 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: `0` Description: The initial value of the slider. Use when you don't need to control the value of the slider. **`dir`** Type: `'ltr' | 'rtl'` 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. **`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: string; hiddenInput: string; control: string; valueText: string }>` Required: false Default Value: `undefined` Description: The ids of the elements in the machine. Useful for composition. **`invalid`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the slider is invalid. **`modelValue`** Type: `number` Required: false Default Value: `undefined` Description: The v-model value of the angle slider **`name`** Type: `string` Required: false Default Value: `undefined` Description: The name of the slider. Useful for form submission. **`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 for the slider. #### Data Attributes **`data-scope`**: angle-slider **`data-part`**: root **`data-disabled`**: Present when disabled **`data-invalid`**: Present when invalid **`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`**: angle-slider **`data-part`**: control **`data-disabled`**: Present when disabled **`data-invalid`**: Present when invalid **`data-readonly`**: Present when 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. ### 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`**: angle-slider **`data-part`**: label **`data-disabled`**: Present when disabled **`data-invalid`**: Present when invalid **`data-readonly`**: Present when read-only ### 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. ### Marker #### Props **`value`** Type: `number` Required: true Default Value: `undefined` Description: The value of the marker **`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`**: angle-slider **`data-part`**: marker **`data-value`**: The value of the item **`data-state`**: **`data-disabled`**: Present when disabled ### RootProvider #### Props **`value`** Type: `AngleSliderApi` 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-scope`**: angle-slider **`data-part`**: thumb **`data-disabled`**: Present when disabled **`data-invalid`**: Present when invalid **`data-readonly`**: Present when read-only ### 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. # 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 Use `onStatusChange` to listen for loading state changes. ```vue ``` ### Root Provider Use the `useAvatar` hook to create the avatar store and pass it to the `Avatar.RootProvider` component. This allows you to have maximum control over the avatar programmatically. ```vue ``` > If you're using the `Avatar.RootProvider` component, you don't need to use the `Avatar.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 { getImageProps, type ImageProps } from 'next/image' const AvatarNextImage = (props: ImageProps) => { const avatar = useAvatarContext() const { hidden, ...arkImageProps } = avatar.getImageProps() const nextImage = getImageProps(props) 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 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 ``` ### Root Provider Use the `useCarousel` hook to create the carousel store and pass it to the `Carousel.RootProvider` component. This allows you to have maximum control over the carousel programmatically. ```vue ``` > If you're using the `Carousel.RootProvider` component, you don't need to use the `Carousel.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 Use the `checked` and `onCheckedChange` props to programatically control the checkbox's state. ```vue ``` ### Indeterminate Use the `indeterminate` prop to create a checkbox in an indeterminate state (partially checked). ```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 ``` ### Access Checkbox state Use the `Checkbox.Context` and its render prop to access the checkbox's state and methods. ```vue ``` ### Field The checkbox integrates smoothly with the `Field` component to handle form state, helper text, and error text for proper accessibility. ```vue ``` ### Root Provider Use the `useCheckbox` hook to create the checkbox store and pass it to the `Checkbox.RootProvider` component. This allows you to have maximum control over the checkbox programmatically. ```vue ``` > If you're using the `Checkbox.RootProvider` component, you don't need to use the `Checkbox.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 ### GroupProvider #### Props **`value`** Type: `{ isChecked: (val: string | undefined) => boolean; value: string[]; name: string | undefined; disabled: boolean | undefined; readOnly: boolean | undefined; invalid: boolean | undefined; addValue: (val: string) => void; setValue: (value: string[]) => void; toggleValue: (val: string) => void; getItemProps: (itemProps:...` 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. ### 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 Context Access the clipboard state and methods using `Clipboard.Context`. This provides access to properties like `copied`, `value`, and `setValue` > Alternatively, you can use the `useClipboardContext` hook to access the clipboard context. ```vue ``` ### Copy Status Use the `onStatusChange` prop to listen for copy operations. It exposes a `copied` property that you can use to display a success message. ```vue ``` ### Controlled Control the clipboard value externally by managing the state yourself and using `onValueChange` to handle updates. ```vue ``` ### Root Provider Use the `useClipboard` hook to create the clipboard store and pass it to the `Clipboard.RootProvider` component. This allows you to have maximum control over the clipboard programmatically. > If you're using the `Clipboard.RootProvider` component, you don't need to use the `Clipboard.Root` component. ```vue ``` ### Custom Timeout Configure the copy status timeout duration using the `timeout` prop. Default is 3000ms (3 seconds). ```vue ``` ### Programmatic Copy Trigger copy operations programmatically using the context's `copy()` method. ```vue ``` ### Value Text Use `Clipboard.ValueText` to display the current clipboard value. ```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. **`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 Use `onExitComplete` callback to listen for 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 ``` ### Lazy Mount + 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 ``` ### Root Provider Use the `useCollapsible` hook to create the collapsible store and pass it to the `Collapsible.RootProvider` component. This allows you to have maximum control over the collapsible programmatically. ```vue ``` > If you're using the `Collapsible.RootProvider` component, you don't need to use the `Collapsible.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 ### 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`**: collapsible **`data-part`**: indicator **`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 Use the `value` and `onValueChange` props to programatically control the color picker's state. ```vue ``` > Alternatively, the `onValueChangeEnd` prop can be used to listen for when the user has finished selecting a color. ### Field 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 ``` ### Root Provider Use the `useColorPicker` hook to create the color picker store and pass it to the `ColorPicker.RootProvider` component. This allows you to have maximum control over the color picker programmatically. ```vue ``` > If you're using the `ColorPicker.RootProvider` component, you don't need to use the `ColorPicker.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. **`inline`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the color picker is inline **`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: `false` 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: `false` Description: Whether the node is present (controlled by the user) **`skipAnimationOnMount`** Type: `boolean` Required: false Default Value: `false` Description: Whether to allow the initial presence animation. **`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-nested`**: popover **`data-has-nested`**: popover **`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. **`format`** Type: `ColorStringFormat` Required: false Default Value: `undefined` Description: undefined #### 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 ``` ### Grouping To group related combobox items, use the `groupBy` prop on the collection and `collection.group()` to iterate the groups. ```vue ``` ### Field 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 ``` ### Root Provider Use the `useCombobox` hook to create the combobox store and pass it to the `Combobox.RootProvider` component. This allows you to have maximum control over the combobox programmatically. ```vue ``` > If you're using the `Combobox.RootProvider` component, you don't need to use the `Combobox.Root` component. ### Links Use the `asChild` prop to render the combobox items as links. ```vue ``` For custom router links, you can customize the `navigate` prop on the `Combobox.Root` component. Here's an example of using the Tanstack Router. ```tsx import { Combobox } from '@ark-ui/react/combobox' import { useNavigate } from '@tanstack/react-router' function Demo() { const navigate = useNavigate() return ( { navigate({ to: e.node.href }) }} > {/* ... */} ) } ``` ### Rehydrate Value In some cases, where a combobox has a `defaultValue` or `value` but the `collection` is not loaded yet, here's how to rehydrate the value and populate the input value. ```vue ``` ### Highlight Matching Text Here's an example of highlighting the search text in combobox items based on the user's input. ```vue ``` ### Dynamic Items Generate combobox items dynamically based on user input. This is useful for creating suggestions or autocomplete functionality. ```vue ``` ### Creatable Options Allow users to create new options when their search doesn't match any existing items. This is useful for tags, categories, or other custom values. ```vue ``` ### Custom Objects By default, the combobox collection expects an array of objects with `label` and `value` properties. In some cases, you may need to deal with custom objects. Use the `itemToString` and `itemToValue` props to map the custom object to the required interface. ```tsx const items = [ { country: 'United States', code: 'US', flag: '🇺🇸' }, { country: 'Canada', code: 'CA', flag: '🇨🇦' }, { country: 'Australia', code: 'AU', flag: '🇦🇺' }, // ... ] const { collection } = useListCollection({ initialItems: items, itemToString: (item) => item.country, itemToValue: (item) => item.code, }) ``` ```vue ``` ## Guides ### Limit Large Datasets The recommended way of managing large lists is to use the `limit` property on the `useListCollection` hook. This will limit the number of rendered items in the DOM to improve performance. ```tsx {3} const { collection } = useListCollection({ initialItems: items, limit: 10, }) ``` ### Available height and width The following css variables are exposed to the `Combobox.Positioner` which you can use to style the `Combobox.Content` ```css /* width of the combobox control */ --reference-width: ; /* width of the available viewport */ --available-width: ; /* height of the available viewport */ --available-height: ; ``` For example, if you want to make sure the maximum height doesn't exceed the available height, you can use the following: ```css [data-scope='combobox'][data-part='content'] { max-height: calc(var(--available-height) - 100px); } ``` ## 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: `'none' | 'autocomplete' | '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-nested`**: listbox **`data-has-nested`**: listbox **`data-placement`**: The placement of the content **`data-empty`**: Present when the content is empty ### 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 ### Empty #### Props **`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`**: combobox **`data-part`**: input **`data-invalid`**: Present when invalid **`data-autofocus`**: **`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 #### Data Attributes **`data-scope`**: combobox **`data-part`**: item-group **`data-empty`**: Present when the content is empty ### 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. #### Data Attributes **`data-scope`**: combobox **`data-part`**: list **`data-empty`**: Present when the content is empty ### 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 ``` ### Controlled Use the `value` and `onValueChange` prop to control the date picker's value. ```vue ``` ### Range Selection To create a date picker that allows a range selection, you need to: - Set the `selectionMode` prop to `range`. - Render multiple inputs with the `index` prop set to `0` and `1`. ```vue ``` ### Multiple Months To create a date picker that allows multiple months, you need to: - Set the `numOfMonths` prop to the number of months you want to display. - Use the `datePicker.getOffset({ months: 1 })` prop to offset the date picker to the next month. - Render a `DatePicker.RangeText` component to display the range text. ```vue ``` ### Inline In some cases, you might want to display an inline date picker without a popup. This can be achieved by passing the `inline` prop and avoiding the use of `Portal`, `Positioner` and `Content` components. > Important to note that inline date picker doesn't use the `Portal` and `Positioner` components. ```vue ``` ### Root Provider Use the `useDatePicker` hook to create the date picker store and pass it to the `DatePicker.RootProvider` component. This allows you to have maximum control over the date picker programmatically. ```vue ``` > If you're using the `DatePicker.RootProvider` component, you don't need to use the `DatePicker.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. **`inline`** Type: `boolean` Required: false Default Value: `undefined` Description: Whether the date picker is inline **`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 **`outsideDaySelectable`** Type: `boolean` Required: false Default Value: `false` Description: Whether day outside the visible range can be selected. **`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-nested`**: popover **`data-has-nested`**: popover **`data-placement`**: The placement of the content **`data-inline`**: Present when the content is inline ### 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 To create a controlled Dialog component, manage the state of the dialog using the `open` and `onOpenChange` props: ```vue ``` ### Lazy Mount 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 ``` ### Lazy Mount and Dynamic Imports When using `lazyMount` and dynamically rendering components in the dialog (via `React.lazy`, Next.js `dynamic`), wrap the imported component in a `Suspense` component to render a fallback. ```tsx import { Dialog } from '@ark-ui/react/dialog' import { Suspense } from 'react' import dynamic from 'next/dynamic' const HeavyComponent = dynamic(() => import('./HeavyComponent')) export default function DialogExample() { return ( Open Dialog Loading...}> ) } ``` ### Render Function Use the `Dialog.Context` component to access the dialog's state and methods. ```vue ``` ### Root Provider Use the `useDialog` hook to create the dialog store and pass it to the `Dialog.RootProvider` component. This allows you to have maximum control over the dialog programmatically. ```vue ``` > If you're using the `Dialog.RootProvider` component, you don't need to use the `Dialog.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 **`requestDismiss`** Type: `[ event: CustomEvent<{ originalLayer: HTMLElement targetLayer: HTMLElement | undefined originalIndex: number targetIndex: number }>, ]` Description: Function called when this layer is closed due to a parent layer being closed **`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" **`data-nested`**: dialog **`data-has-nested`**: dialog ### 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 ``` ### 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 To auto-grow the editable as the content changes, set the `autoResize` prop to `true`. ```tsx {/*...*/} ``` ### Max Length Use the `maxLength` prop to set a maximum number of characters that can be entered into the editable. ```tsx {/*...*/} ``` ### Double click activation 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 {/*...*/} ``` ### Field 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 ``` ### Root Provider Use the `useEditable` hook to create the editable store and pass it to the `Editable.RootProvider` component. This allows you to have maximum control over the editable programmatically. ```vue ``` > If you're using the `Editable.RootProvider` component, you don't need to use the `Editable.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 ``` ### Checkbox This example demonstrates how to integrate the `Field` and `Checkbox` components. ```vue ``` ### Root Provider Use the `useField` hook to create the field store and pass it to the `Field.RootProvider` component. This allows you to have maximum control over the field programmatically. ```vue ``` > If you're using the `Field.RootProvider` component, you don't need to use the `Field.Root` component. ### Custom Control Use the `Field.Context` or `useFieldContext` hook to access the internal state of the field.This can help you wire up custom controls with the `Field` component. ```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. **`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 ``` ### Field This example demonstrates how to use the `Field` component with a standard input field within a `Fieldset`. ```vue ``` ### Checkbox This example shows how to use the `Fieldset` component with other Ark UI form elements like `Checkbox`. ```vue ``` ### 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. ### Input with Select This example shows how to use the `Fieldset` component with `Field.Input` and `Select` to create a interactive phone input component. ```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. **`disabled`** Type: `boolean | 'false' | 'true'` 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 | "false" | "true" | 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 ``` ### Initial Files Use the `defaultAcceptedFiles` prop to set the initial files in the file upload component. ```vue ``` ### Clear Trigger Use the `ClearTrigger` component to provide users with a way to remove all uploaded files at once. This trigger will clear both accepted and rejected files from the upload component. ```vue ``` ### Drag & Drop Use the `Dropzone` component to enable drag-and-drop functionality. The dropzone provides adds a `data-dragging` attribute while dragging for styling purposes. ```vue ``` ### Directory Upload Use the `directory` prop to allow users to upload entire folders. This enables selecting multiple files from a directory structure while preserving the folder hierarchy. ```vue ``` The `file.webkitRelativePath` property contains the full path of each file within the uploaded directory, allowing you to display the folder structure or process files based on their location. > **Important**: When uploading directories with many files, set `maxFiles` to a higher value (e.g., `maxFiles={100}`) > or remove the limit entirely to prevent files from being rejected due to the default file count restriction. ### Accepted File Types Use the `accept` prop to restrict the file types that can be uploaded. This prop accepts MIME types (e.g., `image/png`, `image/jpeg`) or file extensions (e.g., `.pdf`, `.txt`). When users attempt to upload files that don't match the accepted types, these files will be automatically rejected and appear in the `rejectedFiles` array with a `FILE_INVALID_TYPE` error code. ```vue ``` ### Error Handling The `FileUpload` component provides comprehensive validation and error handling capabilities. You can set various constraints and handle different types of validation errors: **Built-in Validation Props:** - `maxFiles` - Maximum number of files allowed - `maxFileSize` - Maximum file size in bytes - `minFileSize` - Minimum file size in bytes - `accept` - Allowed MIME types or file extensions **Built-in Error Types:** - `TOO_MANY_FILES` - Exceeds maxFiles limit - `FILE_INVALID_TYPE` - File type not in accept list - `FILE_TOO_LARGE` - File size exceeds maxFileSize - `FILE_TOO_SMALL` - File size below minFileSize - `FILE_INVALID` - Generic validation failure - `FILE_EXISTS` - Duplicate file detected ```vue ``` ### File Transformations Use the `transformFiles` prop to process files before they're added to the accepted files list. This is useful for file compression, format conversion, or adding metadata. **Common transformation use cases:** - **Image compression**: Use `image-conversion`, `browser-image-compression`, or similar libraries - **Format conversion**: Convert files to different formats (e.g., HEIC to JPEG) - **Metadata extraction**: Add EXIF data or other file information - **File validation**: Perform additional checks beyond basic validation - **Resizing**: Automatically resize images to specific dimensions ```vue ``` ### Custom Validation Use the `validate` prop to implement custom validation logic beyond the built-in constraints. ```vue ``` ### Field Here's an example of how to use the `FileUpload` component with the `Field` component to provide a error and helper text. ```vue ``` ### Root Provider Use the `useFileUpload` hook to create the file upload store and pass it to the `RootProvider` component. This allows you to have maximum control over the file upload programmatically. > If you're using the `RootProvider` component, you don't need to use the `Root` component. ```vue ``` ### Pasting Files Use the `setClipboardFiles` method to enable pasting images directly from the clipboard. > You can access the `fileUpload` store from `FileUpload.Context` as well. ```vue