Tray Navbar
Installation
npx shadcn@latest add https://uibrik.com/r/tray-navbar.jsonInstall the packages
npm install motionAdd the cn helper
Imports
cnfrom@/lib/utils, whichshadcn initcreates. Add it by hand without shadcn.Copy the source into your project
components/uibrik/tray-navbar/tray-navbar.tsx"use client"; // A navbar whose links sit together in an inset tray, with a raised pill that // slides to the current page, like a segmented control. Calm and compact; it // reads well on busy pages. On small screens a card unfolds from the menu // button with the same tray stood upright, its pill sliding up and down. // Links sit left, centred or right; zero, one or two CTAs. import { AnimatePresence, motion, useReducedMotion } from "motion/react"; import { useCallback, useEffect, useId, useState, type ReactNode } from "react"; import { cn } from "@/lib/utils"; const EASE_OUT: [number, number, number, number] = [0.23, 1, 0.32, 1]; const SPRING = { type: "spring", duration: 0.35, bounce: 0 } as const; const FOCUS = "outline-none focus-visible:ring-2 focus-visible:ring-neutral-400 focus-visible:ring-offset-2 focus-visible:ring-offset-background"; export type NavLink = { label: string; href?: string }; export type NavbarProps = { /** Text beside the mark. */ brand?: string;
Adds the files to
components/uibrik/tray-navbar and installs motion. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/tray-navbar.Props
TrayNavbar- align
- Type "left" | "center" | "right"
- "center"
- Where the links sit: beside the logo, centred, or beside the CTAs.
- ctas
- Type "none" | "one" | "two"
- "one"
- How many call-to-action buttons.
- brand
- Type string
- "Acme"
- Text beside the mark.
- links
- Type string[]
- ["Product","Features","Pricing","Customers","Docs"]
- Link labels, in order.
- primaryLabel
- Type string
- "Get started"
- Label of the main button.
- secondaryLabel
- Type string
- "Sign in"
- Label of the quieter button.
- surface
- Type boolean
- false
- Draw the bar on a surface with a hairline edge.
- logo
- Type ReactNode
- –
- Your own logo; replaces the default mark.
- current
- Type string
- –
- Label of the current page's link.
- primaryHref / secondaryHref
- Type string
- –
- Where the CTAs go.
- className
- Type string
- –
- Classes for the header.
- maxWidth
- Type number
- 1120
- Width of the content inside the bar, in px.
- onNavigate
- Type (label) => void
- –
- Called when a link is chosen, for client-side routing.