Menu is used to display a list of links vertically or horizontally. Supports icons, submenus, and collapsible sections.
Basic Example
Vertical menu with active state
await import('/components/navigation/menu.js');
const { signal, tags, $ } = Lightview;
const { Menu } = tags;
const active = signal('home');
const items = ['home', 'profile', 'settings', 'logout'];
const menu = Menu({ style: 'background-color: oklch(var(--b2)); border-radius: var(--rounded-box, 1rem); width: 14rem;' },
...items.map(item =>
Menu.Item({
active: () => active.value === item,
onclick: () => { active.value = item; }
}, item.charAt(0).toUpperCase() + item.slice(1))
)
);
$('#example').content(menu);
Horizontal Menu
Navigation bar style menu
await import('/components/navigation/menu.js');
const { signal, tags, $ } = Lightview;
const { Menu } = tags;
const current = signal('features');
const menu = Menu({ horizontal: true, style: 'background-color: oklch(var(--b2)); border-radius: var(--rounded-box, 1rem);' },
Menu.Item({
active: () => current.value === 'features',
onclick: () => { current.value = 'features'; }
}, '✨ Features'),
Menu.Item({
active: () => current.value === 'pricing',
onclick: () => { current.value = 'pricing'; }
}, '💰 Pricing'),
Menu.Item({
active: () => current.value === 'docs',
onclick: () => { current.value = 'docs'; }
}, '📚 Docs')
);
$('#example').content(menu);
Props
| Prop | Type | Default | Description |
|---|---|---|---|
horizontal |
boolean | false | Horizontal layout |
size |
string | - | 'xs' | 'sm' | 'md' | 'lg' |
Sub-components
| Component | Props | Description |
|---|---|---|
Menu.Item |
active, disabled | Menu list item (li with a inside) |
Menu.Title |
- | Section header |
Menu.Dropdown |
label, open | Collapsible submenu |