Skip to content
English
Dock bar comes with Pro. Its preview shows once you unlock it.

How it works

Only transform changes, so the root keeps its size. Each icon scales by 1 + (magnify - 1) × a raised-cosine bell of its distance from the pointer, then shifts sideways so gaps stay equal and the row spreads symmetrically. Values are written by a requestAnimationFrame loop into CSS variables without React renders, and approach their targets with a 70ms time constant, so following and settling are continuous.

Use it for

  • Shortcut rows at the bottom of an internal workspace or dashboard: 5 to 8 frequent actions where icons are recognizable.
  • Floating toolbars in creative tools that benefit from a playful feel.
  • App or social link rows on portfolios and landing pages.

Look elsewhere when

  • Mobile: touch has no hover, so use a bottom tab bar.
  • More than 8 or 9 entries: the row grows noticeably wide, use a grouped sidebar.
  • Dense tables and forms: overflowing icons cover content above, use a plain icon button group.
  • No space above, or a parent with overflow: hidden and too little padding: the enlarged icons and labels get clipped.

Usage

import { useState } from 'react'
import { DockBar } from './DockBar.jsx'

export function Workspace() {
  const [page, setPage] = useState('orders')
  const entry = (key, label, icon) => ({
    key,
    label,
    icon, // an SVG with stroke="currentColor" so the color follows the state
    active: page === key,
    onClick: () => setPage(key),
  })
  return (
    // Leave at least size * (magnify - 1) + 40px above for the enlarged icons and labels
    <div style={{ paddingTop: 72 }}>
      <DockBar
        aria-label="Shortcuts"
        magnify={1.6}
        range={120}
        size={44}
        items={[
          entry('orders', 'Orders', <OrderIcon />),
          entry('chats', 'Chats', <ChatIcon />),
          entry('customers', 'Customers', <UserIcon />),
          { key: 'docs', label: 'Help docs', icon: <BookIcon />, href: '/docs' },
        ]}
      />
    </div>
  )
}

Props

PropTypeDefaultWhat it does
items{ key, label, icon, onClick?, href?, active? }[]—The icons. label is both the hover label and the accessible name; href renders an <a>, otherwise a <button>; active shows a small dot underneath.
magnifynumber1.6Scale of the icon right under the pointer; 1 means no magnifying.
rangenumber120Influence radius in px: icons farther from the pointer are not enlarged. About 2.5 to 3 times the icon size works well.
sizenumber44Base icon size in px; the icon artwork takes half of it.
...restHTMLAttributes<HTMLDivElement>—Other attributes go to the root, such as aria-label, className and style. Use --ds-dock-shadow to override the shelf shadow.

Accessibility

  • The root is role="toolbar" (pass an aria-label) and the row is one Tab stop: Left and Right move between icons with wrap-around, Home and End jump to the ends.
  • Each icon is a real <button> or <a> with an aria-label; the current one has aria-current; the visual name label is aria-hidden.
  • Keyboard focus (:focus-visible) magnifies the icon and its neighbours and shows the label and a focus ring; focus from a mouse click does not.
  • With reduced motion there is no magnifying or shifting (no animation loop, transform off in CSS), only the hover and focus highlight and the label.
  • Touch devices get a plain row of buttons with no magnifying; icons are 44×44 by default.

Motion

Scale and shift chase their targets with a 70ms time constant (about 200ms to settle); settling starts 80ms after the pointer leaves. The label enters in 160ms ease-out (fade and 4px up) and leaves in 100ms ease-in; pressing scales an icon to 0.86 in 100ms.

Add it to your project

Pro members copy a prompt and their coding agent installs the source, the same way as the free components.

DockBar.jsxdock-bar.csstokens.cssREADME.md

Both files install together. The stylesheet reads the design tokens in tokens.css and carries fallbacks, so it also works alone.

Navigation