Skip to content

Composables ​

Import composables from the package root:

ts
import { useClipboard, useControllableState } from '@astryx-vue/core'

There is no @astryx-vue/core/composables subpath. The functions exported from packages/core/src/composables/index.ts are below. Parameters are the TypeScript types.

FunctionWhat it does
useControllableStateA v-model that is controlled or internal. If the value is missing at setup, it stays internal.
useAnnounceAnnounces to screen readers. Matches upstream useAnnounce.
useClipboardWrites to the clipboard and keeps isCopied true for a short time.
useHotkeysGlobal shortcuts. mod+k uses ⌘ on Apple platforms.
useMediaQueryA media query as a ref, read once during setup.
useDismissOutside press and Escape for popups. Escape uses a stack; the innermost layer handles it.
useFocusTrapCycles Tab inside a container.
useRestoreFocusRemembers focus when a popup opens and returns it on close.
useScrollLockLocks body scroll with a reference count.
useListFocusArrow keys for a one-dimensional list. The default selector is [role="menuitem"].
useClickableContainerMakes a region activate on click, and leaves nested buttons, links, and inputs alone.
useGridRovingFocusArrow keys for a grid.
useTypeaheadCycles matches as the same letter is pressed. It does not move focus; onMatch does.
useComboboxA searchable option list and the current value.
useNumberFieldA number with min, max, and step.
useAsyncSource, createStaticSourceA cancellable search source, and a local static source.
useOverflow, computeOverflowFolds items that do not fit into an indicator. computeOverflow is pure.
useLongPressFires after a hold. Moving too far cancels it.
useStreamingTextReveals text that has already arrived, at natural, fast, or instant.
snapToGraphemeBoundarySnaps an offset to a grapheme boundary for streaming text.
useChatStreamScrollPins a transcript to the bottom, or lets it go. Reduced motion jumps instead of springing.
useChatNewMessagesMarks rows that arrived while the reader was not pinned to the bottom.
useKeyboardHintThe first time keyboard focus enters a group of arrow-key controls, shows a short hint beside the current item.
useImageModeDecides whether a foreground should be dark or light from an image's brightness. Returns fallback when sampling fails.
useContainerRevealReveals inline actions on hover or keyboard focus. Returns classes for the container and the content.
useMenuPressAfter a menu press, swallows the browser's extra click. resetMenuPress is for unmount and tests.

useClipboard is also exported as useCopyToClipboard from @astryx-vue/core and from @astryx-vue/core/Code. The types are the same.

Some functions belong to one component and are not in the table above. Import them from that component's subpath. The package root re-exports them too:

FunctionEntry
useToast@astryx-vue/core/Toast
useImperativeDialog@astryx-vue/core/Dialog
useImperativeAlertDialog@astryx-vue/core/AlertDialog
useOverlay@astryx-vue/core/Overlay
useContextMenu, useContextMenuSize@astryx-vue/core/ContextMenu
useDropdownMenuContext@astryx-vue/core/DropdownMenu
useSideNavCollapse@astryx-vue/core/SideNav
useListContext, useItemDescriptionId@astryx-vue/core/List
useTheme, useMediaTheme@astryx-vue/core/Theme
useIndicator@astryx-vue/core/Indicator
useSemanticIcon@astryx-vue/core/Icon
useSyntaxTheme@astryx-vue/core/Code
useChatComposerContext, useChatComposerTokens, useChatPasteAsToken, useChatDictation, useSpeechRecognition@astryx-vue/core/Chat

provideAstryxLocale and useAstryxMessages are in Internationalization.