Early bird: 30% off Dashral ProSee pricing

Dashral

Floating NavPro

A site header as one pill: a highlight glides along the menu, one panel reshapes from menu to menu, and search widens out of its button.

Installation

When to use

  • The header of a marketing site or a product's landing page, with a few menus of links and a search.
  • When the header is the first thing people touch and should feel finished: every hover and click moves smoothly.

When not to use

  • Inside an app, where people work: a sidebar or a plain top bar stays out of the way.
  • Deep menus several levels down: a mega menu page or a sidebar holds them better.

Usage

Floating Nav with your own data: a whole component you can paste as a page.

example.tsx
"use client"

import { FloatingNav } from "@/components/dashral/pro/floating-nav"

const items = [
  {
    label: "Product",
    links: [
      { label: "Planning", description: "Roadmaps and cycles", href: "/planning" },
      { label: "Automations", description: "Rules that sort and assign", href: "/automations" },
    ],
  },
  { label: "Pricing", href: "/pricing" },
]

export default function Header() {
  return (
    // A header: it stays at the top while the page scrolls under it.
    <div className="sticky top-4 z-40 flex justify-center px-4">
      <FloatingNav
        brand={<span>Acme</span>}
        items={items}
        search={{ placeholder: "Search Acme", suggestions: [{ label: "Pricing", description: "Plans and prices", group: "Company", href: "/pricing" }] }}
        actions={<a href="/signup" className="rounded-full bg-foreground px-4 py-2 text-sm text-background">Start free</a>}
      />
    </div>
  )
}

API reference

FloatingNav

A site header as one pill: a highlight glides along its menu, a menu's links open in a panel that reshapes from one menu to the next, and the search button widens into the search panel (the menu button too, on a phone).

PropTypeDefault
brandReact.ReactNode

Required. The logo and name at the start; a link to brandHref.

—
brandHrefstring"/"
itemsFloatingNavItem[]

Required.

—
actionsReact.ReactNode

At the end: a call to action, Sign in…

—
search{ suggestions: FloatingNavSuggestion[]; placeholder?: string; title?: string }

Search: its suggestions (filtered as you type) and placeholder. Left out, there's no search button.

—
linkAsReact.ElementType

The link component (Next.js's Link, your router's): a by default.

"a"
classNamestring—
classNamesFloatingNavClassNames—

type FloatingNavLink

PropTypeDefault
labelstring—
descriptionstring—
iconReact.ReactNode—
hrefstring—

type FloatingNavItem

A menu entry: a plain link (href), or a menu whose links open in the panel.

PropTypeDefault
labelstring—
hrefstring—
linksFloatingNavLink[]—

type FloatingNavSuggestion

PropTypeDefault
labelstring—
descriptionstring—
iconReact.ReactNode—
groupstring—
hrefstring—

type FloatingNavClassNames

PropTypeDefault
rootstring—
barstring—
panelstring—
searchstring—

Keyboard

KeysAction
⌘KorCtrl KOpen the search, from anywhere on the page
TabReach the header
←or→Along the bar, past every menu and button
↓On a menu: open its panel at the first link
↑or↓or←or→In a menu's panel: between links; past an edge, on to what's beside it on the bar
↑or↓In the search: through the results
EnterOpen the result or link
EscClose the panel or the search, the focus back where it was

Accessibility

  • A nav named "Main"; each menu button says whether its panel is open (aria-expanded).
  • The search and the phone's menu are dialogs (aria-modal) named Search and Menu; the bar's own content is hidden from screen readers while one is open.
  • Closing returns the focus to the button that opened it.

Motion

  • A highlight glides along the menu; one panel reshapes and slides from menu to menu in the direction you move.
  • The search widens out of its button to the bar's own width (0.42 s) while the bar's content steps back (fading, to 97%, a 2px blur), and shrinks back on close.
  • Smooth tweens on [0.4, 0, 0.2, 1], never springs. With reduced motion there are no slides or growth, only short fades.