Browse the helpers by topic. Each name links to its guide and examples.
Import helpers from @ui-sdk/core unless a different entrypoint is shown.
Helper What It Does createRovingFocusGives a group one Tab stop and moves focus with the arrow keys. createGridFocusMoves focus by row and column, including cells that aren't rendered yet. byCellUpdates only the cell focus leaves and the cell it lands on. spatialMoveChooses the next item from its position on screen. nearestInDirectionFinds the nearest item in a direction without moving focus. createTypeaheadFinds an item as someone types its name. createFocusRecoveryRestores focus when the focused item is removed. keepFocusPreserves focus through a change that moves an element. inputHintsPicks the on-screen keyboard and autofill for a kind of field.
Helper What It Does createInputHistoryBrings back earlier entries with ArrowUp and ArrowDown, like a terminal. isTypeaheadKeyChecks whether a key can be used for typeahead. labelOfReads an element's label for matching typed text. isComposingChecks whether an input event is part of text that's still being composed. pageLocaleReads the language of the page, or of one section of it. userLocaleReads the browser's preferred language. toLocaleTurns a tag like en_US into one that Intl accepts.
Import these helpers from @ui-sdk/core/text-match.
Helper What It Does fuzzyScoreScores how well a piece of text matches what someone typed. matchRangesFinds where the typed text appears in a piece of text. matchSegmentsSplits text into matched and unmatched pieces you can render.
Helper What It Does createSelectionTracks selected items, including multiple selections and ranges. createLassoSelects items touched by a rectangle drawn with the pointer. createCellRangeSelects a rectangular range of grid cells. byCellRangeUpdates only the cells that join or leave a range. cellRangeMessageProvides the default announcements for a range of cells. cellsToTextConverts cell values to text for copying. textToCellsParses pasted text into rows of cell values.
Helper What It Does createMoveMoves freely positioned objects with the pointer or keyboard. createResizeResizes boxes from their edges and corners. createSwipeActionsReveals actions behind a row and supports full-swipe actions. bindHoldRuns an action once a press is held, and can repeat it while held. bindRepeatSteps once when a button is pressed, and keeps stepping while held. createAreaPicks a value along two axes, such as a point on a pad. createSpansDraws, moves, and resizes ranges on tracks. stackSpansPlaces overlapping ranges in separate lanes. createPreviewTracks a value being tried before it is chosen. moveMessageProvides the default announcements for changes in position. resizeMessageProvides the default announcements for resizing boxes. isSpanFreeChecks whether a proposed range overlaps another on its track. spansMessageProvides the default announcements for changes to ranges.
Helper What It Does createListboxHighlights options with the arrow keys, and filters them as someone types. createVirtualizerCalculates which rows to render and where to place them. createStickToBottomFollows new content while preserving the reader's place when they scroll up. bindScrollPickerPicks the option at the center of a scrolling list, like a wheel. createInlineEditManages editing, committing, and canceling a value in place.
Helper What It Does bindPanelCoordinates panel height, transitions, and focus when opening or closing. hiddenAttrsSets visibility attributes for hidden or searchable content. bindFindableReveals hidden content when the browser finds a match. supportsHiddenUntilFoundChecks whether the browser can search hidden content. animateInApplies the starting state for a CSS entrance animation. animateOutApplies the exit state and calls your completion callback after animations finish.
Import these helpers from @ui-sdk/core/gesture.
Helper What It Does createVelocityTrackerMeasures velocity from recent pointer positions. projectDistanceEstimates how far a moving value will travel as it slows down. solveSpringCalculates a spring's position and velocity over time. rubberBandAdds resistance as a value moves past an edge. sectorOfConverts a stroke's direction into a sector, such as a radial menu item.
Helper What It Does createPopupManages opening, closing, positioning, and focus using a popup preset. popupStateCreates the initial open, mounted, and payload state. popupTriggerBuilds a trigger slot that opens and closes the popup. popupContentBuilds a content slot with presence, placement, and focus handling. popupCloseBuilds a slot that closes the popup. popupTitleConnects a visible title to the popup's accessible name. popupDescriptionConnects descriptive text to the popup. popupArrowBuilds an arrow slot that follows the popup's placement. popupBackdropBuilds a backdrop slot behind a modal popup. popupViewportBuilds a full-screen container slot for a popup sheet. popupSlotsBuilds the standard popup parts together. positionPlaces an element beside an anchor and updates its placement. bindLayerRegisters a floating element for Escape and outside-press dismissal. bindPersistentLayerKeeps an element usable across layers, including modal popups. isDismissalIdentifies a dismissal reason, such as Escape or an outside press. supportsTopLayerChecks whether the browser supports the top layer used by popups.
Popup presets choose the interaction for a popover, dialog, tooltip, or hover card. Popup controllers open existing popup components from code and wait for a result. Import each from its component entrypoint, such as @ui-sdk/core/popover.
Helper What It Does createPreferenceHolds a choice from a list, notifies subscribers, and can save it between visits. createColorSchemeBuilds on a preference to choose light, dark, or the browser's scheme. colorSchemeOfReads the color scheme a browser sends with a request. preferencesScriptPuts saved preferences on their attributes before the first paint. createPointerKindReports whether the main pointer is a finger or a mouse, and whether it can hover. pointerKindOfGuesses the pointer kind from a request's headers.
Helper What It Does createViewportPans and zooms a canvas and converts between screen and canvas coordinates. createConnectTracks connections between ports with the pointer or keyboard. connectMessageProvides the default announcements for connection steps.
Helper What It Does announceReads a message out to screen readers. prepareAnnouncementsAdds the regions screen readers listen to before the first message. isRTLChecks whether an element's text runs right to left. matchesShortcutChecks whether a key press matches a shortcut, such as mod+b. formatShortcutWrites a shortcut the way the user's platform shows it. ariaKeyshortcutsWrites a shortcut as an aria-keyshortcuts value.
Helper What It Does bindViewportFollows the visible viewport and reports each change. bindAvoidKeyboardLifts an element above the on-screen keyboard.
Helper What It Does createChangeAsks to change a state value, calling its callback first. createCommitReports the final value when an interaction ends. dispatchCalls an action's callback, such as onDelete, and tells you if it was canceled. createUndoStackKeeps snapshots of a value you record, so you can undo and redo. createControllerLets code outside a component call its methods. sourceOfTells whether an event came from a mouse, touch, pen, keyboard, or code. isFocusFromKeyboardChecks whether focus just arrived from the keyboard.
Import these helpers from @ui-sdk/core/observe.
Helper What It Does observeCalls you with every change to the components on a page. elementOfFinds the element of the component a change came from. withSourceKeeps a change's source across an await.
Helper What It Does definePrimitiveDefines a component's options, state, and parts once for every framework. idPartEscapes an item value so it can be part of an id. elementsReturns a component's bound parts in page order. openAttrsReturns the usual attributes for an open or closed part. checkedAttrsReturns the usual attributes for a checked, unchecked, or mixed part. cssTurns style declarations into a style attribute and skips empty values. liveWrites attributes for state that changes often, without rendering again. selectsTells each part which state changes it needs to hear about. directKeeps chosen attributes current between renders.
Import these helpers from @ui-sdk/core/agent.
Helper What It Does createAgentLets an agent read the components on a page and use them. agentToolsDescribes the snapshot, act, and query tools for your model. registerToolsOffers the same tools to an agent built into the browser.
Import these helpers from @ui-sdk/core/history.
Helper What It Does createHistoryRecords every change to the page's components and who made it, so you can step back or undo one source. describeEntryWrites a short sentence for a history entry. stageChangesTries a set of values on the real controls and lets you put the old ones back.
Number , Date , Color , and Image cover formatting, parsing, and math for each kind of value. Each has its own entrypoint, such as @ui-sdk/core/number. Testing covers the checks for a component of your own.
Previous Mobile Next Focus and Keys