Primitives / foldkit-primitives

Find a primitive by task

You want toReach forIn
Follow the color scheme, reduced motion or any media queryMediaQuery, PrefersDark, PrefersReducedMotionmedia
Change the layout at named widthsBreakpointsmedia
Know whether the tab is visible, the window's size, or the user idleVisibility, WindowSize, Idleevents
Answer keyboard shortcuts, and draw their labelskeyboardEvents, matchHotkey, formatHotkeyevents
Count ticks, or run something on an intervalTimer, Interval, tickstime
Wait until typing stops, or limit how often something runsdebounce, Throttletime
Say "3 minutes ago"formatRelativeTimetime
Page through a listPagination, rangestate
Undo and redohistory, Historystate
Draw only the visible rows of a long listVirtual (WindowList in foldkit-mixins-ui)state
Animate a value, or let an element leave before it is removedTween, Spring, Presencemotion
Move with arrow keys through a list, grid, tree, or boardRovingTabindex, ListNavigation, GridNavigationinteraction
Close a popup on Escape or an outside pressDismissLayer, Overlayinteraction
Press, long-press, or repeat while held (a stepper)Press, LongPress, Repeatinteraction
Drag a window or handle, and nudge or resize it by keysMove, Move.nudge, Move.resizeKeys, Boxinteraction
Reorder a list or tree by keys and by pointerReorder, PointerDraginteraction
Select items, with Shift ranges or a lassoSelection, Marqueeinteraction
Swipe a row open, or settle a scroller on an itemSwipeActions, Swipe, ScrollSettleinteraction
Keep focus when a row goes, or return it when an overlay closesFocusRecovery, FocusReturn, FocusScopeinteraction
Read where the pointer is inside an elementPointerPositiondom
Edit text in placeInlineEdit, EditableTextinteraction
Tell a screen reader what changedLiveAnnounceinteraction
Know whether the browser is online, or talk over a socketOnline, websocket, ssenet
Talk between tabsbroadcastMessages, SharedHostnet
Use the camera, the location or a permissionmediaStream, Geolocation, permissionsdevice
Track one element's size or visibilityResize, Intersection, Boundsobservers
Focus, mask or keep an element in viewAutofocus, InputMask, KeepInViewdom
Copy, share, load a script or restore scrollcopyText, share, loadScript, keepScrolldom

Working widgets built from the interaction primitives are listed under In the examples.