Accessible modal with the dialog element
Use the native dialog element for a modal with built-in focus trapping, Escape to close and a backdrop.
Loading snippets…
137 snippets
Use the native dialog element for a modal with built-in focus trapping, Escape to close and a backdrop.
A keyboard-accessible FAQ accordion with no JavaScript, including an exclusive group using the name attribute.
Recursively merge configuration objects without mutating the inputs and without prototype pollution.
Compare two values structurally, including nested objects, arrays, Dates, Maps and Sets.
Copy nested objects, arrays, Maps, Sets and Dates without sharing references, using the built-in structuredClone.
Deduplicate a list while preserving the first occurrence order, for hashable values or by key.
A debounce function whose returned function keeps the parameter types and exposes cancel() and flush().
Validate and normalize fields in __post_init__ so invalid objects can never be created.
Turn a sort position into a URL-safe cursor string and validate it when it comes back from the client.
Turn a multi-argument function into one that can be called a few arguments at a time.
Protect state-changing forms with a per-session token compared in constant time.
Switch a card from stacked to side-by-side based on the space it has, not the viewport.