Dock
A row of launchers on frosted glass that swell toward the pointer like a lens.
On this page
A dock is a row of launchers on a tray of frosted glass: square tiles that hold a picture or an icon, each a link or a button. Under the pointer the row swells like a lens. The tile under it grows by half, the next one on each side by a little over a quarter and the one after that by a tenth, so the row bends smoothly toward the pointer. A label in ink rises over the tile, and a dot under a tile marks the current one. It is all CSS: :hover, the next-sibling combinator and :has() find the neighbors, and no script measures the pointer.
Dock
<nav class="dock" aria-label="Spaces"> <a class="dock-item" href="#harbor" aria-current="page"> <img class="dock-image" src="/demo/harbor.svg" alt><span class="dock-label">Harbor</span> </a> <a class="dock-item" href="#dunes"> <img class="dock-image" src="/demo/dunes.svg" alt><span class="dock-label">Dunes</span> </a> <a class="dock-item" href="#pines"> <img class="dock-image" src="/demo/pines.svg" alt><span class="dock-label">Pines</span> </a> <a class="dock-item" href="#lighthouse"> <img class="dock-image" src="/demo/lighthouse.svg" alt><span class="dock-label">Lighthouse</span> </a> <span class="dock-divider" role="separator" aria-orientation="vertical"></span> <button type="button" class="dock-item"> <svg class="icon" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <circle cx="8.75" cy="8.75" r="5.75" /><path d="M12.8159 12.8159L17.5 17.5" /> </svg><span class="dock-label">Search</span> </button> <button type="button" class="dock-item"> <svg class="icon" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <rect x="2.5" y="2.9167" width="15" height="4.1667" rx="1" /><path d="M4.1667 7.0833L4.1667 15.8333A1.25 1.25 0 0 0 5.4167 17.0833L14.5833 17.0833A1.25 1.25 0 0 0 15.8333 15.8333L15.8333 7.0833" /><path d="M7.5 10.4167L12.5 10.4167" /> </svg><span class="dock-label">Archive</span> </button></nav>import SearchIcon from '@master/icons-react/native/20/soft/search'import ArchiveIcon from '@master/icons-react/native/20/soft/archive'<nav className="dock" aria-label="Spaces"> <a className="dock-item" href="#harbor" aria-current="page"> <img className="dock-image" src="/demo/harbor.svg" alt="" /><span className="dock-label">Harbor</span> </a> <a className="dock-item" href="#dunes"> <img className="dock-image" src="/demo/dunes.svg" alt="" /><span className="dock-label">Dunes</span> </a> <a className="dock-item" href="#pines"> <img className="dock-image" src="/demo/pines.svg" alt="" /><span className="dock-label">Pines</span> </a> <a className="dock-item" href="#lighthouse"> <img className="dock-image" src="/demo/lighthouse.svg" alt="" /><span className="dock-label">Lighthouse</span> </a> <span className="dock-divider" role="separator" aria-orientation="vertical"></span> <button type="button" className="dock-item"> <SearchIcon className="icon" /><span className="dock-label">Search</span> </button> <button type="button" className="dock-item"> <ArchiveIcon className="icon" /><span className="dock-label">Archive</span> </button></nav><script> import SearchIcon from '@master/icons-svelte/native/20/soft/search' import ArchiveIcon from '@master/icons-svelte/native/20/soft/archive'</script><nav class="dock" aria-label="Spaces"> <a class="dock-item" href="#harbor" aria-current="page"> <img class="dock-image" src="/demo/harbor.svg" alt><span class="dock-label">Harbor</span> </a> <a class="dock-item" href="#dunes"> <img class="dock-image" src="/demo/dunes.svg" alt><span class="dock-label">Dunes</span> </a> <a class="dock-item" href="#pines"> <img class="dock-image" src="/demo/pines.svg" alt><span class="dock-label">Pines</span> </a> <a class="dock-item" href="#lighthouse"> <img class="dock-image" src="/demo/lighthouse.svg" alt><span class="dock-label">Lighthouse</span> </a> <span class="dock-divider" role="separator" aria-orientation="vertical"></span> <button type="button" class="dock-item"> <SearchIcon class="icon" /><span class="dock-label">Search</span> </button> <button type="button" class="dock-item"> <ArchiveIcon class="icon" /><span class="dock-label">Archive</span> </button></nav><script setup>import SearchIcon from '@master/icons-vue/native/20/soft/search'import ArchiveIcon from '@master/icons-vue/native/20/soft/archive'</script><template> <nav class="dock" aria-label="Spaces"> <a class="dock-item" href="#harbor" aria-current="page"> <img class="dock-image" src="/demo/harbor.svg" alt><span class="dock-label">Harbor</span> </a> <a class="dock-item" href="#dunes"> <img class="dock-image" src="/demo/dunes.svg" alt><span class="dock-label">Dunes</span> </a> <a class="dock-item" href="#pines"> <img class="dock-image" src="/demo/pines.svg" alt><span class="dock-label">Pines</span> </a> <a class="dock-item" href="#lighthouse"> <img class="dock-image" src="/demo/lighthouse.svg" alt><span class="dock-label">Lighthouse</span> </a> <span class="dock-divider" role="separator" aria-orientation="vertical"></span> <button type="button" class="dock-item"> <SearchIcon class="icon" /><span class="dock-label">Search</span> </button> <button type="button" class="dock-item"> <ArchiveIcon class="icon" /><span class="dock-label">Archive</span> </button> </nav></template>#The lens
A tile is 40px at rest. Under the pointer it is 60px, its neighbors 51px and the tiles after them 44px; --dock-magnify sets the largest, and the others follow from it. The tiles grow in size, not by a transform, so the row opens around the pointer instead of tiles covering one another, and the tray widens with it. They grow from the tray's foot and over its top edge, and ease there along the theme's glide. Each tile reaches half the gap to its neighbors, so the lens holds while the pointer crosses from one tile to the next.
The lens is for a pointer that hovers. On a touch screen the dock is a plain row of 40px tiles, each a target 46 by 48px with the gap and the tray's foot, and with reduced motion the tiles keep their size; the label still shows. Where the dock has less room than its tiles ask for, they all give some of it up and stay square.
#Tiles
A tile is a raised sheet with an icon, drawn at half its side, or a dock-image that fills it, with an empty alt: the label names the launcher. Its corner is a quarter of its side, the control's 10px at 40px, and the tray's corner is that plus the 8px inset, so the two curves keep one distance around the bend.
A launcher that is a link takes aria-current="page" for the place the reader is in. A button that turns something on, such as a panel, takes aria-pressed. Both draw a dot of ink under the tile. Give a dock of buttons role="group" and a name.
Toggles
<div class="dock" id="panels" role="group" aria-label="Panels"> <button type="button" class="dock-item" aria-pressed="true"> <svg class="icon" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M2.5 6.0417C2.5 5.7917 2.6667 5.589 2.9583 5.4583L9.4167 2.553Q10 2.2917 10.5833 2.553L17.0417 5.4583C17.3333 5.589 17.5 5.7917 17.5 6.0417C17.5 6.2917 17.3333 6.4943 17.0417 6.625L10.5833 9.5303Q10 9.7917 9.4167 9.5303L2.9583 6.625C2.6667 6.4943 2.5 6.2917 2.5 6.0417Z" /><path d="M2.5 10C2.5 10.25 2.6667 10.4527 2.9583 10.5833L9.4167 13.4886Q10 13.75 10.5833 13.4886L17.0417 10.5833C17.3333 10.4527 17.5 10.25 17.5 10" /><path d="M2.5 13.9583C2.5 14.2083 2.6667 14.411 2.9583 14.5417L9.4167 17.447Q10 17.7083 10.5833 17.447L17.0417 14.5417C17.3333 14.411 17.5 14.2083 17.5 13.9583" /> </svg><span class="dock-label">Layers</span> </button> <button type="button" class="dock-item" aria-pressed="false"> <svg class="icon" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M4.25 3.5L15.75 3.5A1.25 1.25 0 0 1 17 4.75L17 12.25A1.25 1.25 0 0 1 15.75 13.5L9.3379 13.5A1.25 1.25 0 0 0 8.7081 13.6703L4.8798 15.9034A1.25 1.25 0 0 1 3 14.8237L3 4.75A1.25 1.25 0 0 1 4.25 3.5Z" /> </svg><span class="dock-label">Comments</span> </button> <button type="button" class="dock-item" aria-pressed="false"> <svg class="icon" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M3.9532 10.7535Q4.119 12.0422 4.7999 13.1487Q5.559 14.3826 6.7952 15.1379Q8.0313 15.8933 9.4756 16.0059A6.0357 6.0357 0 0 0 15.6598 11.9443Q16.1302 10.5741 15.9281 9.1396A6.0358 6.0358 0 0 0 10.6259 3.9793Q9.1864 3.8162 7.8295 4.3235Q6.6125 4.7786 5.6902 5.6937L3.3143 7.9822A0.626 0.626 0 0 1 3.0069 8.1185Q2.7352 8.0852 2.5333 7.8834Q2.3315 7.6815 2.2982 7.4098A0.6257 0.6257 0 0 1 2.4829 7.0501L4.8098 4.8063Q5.923 3.7019 7.3917 3.1527Q9.0294 2.5404 10.7666 2.7372Q12.5039 2.9341 13.963 3.8974A7.2849 7.2849 0 0 1 16.8422 12.3501Q16.2744 14.0038 15.0186 15.2202A7.2846 7.2846 0 0 1 6.1434 16.2045Q4.6515 15.2929 3.7353 13.8038Q2.9135 12.4683 2.7134 10.9131A0.625 0.625 0 0 1 3.9257 10.6341A0.6251 0.6251 0 0 1 3.9532 10.7535Z" fill="currentColor" stroke="none" fill-rule="evenodd" /><path d="M2.9167 2.9167L2.9167 7.3A0.2 0.2 0 0 0 3.1167 7.5L7.5 7.5" /><path d="M10 5.8333L10 9.893A0.2 0.2 0 0 0 10.0891 10.0594L12.5 11.6667" /> </svg><span class="dock-label">History</span> </button> <span class="dock-divider" role="separator" aria-orientation="vertical"></span> <button type="button" class="dock-item"> <svg class="icon" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M3 5.5L5 5.5" /><circle cx="7" cy="5.5" r="2" /><path d="M9 5.5L17 5.5" /><path d="M3 14.5L11 14.5" /><circle cx="13" cy="14.5" r="2" /><path d="M15 14.5L17 14.5" /> </svg><span class="dock-label">Settings</span> </button></div><script>document.querySelectorAll('#panels [aria-pressed]').forEach(function (button) { button.addEventListener('click', function () { button.setAttribute('aria-pressed', button.getAttribute('aria-pressed') === 'true' ? 'false' : 'true') })})</script>dock-divider parts groups with a short hairline. The lens steps over it, as if it were not there.
#Placing it
The dock places nothing. The page decides where it stands: usually centered along the foot of a screen, in a region of its own or held there with fixed or sticky utilities. Leave room above it for the swollen tiles and their labels, about 48px.
#Accessibility
- Wrap the launchers in a
navwith anaria-labelwhen they are places, or give a dock of buttonsrole="group"and a label. - The label is each launcher's accessible name. It is unseen until the pointer or the keys reach the tile, but it stays in the page, so a screen reader reads it.
- Every launcher is a tab stop and shows its label and a focus ring when it has focus.
- Do not hide a launcher's name in the picture alone: the label is the only text it has.
#Classes
| Class | Description |
|---|---|
dock | The tray, a pane of frosted glass 56px tall, on a nav with an aria-label or a div with role="group". Its tiles stand on its foot and grow over its top edge. It places nothing; the page decides where it stands |
dock-item | A launcher: a link or a button, a 40px square raised tile holding an icon or a dock-image, with a dock-label for its name. Under a hovering pointer it grows by half, and its two neighbors on each side by less |
dock-image | A picture that fills the tile, with an empty alt: the label names the launcher |
dock-label | The launcher's name, in ink over the tile while it is under the pointer or has focus. It is also its accessible name, so it stays in the page while unseen |
dock-divider | A short hairline between groups of launchers, with role="separator" and aria-orientation="vertical". The lens steps over it |
#Custom properties
| Property | Default | Description |
|---|---|---|
--dock-size | 2.5rem | A tile's side at rest |
--dock-magnify | 1.5 | How many times its size the tile under the pointer grows to; its neighbors grow by about a half and a sixth of that growth |
--dock-inset | 8px | Space between the tiles and the tray's edge; the tray's corner is a tile's corner plus this inset |
--dock-gap | 6px | Space between two tiles |
--dock-color | var(--color-surface-floating) | The color the glass is tinted with |