@zag-js/focus-visible
Installation
yarn add @zag-js/focus-visible
# or
npm i @zag-js/focus-visible
Contribution
Yes please! See the contributing guidelines for details.
Licence
This project is licensed under the terms of the MIT license.
Focus visible polyfill utility based on WICG
yarn add @zag-js/focus-visible
# or
npm i @zag-js/focus-visible
Yes please! See the contributing guidelines for details.
This project is licensed under the terms of the MIT license.
All notable changes to this project will be documented in this file.
For v0.x changelog, see the v0 branch
Tree View
defaultCheckedValue
, checkedValue
, onCheckedChange
propsloadChildren
fails via onLoadChildrenError
propapi.getCheckedMap
method to get the checked state of all nodesTree Collection: Add support for getDescendantNodes
and getDescendantValues
api.collapse
and api.deselect
throws error when called without argumentsexactOptionalPropertyTypes
compiler optionCollection: 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 withvalue
andlabel
stripping out the original node properties.
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" }],
// }
allowCustomValue: true
used within in a form requires two enter keypress
to submitonOpenChange
could be called twice when controlleddownloadFile
function to handle webview scenariosonInputValueChange
could be called twice when selecting an itemgetItemTextProps
and getItemIndicatorProps
to accept a partial interface of option item.activationMode=none
copy
methodgetParentNodes
to accept a value or index pathslidesPerPage
is 0undefined
in acceptedFiles
when no files acceptedTree 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.childrenCount
to the node object to indicate the number of children.function TreeAsync() {
const [collection, setCollection] = useState(initCollection)
const service = useMachine(tree.machine, {
id: useId(),
collection,
async loadChildren({ valuePath, signal }) {
const url = `/api/file-system/${valuePath.join("/")}`
const response = await fetch(url, { signal })
const data = await response.json()
return data.children
},
onLoadChildrenComplete({ collection }) {
setCollection(collection)
},
})
// ...
}
Shift
+ ArrowRight
set value to 0
instead of max
when step is too large (e.g. 20
)onValueChangeEnd
doesn't return the latest value when dragging very fasttransformFiles
context property.const service = useMachine(fileUpload.machine, {
id: useId(),
accept: ["image/jpeg", "image/png"],
transformFiles: async (files) => {
return Promise.all(files.map((file) => compress(file, { size: 200 })))
},
})
minStepsBetweenThumbs
isn't computed correctly when interacting with pointer or
keyboard.Password Input
Api
and Service
api.toggleVisible
function to toggle the visibility of the password inputtranslations
prop to customize the visibility trigger accessibility labelonSelect
callback that gets fired when an item is selected via keyboard/mouse.Color Picker: Fix issue where value change end event is invoked when committing via an input.
Svelte: Fix issue with microtask timing in svelte 5.28.3+
.
Toast: Fix issue where calling toast.remove()
without an id shows a TypeScript error.
Carousel:
allowMouseDrag
is set where carousel no longer snaps after mouse interactionCombobox: Fix issue where onInputValueChange
doesn't get called when autoFocus
is set to true
Focus Visible: Fix an issue where an assignment to the browser's HTMLElement
prototype is not supported (e.g.
happy-dom)
Preact: Remove react
and react-dom
from peerDependencies
Slider: Fix issue where slider could throw a error when rendered in an popover or dialog
Svelte: Improve reactivity when events don't trigger a state transition
Tour: Fix issue where calling api.start(<id>)
with a step id doesn't work as expected
navigate
propCollection: Fix issue where getNextValue
and getPreviousValue
doesn't work as expected when groupBy
is used.
Combobox:
href
to params in navigate
context propertyMenu, Tabs: Add href
to params in navigate
context property
outsideDaySelectable
prop to allow selecting days outside the current month (on the
same visible date range)SelectionMode
interfaceToggle Group: Add support for deselectable
prop to ensure one or more toggle is selected at any time.
Splitter:
api.resetSizes()
to reset the size to the initial specified sizeSelect: Fix issue where machine doesn't leave focus state when interacting outside with another editable element.
This leads to the data-focus
attribute not being removed from the trigger element.
Floating Panel: Fix issue where clicking the trigger when panel is open, doesn't close the panel
Floating Panel
absolute
to fixed
to improve positioning consistencyStageTriggerProps
and AnchorPositionDetails
was not exportedFloating Panel
Toast: Add support for queuing toasts that exceed the maximum limit. When the maximum number of toasts is reached:
Listbox
api.clearHighlightedValue
function to clear the highlighted valuedata-empty
attribute to indicate when the listbox is emptyCollection: Add filter
function to collection methods
data-empty
attribute to the listbox and content to indicate when the listbox is emptydefaultValue
is set.Listbox
loopFocus
was not set.extended
selection mode was not working as expected.Dom Query: Improve platform detection logic to detect macOS
and iOS
correctly.
ListCollection
instead of mutating
the internal items
Tabs: Fix issue where tabs indicator animation behaves inconsistently.
Date Picker
Interact Outside
Slider
origin: end
to align the thumb to the end of the track.thumbSize
as CSS variables in the root element. Can be useful for styling the slider.Menu: Fix issue where addItemListener
doesn't work as expected.
thumbSize
CSS variable is not applied.addItemListener
function to allow listening for dispatched custom event on menu item.tabIndex
to improve usage within dialogsmenu:select
event on the menu item when it is selectedSplitter: Fix issue where onResizeStart
and onResizeEnd
callbacks are not called when using keyboard
Combobox: Fix issue where onOpenChange
with the same open
value
ColorStringFormat
typedownloadFile
where name
is not considered in some casesNumber Input: Set the default step to 0.01
when formatOptions.style
is set to percent
[Breaking] Splitter: Redesign splitter machine to support more use cases and improve DX.
Before:
const service = useMachine(splitter.machine, {
id: useId(),
defaultSize: [
{ id: "a", size: 50 },
{ id: "b", size: 50 },
],
})
After:
const service = useMachine(splitter.machine, {
id: useId(),
panels: [{ id: "a" }, { id: "b" }],
defaultSize: [50, 50],
})
The also comes with new features such as:
Toast: Fix issue where setting offsets
to undefined
causes machine to throw
Select: Fix issue where select valueAsString
loses reactivity
api.setSizes
to set the size of multiple panelsapi.getSize
to get the size of a panelNumber Input: Fix issue where number input onValueChange
is called with incorrect valueAsNumber
Slider: Fix issue where setting min
to value other than 0
causes incorrect initial placement of thumbs
Combobox: Fix issue where cursor moves unexpected when editing input value
Tags Input: Improve caret detection logic to prevent unwanted tag removal
Timer
interval
value from 250
to 1000
Pin Input: Fix issue where OTP SMS autofill doesn't work as expected.
Date Picker: Fix issue where Svelte throws a state_unsafe_mutation
error when controlling the datepicker range
mode.
Rating Group: Fix issue where rating group label places focus incorrectly.
React: Flush effects synchronously rather than within a microtask.
Checkbox: Fix issue where checkbox incorrectly sets data-invalid
when invalid
is false
.
Radio Group, Switch: Improve focus behavior in Safari browser.
Accordion: Fix issue in Safari where clicking triggers doesn't show the content as expected.
Auto Resize:
maxHeight
, overflowY
, and boxSizing
CSS properties.Date Picker:
api.getViewProps
.visibleRangeText
property to api.offset()
return value.Progress: Add support for locale
and formatOptions
to properly format the api.percentAsString
result.
Framework Adapters (React, Svelte, Solid, Vue): Support reenter:true
in machine transitions.
Progress: Allow for more precise (decimal) values.
Scroll Snap: Fix issue where getScrollPadding
could return NaN
in test environments.
Date Picker: Fix issue where onValueChange
doesn't get called when value is cleared.
Number Input: Fix issue where allowOverflow
was not implemented.
Signature Pad
readOnly
or onChange
.getDataUrl
in the onDrawEnd
callback after clearing the signature pad does not return an
empty string.React: Improve Hot Module Replacement such that effects are replayed correctly. This removes the need to refresh the page for changes to take effect.
Toggle Group: Fix issue where calling api.setValue
with an array doesn't work as expected.
Pin Input: Fix flushSync was called from inside a lifecycle method
warning.
Vue: Fix issue where choose is not a function
error could be thrown for some machines.
File Upload: Fix issue where win.DataTransfer
could throw in testing environments.
Time Picker: Fix [@zag-js/dismissable] node is null or undefined
warning when lazy mounting the content.
count
prop to improve SSR aria-label
attribute.Pin Input: Fix issue where editing existing values don't work as expected.
Number Input: Fix issue where value
prop wasn't consumed in the machine.
Carousel: Fix issue where page
was not consumed in the machine.
Textarea: Fix issue where ResizeObserver
loop could throw undelivered notifications warning.
Toggle: Bring back toggle machine.
Hover Card: Expose interaction outside handlers to hover card.
Collection: Widen items
type to allow Iterable
instead of just Array
since we internally convert iterables
to an array.
Carousel: Enforce required slideCount
to ensure machine works as expected.
Framework Bindings: Fix issue where undefined
values were not filtered out before resolving props.
React: Fix issue where flushSync
warnings could be shown when unmounting a component.
Select: Fix regression where multiple: true
doesn't work.
Timer: Fix issue where timer doesn't restart when startMs
changes.
Toggle Group: Fix issue where data-focus
doesn't get removed after blurring the toggle group.
Toast: Fix keyboard navigation issue where toast group skips the close button within the toast item and moves to the next focusable element in the document.
<component>.Machine
type to help when typecasting generic components like combobox and select.Core: Rewrite machines for increased performance and initial mount time. The results show roughly 1.5x - 4x performance improvements across components.
[Breaking] Toast
createStore
<Key>
component to render toastsMenu: Fix issue where context menu doesn't update positioning on subsequent right clicks.
Avatar: Fix issue where api.setSrc
doesn't work.
File Upload: Fix issue where drag-and-drop doesn't work when directory
is true
.
Carousel
Timer: Fix issue where timer stops when switching tabs.