Skip to content
On this page

Native first: twelve UI patterns HTML and CSS already handle

Every pattern here is one I've seen shipped as a JavaScript component, often in more than one design system I've worked on. Each one also works with semantic HTML and a little CSS, keyboard and screen reader support included. I rebuilt all twelve that way, linked how design systems ship them, and traced the spec work that made the native versions possible.

Before you start

This isn't a case against design systems. I've spent more than a decade building them (I led Spectrum Web Components at Adobe and started PatternFly Elements at Red Hat), and there are good reasons to wrap any of these patterns in a component: one API for a large team, theming, analytics hooks, framework bindings, browsers you still have to support.

The problem is distance. The people who build a component library know that a modal <dialog> makes the rest of the page inert on its own, so focus can't wander behind it. The people using <ds-modal> often don't, and nothing in the component's API tells them. Each section starts from the HTML, so whichever component you end up using, you know what the platform is doing underneath it.

Every pattern follows the same shape:

  1. The pattern, and how a few design systems ship it today. I picked a mix of web component and React libraries and linked the component's own page.
  2. A working demo on CodePen. None of them has a JavaScript panel.
  3. How it works: what each piece of markup and CSS is doing, and what the browser does for you.
  4. What changed: the spec work and browser releases that made the native version possible, with a support table for anything that became Baseline in the last three years.
  5. When you still need JavaScript, because the honest answer is rarely "never."

Some of these only recently became possible without script. Others have worked natively for years and still get rebuilt in JavaScript anyway. Each section opens by saying which.

The support tables are built from web-features and MDN's browser-compat-data each time this site builds, so they shouldn't drift out of date. Each cell is the first version of that browser to ship the feature.

Accordion

Newer Exclusive groups and panel styling arrived between 2024 and 2026.

An accordion is a stack of summaries that each show or hide a panel. The version teams usually reach for a component to get is the exclusive one, where opening a panel closes whichever one was already open.

How design systems ship it

Demo coming: Exclusive accordion

How it works

Each panel is a <details> element. Giving every one the same name makes them a group: the browser closes the open one when another opens, the same way radio buttons share a name.

HTML
<details name="faq" open>	<summary>When will my order ship?</summary>	<div class="panel">…</div></details><details name="faq">	<summary>Can I change my shipping address?</summary>	<div class="panel">…</div></details>

The <summary> is exposed as a button with its expanded state, it's in the tab order, and Enter or Space toggles it. Closed panels stay searchable too: find-in-page opens the panel that holds the match in Chrome, Firefox and Safari. (Safari opens it but doesn't yet scroll to the match.)

For the styling, I hid the default marker and drew a chevron on summary::after that rotates when the panel is :open. The fade uses ::details-content, a pseudo-element for everything inside <details> except the summary. Before it existed, there was no handle on the panel itself, so animating one meant wrapping the content and measuring it in script.

CSS
.accordion summary::after {	transition: rotate 200ms ease;}.accordion details:open > summary::after {	rotate: 225deg;}.accordion ::details-content {	opacity: 0;	transition:		opacity 250ms ease,		content-visibility 250ms;	transition-behavior: allow-discrete;}.accordion details:open::details-content {	opacity: 1;}

Transitioning content-visibility with allow-discrete keeps the closing panel on screen long enough to fade out. Animating the height to auto needs interpolate-size, which only Chromium has today, so the demo adds it inside @supports and every other browser still gets the fade.

What changed

  • Exclusive groups came from the name attribute. Chrome 120 and Safari 17.2 shipped it in December 2023, and Firefox 130 followed in September 2024.
  • ::details-content is defined in CSS Pseudo-Elements Level 4. It shipped in Chrome 131 (November 2024), Safari 18.4 (March 2025) and Firefox 143 (September 2025).
  • :open is in both Selectors Level 4 and the HTML Standard. It matches open <details>, <dialog> and pickers. Safari 26.5 completed support in May 2026. ([open] still works if you need older browsers.)
  • Transitioning content-visibility is what lets a closing panel animate at all, since ::details-content hides with content-visibility: hidden. content-visibility became Baseline in September 2025.
  • Find-in-page opening closed panels has been in Chrome since version 97, and Firefox 148 completed it in February 2026. Safari 26.2 (December 2025) opens the panel but doesn't yet scroll to the matching text.
Mutually exclusive <details> elements Baseline
  1. Limited availability
  2. Newly available
  3. Widely available
First browser version with support for Mutually exclusive <details> elements
Desktop
Chrome 120
Edge 120
Firefox 130Last to ship
Safari 17.2
Mobile
Chrome Android 120
Firefox Android 130Last to ship
Safari iOS 17.2

caniuse MDN Web Platform Status Data from web-features 3.44.0 and MDN browser-compat-data 8.1.7, built 13 November 2026.

::details-content Baseline
  1. Limited availability
  2. Newly available
  3. Widely available
First browser version with support for ::details-content
Desktop
Chrome 131
Edge 131
Firefox 143Last to ship
Safari 18.4
Mobile
Chrome Android 131
Firefox Android 143Last to ship
Safari iOS 18.4

caniuse MDN Web Platform Status Data from web-features 3.44.0 and MDN browser-compat-data 8.1.7, built 13 November 2026.

:open Baseline
  1. Limited availability
  2. Newly available
  3. Widely available
First browser version with support for :open
Desktop
Chrome 133
Edge 133
Firefox 136
Safari 26.5Last to ship
Mobile
Chrome Android 133
Firefox Android 136
Safari iOS 26.5Last to ship

caniuse MDN Web Platform Status Data from web-features 3.44.0 and MDN browser-compat-data 8.1.7, built 13 November 2026.

content-visibility Baseline
  1. Limited availability
  2. Newly available
  3. Widely available
First browser version with support for content-visibility
Desktop
Chrome 108
Edge 108
Firefox 130
Safari 26Last to ship
Mobile
Chrome Android 108
Firefox Android 130
Safari iOS 26Last to ship

caniuse MDN Web Platform Status Data from web-features 3.44.0 and MDN browser-compat-data 8.1.7, built 13 November 2026.

When you still need JavaScript

  • Remembering which panel was open across page loads.
  • Arrow-key movement between headers. The APG accordion pattern lists it as optional, and <details> doesn't do it.
  • Real heading semantics. <summary> is exposed as a button, so a heading placed inside it may not show up in a screen reader's heading list. If your panels need to be navigable by heading, the APG version (a heading wrapping a button) still needs script.

Dialog, drawer and sheet

Newer <dialog> has worked since 2022. Opening one without script arrived in December 2025.

A modal dialog takes over the page until you answer it. A drawer is the same thing pinned to an edge. Both need the same hard parts: focus moves in, the page behind can't be reached, Esc closes, and focus returns to whatever opened it.

How design systems ship it

Demo coming: Dialog and drawer

How it works

The open button names its target with commandfor and says what to do with command="show-modal". That's the declarative version of calling showModal(), and it gets the same behavior.

HTML
<button commandfor="delete-dialog" command="show-modal">Delete account</button><dialog id="delete-dialog" aria-labelledby="delete-title" closedby="any">	<h2 id="delete-title">Delete your account?</h2>	<p>This removes your projects and invoices. It can't be undone.</p>	<form method="dialog">		<button value="cancel" autofocus>Cancel</button>		<button value="delete">Delete</button>	</form></dialog>

Here's what the browser does once the modal opens:

  • It moves the dialog to the top layer, so no z-index or portal is needed.
  • It makes everything outside the dialog inert, for focus and for the accessibility tree. Tab can still reach the browser's own toolbar, but never the page behind.
  • It moves focus inside (to the autofocus button here), and puts it back on the opener when the dialog closes.
  • Esc closes it.

A <form method="dialog"> closes the dialog on submit and sets its returnValue to the button's value. The drawer closes with command="close" on a plain button.

The drawer is the same element with different margins. I pinned it to the inline end with margin-inline: auto 0, gave it the full block size, and flipped its slide direction under :dir(rtl). One more line stops the page scrolling behind an open modal:

CSS
html:has(dialog:modal) {	overflow: hidden;}

The entry animation uses @starting-style. The exit transitions display and overlay with allow-discrete. In Chromium, that keeps the dialog in the top layer until its fade finishes. Firefox doesn't transition display yet and overlay is Chromium-only, so other engines close it with less animation or none, which is a fine fallback.

What changed

  • <dialog> itself isn't new. It reached every engine in March 2022, when Firefox 98 and Safari 15.4 shipped it.
  • Opening without script is new. Invoker commands shipped in Chrome 135 (April 2025), Firefox 144 (October 2025) and Safari 26.2 (December 2025). Before that, every modal <dialog> needed at least one line of JavaScript to call showModal().
  • Animating in and out of the top layer came with @starting-style and transition-behavior, both Baseline since August 2024.
  • :dir() reached every engine in December 2023, so the drawer can flip for right-to-left pages without a class or attribute check.
  • Light dismiss (closing on a backdrop click) is the closedby attribute, in Chrome 134 and Firefox 141. Safari doesn't support it yet, so I kept a visible close button in both demos.
Invoker commands Baseline
  1. Limited availability
  2. Newly available
  3. Widely available
First browser version with support for Invoker commands
Desktop
Chrome 135
Edge 135
Firefox 144
Safari 26.2Last to ship
Mobile
Chrome Android 135
Firefox Android 144
Safari iOS 26.2Last to ship

caniuse MDN Web Platform Status Data from web-features 3.44.0 and MDN browser-compat-data 8.1.7, built 13 November 2026.

@starting-style Baseline
  1. Limited availability
  2. Newly available
  3. Widely available
First browser version with support for @starting-style
Desktop
Chrome 117
Edge 117
Firefox 129Last to ship
Safari 17.5
Mobile
Chrome Android 117
Firefox Android 129Last to ship
Safari iOS 17.5

caniuse MDN Web Platform Status Data from web-features 3.44.0 and MDN browser-compat-data 8.1.7, built 13 November 2026.

transition-behavior Baseline
  1. Limited availability
  2. Newly available
  3. Widely available
First browser version with support for transition-behavior
Desktop
Chrome 117
Edge 117
Firefox 129Last to ship
Safari 17.4
Mobile
Chrome Android 117
Firefox Android 129Last to ship
Safari iOS 17.4

caniuse MDN Web Platform Status Data from web-features 3.44.0 and MDN browser-compat-data 8.1.7, built 13 November 2026.

:dir() Baseline
  1. Limited availability
  2. Newly available
  3. Widely available
First browser version with support for :dir()
Desktop
Chrome 120
Edge 120Last to ship
Firefox 49
Safari 16.4
Mobile
Chrome Android 120
Firefox Android 49
Safari iOS 16.4

caniuse MDN Web Platform Status Data from web-features 3.44.0 and MDN browser-compat-data 8.1.7, built 13 November 2026.

When you still need JavaScript

  • Acting on the result. returnValue tells you which button closed the dialog, but doing something about it takes script or a real form submission.
  • Guarding unsaved changes. Stopping a close means listening for the cancel event, or using command="request-close" with a listener.
  • Browsers from before 2025. The invokers polyfill fills in command, and it's worth loading only where commandForElement is missing.

Disclosure nav, toggletip and flyout

Newer Popover reached every engine in 2024, and anchor positioning in January 2026.

A navigation flyout is a button that reveals a panel of links next to it. A toggletip is the same idea on a smaller scale: a button that reveals a short note. Both need to float above the page, stay attached to their button, flip when they'd run off screen, and close when you click away or press Esc.

How design systems ship it

Demo coming: Disclosure nav and toggletip

How it works

Each panel has the popover attribute, and its button points at it with command="toggle-popover".

HTML
<button id="products-trigger" commandfor="products-menu" command="toggle-popover">Products</button><div id="products-menu" class="flyout" popover>	<ul>		<li><a href="/invoicing">Invoicing</a></li>		<li><a href="/payroll">Payroll</a></li>	</ul></div>

A plain popover is an auto popover, and that gets you a lot:

  • It renders in the top layer.
  • It light-dismisses when you click outside it or press Esc.
  • Opening one closes any other open auto popover that isn't its ancestor, which is why opening "Resources" closes "Products".
  • The browser exposes the button's expanded state to assistive tech.

The expanded state lives in the accessibility tree, not in the DOM, so [aria-expanded="true"] won't match anything. I styled the open chevron with .nav-trigger:has(+ :popover-open) instead.

Anchor positioning keeps each panel attached to its button:

CSS
#products-trigger {	anchor-name: --products;}#products-menu {	position-anchor: --products;	inset: auto;	position-area: block-end span-inline-end;	position-try-fallbacks: flip-inline;}

position-area places the panel below the button, aligned to its start edge. position-try-fallbacks flips it to the other side when there isn't room. I named each anchor explicitly rather than relying on the implicit anchor a popover gets from its invoker. The explicit names make the CSS easier to read, and they don't depend on how each engine wires up the invoker. All of it sits inside @supports (anchor-name: --a). Without support, a popover falls back to the center of the viewport, which is usable if not pretty.

This is a disclosure navigation, not a menu button. A list of links doesn't get role="menu", and it shouldn't, since that role promises arrow-key behavior that nothing here provides.

What changed

  • The popover attribute shipped in Chrome 114 (May 2023), Safari 17 (September 2023) and Firefox 125 (April 2024). web-features dates the whole feature to January 2025, when Safari on iOS 18.3 added the last piece, the HTMLElement.popover property. The attribute itself has worked everywhere since April 2024.
  • Anchor positioning is defined in CSS Anchor Positioning Level 1. Chrome 125 shipped it in May 2024, with some properties under earlier names; position-try-fallbacks and position-area got their current names in Chrome 128 and 129. Safari 26 followed in September 2025 and Firefox 147 in January 2026. The feature as a whole isn't Baseline yet, because position-visibility: anchor-valid and anchor-visible are still Safari-only. Nothing in the demo uses them.
  • command="toggle-popover" is an invoker command (Baseline December 2025). The older popovertarget attribute does the same job and has been supported since 2024. I used command so it matches the dialog demo.
popover Baseline
  1. Limited availability
  2. Newly available
  3. Widely available
First browser version with support for popover
Desktop
Chrome 114
Edge 114
Firefox 125Last to ship
Safari 17
Mobile
Chrome Android 114
Firefox Android 125Last to ship
Safari iOS 17

caniuse MDN Web Platform Status Data from web-features 3.44.0 and MDN browser-compat-data 8.1.7, built 13 November 2026.

anchor-name Baseline
  1. Limited availability
  2. Newly available
  3. Widely available
First browser version with support for anchor-name
Desktop
Chrome 125
Edge 125
Firefox 147Last to ship
Safari 26
Mobile
Chrome Android 125
Firefox Android 147Last to ship
Safari iOS 26

caniuse MDN Web Platform Status Data from web-features 3.44.0 and MDN browser-compat-data 8.1.7, built 13 November 2026.

position-area Baseline
  1. Limited availability
  2. Newly available
  3. Widely available
First browser version with support for position-area
Desktop
Chrome 129
Edge 129
Firefox 147Last to ship
Safari 26
Mobile
Chrome Android 129
Firefox Android 147Last to ship
Safari iOS 26

caniuse MDN Web Platform Status Data from web-features 3.44.0 and MDN browser-compat-data 8.1.7, built 13 November 2026.

When you still need JavaScript

  • A real application menu with role="menu", arrow keys and typeahead.
  • Closing the flyout when focus tabs out of it. Light dismiss covers clicks and Esc, not focus leaving.
  • Opening on hover. Interest invokers (interestfor) do it natively, but only in Chromium so far.
  • Older browsers. OddBird maintains polyfills for popover and anchor positioning.

Toggle switch

Long-standing Has worked natively since 2022.

A switch is an on/off control that takes effect right away, like a light switch. It reads differently from a checkbox, which usually means "include this when I submit."

How design systems ship it

Demo coming: Toggle switch

How it works

It's a checkbox. Adding role="switch" changes what a screen reader says ("switch, on" instead of "checkbox, checked"), and everything else stays native: the label, Space to toggle, form submission, :checked, :disabled.

HTML
<label class="switch-row">	Email digests	<input type="checkbox" role="switch" switch name="digest" checked></label>

appearance: none removes the native box, so the input itself becomes the track and ::before becomes the thumb. When it's checked, a checkmark drawn on ::after appears too, so the state never depends on color alone. A forced-colors block keeps it visible in Windows high contrast mode.

CSS
[role="switch"] {	appearance: none;	position: relative;	inline-size: 2.7rem;	block-size: 1.5rem;	border-radius: 999px;}[role="switch"]::before {	content: "";	position: absolute;	/* the thumb */}[role="switch"]:checked::before {	translate: 1.2rem 0;}

The switch attribute is a Safari addition. On its own, Safari draws a native switch for it; appearance: none overrides that, so the demo looks the same everywhere. I left the attribute in because it costs nothing and should pay off once more browsers support it.

What changed

Nothing recent, which is the point. role="switch" arrived in WAI-ARIA 1.1 in 2017, and unprefixed appearance reached every engine in March 2022. The only new piece is Safari's native <input type="checkbox" switch> (Safari 17.4, March 2024). No other engine has shipped it yet, which is why the demo doesn't depend on it.

When you still need JavaScript

  • Making it take effect immediately. A switch implies the change happens the moment you flip it, and saving that change somewhere needs script or a form submission.
  • Dragging the thumb. Clicking and Space work natively; a drag gesture doesn't.

Auto-growing textarea

Newer Auto-sizing reached every engine in June 2026.

A textarea that grows as you type, so you can see everything you've written without a scrollbar inside a scrollbar.

How design systems ship it

Demo coming: Auto-growing textarea

How it works

One property.

CSS
textarea {	field-sizing: content;	inline-size: 100%;	min-block-size: 3lh;	max-block-size: 10lh;}input {	field-sizing: content;	min-inline-size: 10ch;	max-inline-size: 100%;}

field-sizing: content tells a form control to size itself to its content, the way most elements already do. The rest is guardrails:

  • A fixed inline size stops the textarea shrinking sideways when a long placeholder clears.
  • lh units set the minimum and maximum in lines of text, so it starts at three lines and scrolls after ten.
  • The single-line input grows sideways, with a floor so it never collapses to nothing and a ceiling at its container.

An explicit width or height overrides field-sizing. If your reset sets textarea { height: 8rem }, take it back out.

What changed

  • field-sizing is defined in CSS Form Control Styling Level 1. Chrome 123 shipped it in March 2024, Safari 26.2 in December 2025, and Firefox 152 in June 2026, which made it Baseline.
  • The lh unit became Baseline in November 2023. Before that, the cap had to be a guess in rem.
field-sizing Baseline
  1. Limited availability
  2. Newly available
  3. Widely available
First browser version with support for field-sizing
Desktop
Chrome 123
Edge 123
Firefox 152Last to ship
Safari 26.2
Mobile
Chrome Android 123
Firefox Android 152Last to ship
Safari iOS 26.2

caniuse MDN Web Platform Status Data from web-features 3.44.0 and MDN browser-compat-data 8.1.7, built 13 November 2026.

lh unit Baseline
  1. Limited availability
  2. Newly available
  3. Widely available
First browser version with support for lh unit
Desktop
Chrome 109
Edge 109
Firefox 120Last to ship
Safari 16.4
Mobile
Chrome Android 109
Firefox Android 120Last to ship
Safari iOS 16.4

caniuse Web Platform Status Data from web-features 3.44.0 and MDN browser-compat-data 8.1.7, built 13 November 2026.

When you still need JavaScript

  • Growing in browsers from before mid-2026. Without the property you get a normal fixed textarea with a scrollbar, which is a perfectly good fallback. Matching the growth exactly takes an input listener.
  • Character counters and "you've hit the limit" messages.

Validation states

Newer The timing pseudo-classes reached every engine in November 2023.

A field should turn red when you've gotten something wrong, not while you're still typing it, and not as soon as the page loads. That timing is most of the reason form libraries track "touched" and "dirty" state.

How design systems ship it

Demo coming: Validation states

How it works

The rules are plain HTML attributes: required, type="email", minlength. CSS handles the timing.

CSS
.field input:user-invalid {	border-color: var(--error);}.field:has(input:user-invalid) .error {	display: flex;}.field input:user-valid {	border-color: var(--success);}

:user-invalid matches only after the user has changed the value and moved on, or has tried to submit the form. Tabbing past an empty required field doesn't trigger it. Typing half an email address doesn't either, until you leave the field. On submit, the browser stops the submission, focuses the first invalid field and shows its own message, and every invalid field picks up the style at once.

:has() lets the wrapper react to its input, so the error message and hint can change without a class toggled from script. Each error starts with a "!" drawn in CSS, so the state never relies on color alone. The / "" alt text on that generated content keeps it out of the accessible name.

The demo uses method="dialog" on a form outside any dialog. The browser still validates it on submit, but a valid submission goes nowhere, which is exactly what a demo needs.

What changed

  • :user-invalid and :user-valid are in both Selectors Level 4 and the HTML Standard. Firefox has had them since version 88 (2021). Safari 16.5 added them in May 2023 and Chrome 119 in October 2023, which made them Baseline in November 2023.
  • :has() became Baseline in December 2023, when Firefox 121 shipped it.
  • Alt text for generated content (content: "!" / "") became Baseline in July 2024, when Firefox 128 shipped it.
:user-valid and :user-invalid Baseline
  1. Limited availability
  2. Newly available
  3. Widely available
First browser version with support for :user-valid and :user-invalid
Desktop
Chrome 119
Edge 119Last to ship
Firefox 88
Safari 16.5
Mobile
Chrome Android 119
Firefox Android 88
Safari iOS 16.5

caniuse MDN Web Platform Status Data from web-features 3.44.0 and MDN browser-compat-data 8.1.7, built 13 November 2026.

:has() Baseline
  1. Limited availability
  2. Newly available
  3. Widely available
First browser version with support for :has()
Desktop
Chrome 105
Edge 105
Firefox 121Last to ship
Safari 15.4
Mobile
Chrome Android 105
Firefox Android 121Last to ship
Safari iOS 15.4

caniuse MDN Web Platform Status Data from web-features 3.44.0 and MDN browser-compat-data 8.1.7, built 13 November 2026.

Alt text for generated content Baseline
  1. Limited availability
  2. Newly available
  3. Widely available
First browser version with support for Alt text for generated content
Desktop
Chrome 77
Edge 79
Firefox 128Last to ship
Safari 17.4
Mobile
Chrome Android 77
Firefox Android 128Last to ship
Safari iOS 17.4

caniuse Web Platform Status Data from web-features 3.44.0 and MDN browser-compat-data 8.1.7, built 13 November 2026.

When you still need JavaScript

  • Connecting your own error message to the field. Browsers expose the invalid state to assistive tech once the user has interacted, but the visible message isn't linked to anything. aria-errormessage only applies alongside a real aria-invalid attribute, and :user-invalid doesn't set one, so wiring the message up takes a few lines of script.
  • Rules HTML can't express, like "passwords must match." That's setCustomValidity().
  • Errors that come back from the server.

Clickable card

Long-standing The stretched link has worked for years. The card-level focus ring needs :has(), Baseline since December 2023.

A card you can click anywhere on to open, which still has its own secondary links inside. The cards at the top of this guide work this way.

How design systems ship it

Demo coming: Clickable card

How it works

Wrapping the whole card in an <a> is the obvious move, and it causes two problems. A screen reader reads the entire card as the link text, and you can't put another link inside, because nested links are invalid. Carbon's tile rules out internal actions for exactly that reason.

The alternative leaves the link on the title and stretches its hit area with a pseudo-element:

CSS
.card {	position: relative;}.card h2 a::after {	content: "";	position: absolute;	inset: 0;}.card .secondary {	position: relative;	z-index: 1;}

The link's accessible name is still just the title. The ::after covers the card, so a click anywhere lands on the link. Lifting the secondary links with position: relative and z-index puts them above the overlay, so they stay clickable on their own. :has() moves the hover and focus styles up to the card:

CSS
.card:has(h2 a:focus-visible) {	outline: 2px solid var(--focus-ring);}

What changed

The stretched link works anywhere ::after and inset do, and inset has been Baseline since 2021. The newer part is the card-level focus ring. Before :has(), outlining the whole card on focus meant either outlining the pseudo-element or toggling a class from script.

:has() Baseline
  1. Limited availability
  2. Newly available
  3. Widely available
First browser version with support for :has()
Desktop
Chrome 105
Edge 105
Firefox 121Last to ship
Safari 15.4
Mobile
Chrome Android 105
Firefox Android 121Last to ship
Safari iOS 15.4

caniuse MDN Web Platform Status Data from web-features 3.44.0 and MDN browser-compat-data 8.1.7, built 13 November 2026.

When you still need JavaScript

Letting people select the card's text. The overlay sits on top of it, so dragging to select starts a click instead. Scripted cards usually check for a text selection before navigating.

Back to top

Long-standing Has worked for years. Only revealing the button on scroll still needs script.

A link at the end of a long page, or a floating button, that returns you to the start.

How design systems ship it

Demo coming: Back to top

How it works

Every one of those links is native. The script in each component exists to hide the link until you've scrolled.

HTML
<h1 id="top">Release notes</h1>…<a href="#top">Back to top</a>
CSS
@media (prefers-reduced-motion: no-preference) {	html {		scroll-behavior: smooth;	}}

#top is a special fragment: with no element of that ID, it scrolls to the top of the document but leaves focus where it was. Giving the <h1> that ID means the link also moves the focus starting point to the heading, so the next Tab doesn't send a keyboard user back to the bottom. Smooth scrolling sits behind prefers-reduced-motion, and scroll-margin-block-start leaves some room above the heading when it lands.

The demo also has a floating version, always visible. Showing it only after the reader has scrolled down is the one part that needs script today.

What changed

scroll-behavior reached every engine in March 2022 and prefers-reduced-motion in 2020. Revealing the button after scrolling without script is coming: scroll-driven animations or scroll-state() container queries can do it. Neither is Baseline yet: scroll-driven animations are missing only in Firefox, and scroll-state() queries are Chromium-only.

When you still need JavaScript

Showing the floating button only after the reader has scrolled, at least until scroll-driven animations reach Firefox.

Progress and meter

Long-standing Baseline since 2015 and 2018.

A progress bar shows how far along a task is. A meter shows a measurement within a known range, like storage used or a password's strength. They look alike, and HTML has a separate element for each.

How design systems ship it

Demo coming: Progress and meter

How it works

HTML
<label for="upload">Uploading statements.pdf</label><progress id="upload" max="100" value="62">62%</progress><label for="sync">Syncing with your bank</label><progress id="sync">Syncing</progress><label for="storage">Storage used</label><meter id="storage" min="0" max="10" low="7" high="9" optimum="2" value="8.4">8.4 of 10 GB</meter>

<progress> with a value is determinate. Without one, it's indeterminate, and the browser says so. <meter> uses low, high and optimum to decide whether the value is good, so-so or bad, and each state gets its own styling hook. Both elements are labelable, so a plain <label for> names them.

Styling is the weak spot. Each engine draws the bar with its own pseudo-elements (::-webkit-progress-value, ::-moz-progress-bar, ::-webkit-meter-optimum-value), so the demo's CSS styles each of them. That's more repetitive than a single div, but you get the semantics, states and labeling without any script.

What changed

Nothing recent. <progress> has been Baseline since 2015 and <meter> since 2018. A standard way to style the bar's parts is under discussion in CSS Form Control Styling.

When you still need JavaScript

Updating the value. Something has to know how far along the upload is. Announcing progress as it changes also needs a live region, since a screen reader won't read every new value on its own.

About the data

Ship dates come from MDN's browser-compat-data, and Baseline status from web-features, which is built on it. When the two disagreed about what a feature "is" (popover and anchor positioning both have more than one date, depending on which parts you count), I gave both and said which one this guide relies on. Design system notes describe each library's own documentation as of October 2026, not its source code.

Every demo is on CodePen, and none of them has a line of JavaScript. If one breaks in your browser, I'd like to hear about it.

Contact

A question about a post, a project, or working together — send it here. I try to reply within a couple of weekdays.

Required