@molecule/app-top-nav-layout-vue
Feature · top-nav-layout · App (browser) · v1.2.2 · Apache-2.0
Top navigation app shell: brand link + horizontal NavLinks + UserMenu slot, with a router outlet for nested routes
npm install @molecule/app-top-nav-layout-vueHow it works
@molecule/app-top-nav-layout-vue is a ready-made top-nav-layout feature for the app (browser) side. It composes the core interfaces it needs, so it works with whichever providers your app has bonded.
import { defineComponent, h } from 'vue'
import { TopNavLayout, type TopNavItem } from '@molecule/app-top-nav-layout-vue'
const NAV: TopNavItem[] = [
{ key: 'dashboard', to: '/dashboard', icon: 'dashboard', label: 'Dashboard' },
{ key: 'reports', to: '/reports', icon: 'bar_chart', label: 'Reports' },
]
// The layout route's component: its `<main>` renders the matched child route.
export const Shell = defineComponent({
setup() {
return () =>
h(TopNavLayout, {
appName: 'Acme',
navItems: NAV,
userMenu: h('button', { type: 'button' }, 'Account'),
})
},
})Works with: @molecule/app-ui, @molecule/app-ui-vue, @molecule/app-vue
Reference
Vue top navigation app shell layout for routed Vue apps.
Exports <TopNavLayout> — sticky header with brand link + horizontal
router links + a user-menu slot, plus the <main> holding the routed page
body — and the TopNavItem / TopNavLayoutProps types. It is the Vue
counterpart of @molecule/app-top-nav-layout-react: the same props (React
names) and the same DOM for the same input.
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 { defineComponent, h } from 'vue'
import { TopNavLayout, type TopNavItem } from '@molecule/app-top-nav-layout-vue'
const NAV: TopNavItem[] = [
{ key: 'dashboard', to: '/dashboard', icon: 'dashboard', label: 'Dashboard' },
{ key: 'reports', to: '/reports', icon: 'bar_chart', label: 'Reports' },
]
// The layout route's component: its `<main>` renders the matched child route.
export const Shell = defineComponent({
setup() {
return () =>
h(TopNavLayout, {
appName: 'Acme',
navItems: NAV,
userMenu: h('button', { type: 'button' }, 'Account'),
})
},
})
Type
feature
Installation
npm install @molecule/app-top-nav-layout-vue @molecule/app-ui @molecule/app-ui-vue @molecule/app-vue vue
API
Interfaces
TopNavItem
A single navigation item rendered in the top nav bar.
interface TopNavItem {
/** Route path the link goes to. */
to: string
/** Stable key — used to key the rendered link and as the i18n key suffix in apps. */
key: string
/** Material symbol icon name (or any glyph) shown next to the label. */
icon?: string
/** Visible label. Apps that route this through `t(...)` should pass the resolved string. */
label: string
}
TopNavLayoutProps
Props accepted by the TopNavLayout component.
interface TopNavLayoutProps {
/** Brand text shown in the top-left link (typically the app name). */
appName: string
/** Path the brand link navigates to. Defaults to `'/'`. */
logoTo?: string
/** Horizontal nav items rendered in the header. */
navItems: ReadonlyArray<TopNavItem>
/**
* Node rendered at the right of the header (typically a user menu). Passed
* as a prop or as the same-named slot — both work.
*/
userMenu?: VNodeChild
/**
* Aria-label for the primary `<nav>`. Overrides the translated /
* `defaultValue` `'Primary navigation'` (prop > `t()` > default).
*/
navAriaLabel?: string
/** Extra classes on the outer wrapper. */
className?: string
/** `data-mol-id` for AI-agent selectors. */
dataMolId?: string
/**
* The routed page body — the DEFAULT slot. React renders its router's
* `<Outlet />` here; pass the routed view (`<RouterView />`) or any content.
*/
children?: VNodeChild
}
Constants
TopNavLayout
Sticky top-nav shell with brand + horizontal nav + user-menu slot.
The page body comes from the default slot, where React renders React
Router's <Outlet />. Nav labels are hidden below the md breakpoint
(icon-only mobile nav), so always provide icon names; they render as
Material Symbols ligatures and need the Material Symbols font loaded by the
host app. label is rendered as-is: pass an already-translated string.
const TopNavLayout: DefineComponent<
ExtractPropTypes<{
appName: { type: StringConstructor; required: true }
logoTo: { type: StringConstructor; default: string }
navItems: { type: PropType<ReadonlyArray<TopNavItem>>; required: true }
userMenu: null
navAriaLabel: StringConstructor
className: StringConstructor
dataMolId: StringConstructor
}>,
() => VNode,
{},
{},
{},
ComponentOptionsMixin,
ComponentOptionsMixin,
{},
string,
PublicProps,
Readonly<
ExtractPropTypes<{
appName: { type: StringConstructor; required: true }
logoTo: { type: StringConstructor; default: string }
navItems: { type: PropType<ReadonlyArray<TopNavItem>>; required: true }
userMenu: null
navAriaLabel: StringConstructor
className: StringConstructor
dataMolId: StringConstructor
}>
> &
Readonly<{}>,
{ logoTo: string },
{},
{},
{},
string,
ComponentProvideOptions,
true,
{},
any
>
props— Component props (seeTopNavLayoutProps).
Returns: The top navigation layout component.
Injection Notes
Requirements
Peer dependencies:
@molecule/app-ui^1.3.11@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-vuevue
Render it as a LAYOUT ROUTE component: without a default slot the <main>
renders RoutedView from @molecule/app-vue (the matched child route,
through the app's routing bond), as React's renders its children or
<RoutedView />; a default slot takes its place. Nav labels are hidden below the
md breakpoint (icon-only mobile nav), so always provide icon names; they
render as Material Symbols ligatures and need the Material Symbols font
loaded by the host app. Styling comes from the bonded ClassMap, so a
theme/ClassMap bond is a prerequisite. Node-valued props (userMenu) arrive
as a prop AND a same-named slot; the component accepts either. label is
rendered as-is: pass an already-translated string.
Translations
Translation strings are provided by @molecule/app-locales-top-nav-layout.