Live playground
These examples run the installed npm package. Requests and saves are simulated locally. No account or external service is required. Hover checks are labeled when they need a desktop mouse or trackpad.
Menus & navigation
Submenus, keyboard menus, link preloading and returning to a previous list position.
Load a link when someone is likely to open it
intentPrefetch()Hover or focus this documentation link for 120 ms. A same-origin prefetch hint is added. Your browser may skip the actual request when data saving or network conditions call for it.
Hover or focus the link.
Keep a submenu open while moving to it
menuAim()Move diagonally from Products towards the lower links, then try moving directly down. Click a trigger or use Enter to activate immediately.
Products selected
Restore a list and its scroll position
navigationMemory()Scroll the project list and save your position. Scroll somewhere else, then restore. The saved position is held in memory for this page only.
Scroll the list to begin.
Find a menu item by typing
typeahead()Focus a destination, then type “p” to jump to Poland. Press “p” again to cycle to Portugal. Type “net” quickly to reach Netherlands. Arrow keys also work.
Focus a destination, then type its name.
Hover & overlays
Hover previews, tooltips, popovers, outside clicks, scroll locking and dragging.
Start dragging after clear movement
dragIntent()Move the task handle slightly, then drag deliberately. Dragging starts after 8 px. Focus the same handle and use arrow keys to move it without dragging.
Move more than 8 px to start dragging.
Keep popovers inside the screen
floating()Open the panel, change its preferred placement, then resize the browser or move the anchor close to an edge. The panel flips, shifts and shrinks to stay visible.
Save your work or invite someone to the project.
Panel closed
Open a preview after a deliberate hover
hoverIntent()Move quickly across the project button, then rest on it. The project preview opens after 150 ms of deliberate hover. You can also focus or click the button.
A clearer home for your next release.
In progressPreview closed. Hover, focus or click to open.
Stop the page moving behind a dialog
lockScroll()Open the sample dialog and try scrolling the page behind it. Close the dialog to restore page scrolling. Escape also closes it.
Scroll the page a little before opening to check that its position is preserved.
Page scrolling is available.
Close a popover after an outside click
outsidePress()Open the filters panel, change a checkbox, then click elsewhere. Inside interactions keep it open. Escape also closes the panel and returns focus to its trigger.
Filters closed.
Show hints on toolbar buttons
tooltipGroup()Hover a formatting button. The first hint waits 500 ms; moving to a neighboring button shows its hint immediately. Keyboard focus always shows the hint immediately.
Good writing starts with a small idea.
Hover or focus a formatting button.
Forms & drafts
Field errors, input cleanup, draft recovery and unsaved-change warnings.
Restore a form after an interruption
draftRecovery()Write a sample project title and note, save the draft, then clear the editor. Restore brings your text back from this tab’s session storage. Delete draft removes the stored copy.
No changes saved in this example yet.
Show an error after someone edits a field
fieldValidation()Enter “hello”, then move out of the email field. An error appears after blur. Correct it to “hello@example.com” and the error clears as you type.
Start typing, then leave the field.
Move to the first invalid field
focusInvalid()Submit the empty project form. Focus moves to the first missing field. Fill the title, submit again and focus moves to the email field.
Both fields are required. Nothing is submitted.
Clean up common input formatting
normalize()Choose a format, edit the sample value and normalize it. Compare the original with the output. Formatting cleanup does not verify that an address or phone number is valid.
Choose a format, then normalize.
Warn before leaving unsaved edits
unsavedChanges()Edit the project note to enable the guard, then save to disable it. After editing, you can use the test link to try leaving. Your browser chooses whether to show a confirmation.
Search & loading
Responsive search, current results, useful loading states and deferred content.
Search after typing pauses
debounce()Search this local reading list. Type “design” and watch the list update after you stop typing for 300 ms. The counter shows how much filtering actually ran.
- Designing a useful empty state
- Accessible menus from the start
- Small details in product design
- A guide to loading feedback
4 articles · 0 filter runs
Ignore outdated search responses
latestRequest()Load Design, then immediately load Engineering. Design is deliberately slower. Only the most recently requested team can appear, even when the earlier request finishes later.
Older results will never replace your latest selection.
Choose a team.
Avoid flashes from very short loading states
loadingIndicator()Load the report with a fast or slow connection. Both requests show a busy state immediately, but only the longer request displays the spinner after 200 ms.
Choose a request speed.
Load content as it nears the screen
nearViewport()Scroll inside the panel until the deferred report comes into view. It initializes once, when it reaches the visible area. The rest of the page stays usable throughout.
Keep scrolling inside this panel to load the secondary report.
Waiting for the report to enter view.
Prevent repeat submissions while saving
singleFlight()Click Save preferences several times during the one-second request. The button stays available so you can test repeated input, but the request counter increases only once.
Repeated clicks share one pending save.
Ready to save.
Show previous results while refreshing
staleCache()Load the project summary twice within two seconds. The second read uses the cache. Wait longer and load again: the previous version appears while a fresh one is requested.
Cache is empty.
Ready to load.
Feedback & undo
Instant updates, undo windows and screen-reader announcements.
Read updates aloud to screen readers
liveAnnouncer()Add a sample item to the basket. The count updates visually and the same useful update is announced politely to a screen reader without moving your focus.
Illustrative basket. No purchase is made.
Show a change before the server replies
optimistic()Save this article. Its appearance changes immediately, before the simulated server confirms. Turn on “Simulate a failed save” to see the previous state restored.
The details between an action and its result.
Article is not saved.
Let someone undo a recent change
undoAction()Archive the sample task. It disappears immediately and you have five seconds to undo. The final commit here only updates this local demo.
One task in your list.
Keyboard & motion
Keyboard focus, input type and motion preferences.
Return focus to the dialog opener
captureFocus()Open the project settings dialog and close it with its button or Escape. Notice the focus ring returning to the control that opened it.
Open the dialog using the keyboard to follow the focus ring.
Ready. Focus will return to the opener.
Detect keyboard, mouse or touch input
inputModality()Click or tap the sample button, then press Tab. The input card reflects the latest input type. Use this to adapt focus presentation without hiding useful feedback.
Click, tap or press a key.
Let an animation reverse smoothly
interruptibleMotion()Expand the details, then collapse them before the transition finishes. The visual reverses from its current position instead of jumping back or queuing animations.
Collapsed. Try toggling quickly.
Follow the reduced-motion setting
motionPreference()Play the sample transition. Its duration follows your system’s reduced-motion setting. Change that setting to see the value update while this page stays open.
Follows your system setting.
Move through a toolbar with arrow keys
rovingFocus()Tab into the text alignment toolbar once, then use Left, Right, Home or End to move between controls. Activate a button to update the sample text.
Small details make a familiar interface feel easier to use.
Left alignment. Tab into the toolbar to begin.