@molecule/app-header-vue
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-vueHow it works
@molecule/app-header-vue 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 { createApp, defineComponent, h } from 'vue'
import { moleculePlugin } from '@molecule/app-vue'
import { AppHeader } from '@molecule/app-header-vue'
import { UserMenu } from '@molecule/app-ui-vue'
const Shell = defineComponent({
setup() {
// UserMenu takes the settings panel as its DEFAULT SLOT (no renderPanel
// prop); panel content dismisses the drawer via usePanelClose().
return () =>
h(
AppHeader,
{ appName: 'Bearing' },
{
userMenu: () => [h(UserMenu, () => [h('div', 'Your settings panel here')])],
},
)
},
})
const app = createApp(Shell)
app.use(moleculePlugin, { theme: themeProvider, i18n: i18nProvider, router })
app.mount('#app')Works with: @molecule/app-ui, @molecule/app-ui-vue, @molecule/app-vue
Reference
Top app-shell header — branded logo + appName on the left, slotted actions (theme toggle, extra actions, user menu) on the right.
Vue counterpart of @molecule/app-header-react: the same props (React
names), the same DOM for the same input, the same ClassMap tokens and i18n
keys. Pair with @molecule/app-shell-layout-vue'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.tsJSDoc, not this file.
Quick Start
import { createApp, defineComponent, h } from 'vue'
import { moleculePlugin } from '@molecule/app-vue'
import { AppHeader } from '@molecule/app-header-vue'
import { UserMenu } from '@molecule/app-ui-vue'
const Shell = defineComponent({
setup() {
// UserMenu takes the settings panel as its DEFAULT SLOT (no renderPanel
// prop); panel content dismisses the drawer via usePanelClose().
return () =>
h(
AppHeader,
{ appName: 'Bearing' },
{
userMenu: () => [h(UserMenu, () => [h('div', 'Your settings panel here')])],
},
)
},
})
const app = createApp(Shell)
app.use(moleculePlugin, { theme: themeProvider, i18n: i18nProvider, router })
app.mount('#app')
Type
feature
Installation
npm install @molecule/app-header-vue @molecule/app-ui @molecule/app-ui-vue @molecule/app-vue vue
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 link props, the destination itself being
* the key. Any other anchor attribute (`class`, `target`, `rel`,
* `aria-*`, `onClick`) rides along as an attribute, as `Link` passes it to
* the anchor.
*/
links: Readonly<Record<string, AppHeaderNavigationLink | 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. When given, the header's inner element is a named `<nav>`
* landmark wrapping the brand and the actions, with one link per declared
* destination.
*/
navigation?: AppHeaderNavigation
/**
* Slot for the right-side user menu — typically `<UserMenu />` from
* `@molecule/app-ui-vue`. Passed as a prop or as the same-named slot — both
* work. `null` contributes nothing.
*/
userMenu?: VNodeChild | null
/**
* Theme toggle slot. Defaults to a resilient wrapper around
* `<ThemeToggle />` (from `@molecule/app-ui-vue`) that renders the toggle
* ONLY when the binding's theme and i18n providers are both installed 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. Passed as a prop or as the same-named slot — both work.
*/
themeToggle?: VNodeChild | null
/**
* Optional extra actions rendered between the theme toggle and the user
* menu. Passed as a prop or as the same-named slot — both work. `null`
* contributes nothing.
*/
extraActions?: VNodeChild | null
/**
* 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
}
Constants
AppHeader
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.logoText) so the bonded styling
layer controls the visual treatment.
Vue counterpart of @molecule/app-header-react's AppHeader — the same
props (React names), the same DOM for the same input.
const AppHeader: DefineComponent<
ExtractPropTypes<{
appName: { type: StringConstructor; required: true }
logoSrc: { type: StringConstructor; default: string }
logoSize: { type: NumberConstructor; default: number }
brandTo: { type: StringConstructor; default: string }
brandClassName: StringConstructor
navigation: PropType<AppHeaderNavigation>
userMenu: null
themeToggle: null
extraActions: null
fixed: { type: BooleanConstructor; default: boolean }
className: StringConstructor
dataMolId: StringConstructor
}>,
() => VNodeChild,
{},
{},
{},
ComponentOptionsMixin,
ComponentOptionsMixin,
{},
string,
PublicProps,
Readonly<
ExtractPropTypes<{
appName: { type: StringConstructor; required: true }
logoSrc: { type: StringConstructor; default: string }
logoSize: { type: NumberConstructor; default: number }
brandTo: { type: StringConstructor; default: string }
brandClassName: StringConstructor
navigation: PropType<AppHeaderNavigation>
userMenu: null
themeToggle: null
extraActions: null
fixed: { type: BooleanConstructor; default: boolean }
className: StringConstructor
dataMolId: StringConstructor
}>
> &
Readonly<{}>,
{ logoSrc: string; logoSize: number; brandTo: string; fixed: boolean },
{},
{},
{},
string,
ComponentProvideOptions,
true,
{},
any
>
props— Component props (seeAppHeaderProps).
Returns: The header component.
Injection Notes
Requirements
Peer dependencies:
@molecule/app-ui^1.0.1@molecule/app-ui-vue^1.1.0@molecule/app-vue^3.13.0 || ^4.0.0vue^3.4.0
Runtime Dependencies
-
@molecule/app-ui -
@molecule/app-ui-vue -
@molecule/app-vue -
vue -
Must render inside the binding's router plugin — the brand link navigates through
useRouter()and throws outside it. -
The DEFAULT
themeToggleslot renders<ThemeToggle />(which callsuseTheme()+useTranslation()) ONLY when the binding's theme and i18n plugins are both installed above the header — it probes their injection keys withinject(Key, null)first. Without those providers the toggle is silently OMITTED instead of throwing, so<AppHeader appName="…" />renders out of the box; it lights up automatically once they are wired. PassthemeToggle={null}to force-hide it, or your own node to override. -
Node-valued props (
userMenu,themeToggle,extraActions) arrive as a prop AND a same-named slot; components accept either. -
Give
navigationthe destinations available in the current view or session: the header's inner element becomes a named<nav>landmark wrapping the brand and the actions, with one link per destination. Group an avatar or icon with its label in that link's children, and usebrandClassNameand the navigation classes with the app's stylesheet. -
fixeddefaults totrue(cm.headerFixedpositions the header fixed): give the page content a matching top offset (flagships get it from<AppShellLayout>), or passfixed={false}for an in-flow header. -
logoSrcdefaults to/logo.svg, the file mlcl scaffolds intopublic/. -
Styling routes through ClassMap tokens (
cm.headerBar,cm.headerFixed,cm.headerInner,cm.logoText) — requires a bonded ClassMap.