@molecule/app-header-solid

Feature · header · App (browser) · v1.2.3 · Apache-2.0

Top app-shell header: branded logo + appName on the left, slotted actions (theme toggle, user menu, extras) on the right

npm install @molecule/app-header-solid

npm · Source on GitHub

How it works

@molecule/app-header-solid is a ready-made header feature for the app (browser) side. It composes the core interfaces it needs, so it works with whichever providers your app has bonded.

import { AppHeader } from '@molecule/app-header-solid'
import { UserMenu } from '@molecule/app-ui-solid'

function Shell() {
  return (
    <AppHeader
      appName="Bearing"
      userMenu={
        <UserMenu>
          <div>Your settings panel here</div>
        </UserMenu>
      }
    />
  )
}

Works with: @molecule/app-solid, @molecule/app-ui, @molecule/app-ui-solid

Reference

Top app-shell header — branded logo + appName on the left, slotted actions (theme toggle, extra actions, user menu) on the right.

The Solid counterpart of @molecule/app-header-react — the same props and the same DOM for the same input, with the brand link wired to the @molecule/app-solid router instead of react-router. Pair with @molecule/app-shell-layout-solid's <AppShellLayout> to assemble a full chrome.

Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit src/index.ts JSDoc, not this file.

Quick Start

import { AppHeader } from '@molecule/app-header-solid'
import { UserMenu } from '@molecule/app-ui-solid'

function Shell() {
  return (
    <AppHeader
      appName="Bearing"
      userMenu={
        <UserMenu>
          <div>Your settings panel here</div>
        </UserMenu>
      }
    />
  )
}

Type

feature

Installation

npm install @molecule/app-header-solid @molecule/app-solid @molecule/app-ui @molecule/app-ui-solid solid-js

API

Interfaces

AppHeaderNavigation

A primary navigation landmark with one link per declared destination.

interface AppHeaderNavigation {
  /** Accessible name for the navigation landmark. */
  label: string
  /**
   * Router destinations mapped to anchor props. Put a destination's icon and text in
   * the same children so they share one native link and one keyboard stop. The
   * anchor's class is `className`, as in React's entries.
   */
  links: Readonly<
    Record<
      string,
      | (Omit<LinkProps, 'to' | 'children' | 'class'> & {
          children: JSX.Element
          className?: string
        })
      | undefined
    >
  >
  /** Additional class on the native nav element. */
  className?: string
  /** Additional class on the links' list. */
  listClassName?: string
  /** Additional class on each list item. */
  itemClassName?: string
}

AppHeaderProps

Props for the AppHeader component.

interface AppHeaderProps {
  /** Brand display name shown next to the logo. */
  appName: string
  /** Logo image source. Defaults to `/logo.svg` (the convention scaffolded by mlcl). */
  logoSrc?: string
  /** Logo size in pixels (square). Defaults to 30 to match the flagship-app convention. */
  logoSize?: number
  /** Path the brand link navigates to. Defaults to `/`. */
  brandTo?: string
  /** Additional class on the brand anchor. */
  brandClassName?: string
  /** Primary destinations, such as public links or links for the current session. */
  navigation?: AppHeaderNavigation
  /** Slot for the right-side user menu — typically `<UserMenu />` from `@molecule/app-ui-solid`. */
  userMenu?: JSX.Element
  /**
   * Theme toggle slot. Defaults to a resilient wrapper around
   * `<ThemeToggle />` (from `@molecule/app-ui-solid`) that renders the toggle
   * ONLY when `@molecule/app-solid`'s `ThemeProvider` + `I18nProvider` are both
   * mounted above the header, and omits it (never throws) when they are not —
   * so the header renders out of the box even before theme/i18n are wired.
   * Pass `null` to force-hide it, or your own component (e.g. an icon-bonded
   * variant) to override.
   */
  themeToggle?: JSX.Element | null
  /** Optional extra actions rendered between the theme toggle and the user menu. */
  extraActions?: JSX.Element
  /**
   * Apply `cm.headerFixed` for sticky/fixed positioning. Defaults to `true`,
   * matching the flagship-app convention. Set to `false` for a non-sticky header.
   */
  fixed?: boolean
  /** Extra className on the outer `<header>` (composed with `cm.headerBar` + optional `cm.headerFixed`). */
  className?: string
  /** `data-mol-id` for AI-agent selectors. */
  dataMolId?: string
}

Functions

AppHeader(props)

Sticky top app-shell header — logo + appName on the left, slotted actions on the right. All visual styling routes through ClassMap tokens (cm.headerBar, cm.headerFixed, cm.headerInner, cm.logoText) so the bonded styling layer controls the visual treatment.

This is the Solid counterpart of @molecule/app-header-react: the same props (React names), the same ClassMap tokens, and the same DOM for the same input.

function AppHeader(props: AppHeaderProps): JSX.Element
  • props — Component props (see AppHeaderProps).

Returns: The rendered header.

Injection Notes

Requirements

Peer dependencies:

  • @molecule/app-solid ^3.14.0 || ^4.0.0
  • @molecule/app-ui ^1.0.1
  • @molecule/app-ui-solid ^1.1.0
  • solid-js ^1.8.0

Runtime Dependencies

  • @molecule/app-solid

  • @molecule/app-ui

  • @molecule/app-ui-solid

  • solid-js

  • Must render inside a MoleculeProvider whose config wires router — the brand link navigates through the binding's router and throws outside it.

  • The DEFAULT themeToggle slot renders <ThemeToggle /> (which calls useTheme() + useTranslation()) ONLY when @molecule/app-solid's theme + i18n services are both wired above the header — it probes their contexts first. Without them the toggle is silently OMITTED instead of throwing, so <AppHeader appName="…" /> renders out of the box; it lights up automatically once they are wired. Pass themeToggle={null} to force-hide it, or your own node to override.

  • fixed defaults to true (cm.headerFixed positions the header fixed): give the page content a matching top offset (flagships get it from <AppShellLayout>), or pass fixed={false} for an in-flow header.

  • logoSrc defaults to /logo.svg, the file mlcl scaffolds into public/.

  • Styling routes through ClassMap tokens (cm.headerBar, cm.headerFixed, cm.headerInner, cm.logoText) — requires a bonded ClassMap.