Skip to content

← All components

Brand and content

Navbar

Router-independent brand and navigation shell.

Live example

Usage

Each example includes the complete adapter-specific parameter reference. Copy it as a starting point, then remove options your use case does not need.

React

tsx
import { Navbar } from "@cofob/design-system-react";

/**
 * Complete Navbar parameter reference.
 * @param brand
 *   type: string | renderable content
 *   default: "cofob"
 *   example: "cofob"
 * @param brandLabel
 *   type: string
 *   default: —
 *   example: "Accessible label"
 * @param homeHref/brandHref
 *   type: string
 *   default: "/"
 *   example: "/guide"
 * @param links
 *   type: readonly LinkItem[]
 *   required
 *   example: {links}
 * @param actions
 *   type: ReactNode | Svelte snippet
 *   default: —
 *   example: <ThemeToggle /> / actions snippet
 * @param menuLabel
 *   type: string
 *   default: "Navigation" / "Main navigation"
 *   example: "Accessible label"
 * @param menuToggleLabel
 *   type: string
 *   default: "Menu"
 *   example: "Accessible label"
 * @param collapseAt
 *   type: "mobile" | "tablet" | "never"
 *   default: "mobile"
 *   example: "tablet"
 * @param menuVariant
 *   type: "floating" | "inline"
 *   default: "floating"
 *   example: "floating"
 * @param surface
 *   type: "solid" | "translucent"
 *   default: "solid"
 *   example: "translucent"
 * @param open/defaultOpen
 *   type: boolean; controlled or initial state
 *   default: false
 *   example: true
 * @param onOpenChange
 *   type: (open: boolean) => void
 *   default: —
 *   example: {handleOpenChange}
 * @param nav attributes
 *   type: native element attributes
 *   default: —
 *   example: class / style / aria-* / data-*
 */
export function NavbarExample() {
  return (
    <Navbar links={links} />
  );
}

Svelte

svelte
<script lang="ts">
  import { Navbar } from "@cofob/design-system-svelte";

  // Complete Navbar parameter reference.
  // brand
  //   type: string | renderable content
  //   default: "cofob"
  //   example: "cofob"
  // brandLabel
  //   type: string
  //   default: —
  //   example: "Accessible label"
  // homeHref/brandHref
  //   type: string
  //   default: "/"
  //   example: "/guide"
  // links
  //   type: readonly LinkItem[]
  //   required
  //   example: {links}
  // actions
  //   type: ReactNode | Svelte snippet
  //   default: —
  //   example: <ThemeToggle /> / actions snippet
  // brandContent
  //   type: Svelte snippet
  //   default: —
  //   example: brandContent snippet
  // menuLabel
  //   type: string
  //   default: "Navigation" / "Main navigation"
  //   example: "Accessible label"
  // menuToggleLabel
  //   type: string
  //   default: "Menu"
  //   example: "Accessible label"
  // collapseAt
  //   type: "mobile" | "tablet" | "never"
  //   default: "mobile"
  //   example: "tablet"
  // menuVariant
  //   type: "floating" | "inline"
  //   default: "floating"
  //   example: "floating"
  // surface
  //   type: "solid" | "translucent"
  //   default: "solid"
  //   example: "translucent"
  // open/defaultOpen
  //   type: boolean; controlled or initial state
  //   default: false
  //   example: true
  // onOpenChange
  //   type: (open: boolean) => void
  //   default: —
  //   example: {handleOpenChange}
  // nav attributes
  //   type: native element attributes
  //   default: —
  //   example: class / style / aria-* / data-*
</script>

<Navbar links={links} />

HTML

html
<!--
  Complete Navbar parameter reference.
  brand
    type: string | renderable content
    default: "cofob"
    example: "cofob"
  brandLabel
    type: string
    default: —
    example: "Accessible label"
  homeHref/brandHref
    type: string
    default: "/"
    example: "/guide"
  links
    type: readonly LinkItem[]
    required
    example: {links}
  actions
    type: ReactNode | Svelte snippet
    default: —
    example: <ThemeToggle /> / actions snippet
  menuLabel
    type: string
    default: "Navigation" / "Main navigation"
    example: "Accessible label"
  menuToggleLabel
    type: string
    default: "Menu"
    example: "Accessible label"
  collapseAt
    type: "mobile" | "tablet" | "never"
    default: "mobile"
    example: "tablet"
  menuVariant
    type: "floating" | "inline"
    default: "floating"
    example: "floating"
  surface
    type: "solid" | "translucent"
    default: "solid"
    example: "translucent"
  open/defaultOpen
    type: boolean; controlled or initial state
    default: false
    example: true
  onOpenChange
    type: (open: boolean) => void
    default: —
    example: {handleOpenChange}
  nav attributes
    type: native element attributes
    default: —
    example: class / style / aria-* / data-*
-->
<nav class="cf-navbar">…</nav>

<script type="module">
  import { initDesignSystem } from "@cofob/design-system-css";

  const designSystem = initDesignSystem(document);
  window.addEventListener("pagehide", () => designSystem.destroy(), { once: true });
</script>

Parameters

Adapter differences are explicit. Native element attributes are forwarded in React and Svelte and can be written directly in HTML.

ParameterTypeDefaultAdaptersExampleDescription
brandstring | renderable content"cofob"React · Svelte · HTML"cofob"Brand text or custom brand content.
brandLabelstringReact · Svelte · HTML"Accessible label"Accessible label for a non-text brand.
homeHref/brandHrefstring"/"React · Svelte · HTML"/guide"Router-independent home destination.
linksrequiredreadonly LinkItem[]requiredReact · Svelte · HTML{links}Portable link records with href, label, external, and current fields.
actionsReactNode | Svelte snippetReact · Svelte · HTML<ThemeToggle /> / actions snippetOptional actions at the end of the navigation bar.
brandContentSvelte snippetSveltebrandContent snippetSvelte snippet replacing plain brand text.
menuLabelstring"Navigation" / "Main navigation"React · Svelte · HTML"Accessible label"Accessible name for the mobile navigation toggle.
menuToggleLabelstring"Menu"React · Svelte · HTML"Accessible label"Accessible name announced by the disclosure control.
collapseAt"mobile" | "tablet" | "never""mobile"React · Svelte · HTML"tablet"Breakpoint where navigation moves into its disclosure menu.
menuVariant"floating" | "inline""floating"React · Svelte · HTML"floating"Chooses floating or in-flow disclosure-menu geometry.
surface"solid" | "translucent""solid"React · Svelte · HTML"translucent"Chooses solid or translucent navbar surface tokens.
open/defaultOpenboolean; controlled or initial statefalseReact · Svelte · HTMLtrueUse open/bind:open for controlled state or defaultOpen for initial state.
onOpenChange(open: boolean) => voidReact · Svelte · HTML{handleOpenChange}Reports every user-driven open state transition.
nav attributesnative element attributesReact · Svelte · HTMLclass / style / aria-* / data-*Forwards native class/style, accessibility, event, and data attributes to the root element.