Primitives / foldkit-primitives

Find one by the job

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 shortcutskeyboardEvents with matchHotkeyevents
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 redohistorystate
Draw only the visible rows of a long listVirtualstate
Animate a value, or let an element leave before it is removedTween, Spring, Presencemotion
Move with arrow keys through a toolbar, list, grid or treeRovingTabindex, ListNavigation, GridNavigation, TreeNavigationinteraction
Close a popup on Escape or an outside pressDismissLayer, Overlayinteraction
Press, long-press or dragPress, LongPress, Move, PointerDraginteraction
Edit text in placeEditableTextinteraction
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.