Skip to content
Nacre
Color palette
中文

GrowMenu

experimentalGrowMenu · GrowMenuFooter · MenuMarkOpen in playground
GrowMenu
Runs the real component in your browser.

A menu that opens in place: a panel rises from the account row at the bottom of the sidebar, its bottom row (GrowMenuFooter) sitting exactly over the trigger row with the same content; it appears at once and fades out on close, without morphing. Items can carry a presence dot, an icon, a text mark and a submenu.

Status: experimental · Components: GrowMenu, GrowMenuFooter, MenuMark

import { GrowMenu, GrowMenuFooter, MenuMark } from 'nacre'

left / bottom / width place and size the panel in the window, with its bottom edge aligned to the trigger row; footer shows the same content as the trigger row.

import { signal } from 'nsh'
import type { ViewRef } from 'nsh'
import { Avatar, Button, GrowMenu, GrowMenuFooter } from 'nacre'
export function GrowMenuUsage() {
const open = signal(false)
/** 键盘(Enter / Space)打开时菜单焦点落到第一行 */
const byKeyboard = signal(false)
let trigger: ViewRef | undefined
return (
<>
<Button viewRef={(node) => (trigger = node)} variant="outline" pressed={open()} expanded={open()} onPress={(e) => {
byKeyboard.set(e.clickCount === 0)
open.set(!open())
}}>
Open account menu
</Button>
<GrowMenu
testID="demo-grow"
returnFocus={() => trigger}
focusFirst={byKeyboard()}
open={open()}
onClose={() => open.set(false)}
left={24}
bottom={24}
width={240}
items={[
{ type: 'heading', label: 'Online · 4 chats' },
{ label: 'Online', presence: 'online', checked: true, onSelect: () => open.set(false) },
{ label: 'Break', presence: 'break', onSelect: () => open.set(false) },
{ type: 'separator' },
{
label: 'Appearance',
icon: 'sun-moon',
submenu: [
{ label: 'System', checked: true, onSelect: () => {} },
{ label: 'Light', onSelect: () => {} },
{ label: 'Dark', onSelect: () => {} },
],
},
{ label: 'Log out', icon: 'logout', destructive: true, onSelect: () => open.set(false) },
]}
footer={
<GrowMenuFooter
leading={<Avatar name="Zhiyuan" self size={28} />}
title="Zhiyuan"
subtitle="Online · 00:12:40"
onPress={() => open.set(false)}
/>
}
/>
</>
)
}

When the sidebar shows icons only, the panel keeps the menu width (it does not shrink to the trigger button); MenuMark renders the leading icon, presence dot, swatch or text mark. The submenu items use a text mark for each language, and the footer’s second line uses subtitleTone=“warning” to flag a lost connection.

import { signal } from 'nsh'
import type { ViewRef } from 'nsh'
import { Avatar, Button, GrowMenu, GrowMenuFooter } from 'nacre'
export function GrowMenuCollapsed() {
const open = signal(false)
/** 键盘(Enter / Space)打开时菜单焦点落到第一行 */
const byKeyboard = signal(false)
const lang = signal('zh-CN')
let trigger: ViewRef | undefined
const pick = (value: string) => {
lang.set(value)
open.set(false)
}
return (
<>
<Button viewRef={(node) => (trigger = node)} variant="outline" pressed={open()} expanded={open()} onPress={(e) => {
byKeyboard.set(e.clickCount === 0)
open.set(!open())
}}>
Open from the collapsed sidebar
</Button>
<GrowMenu
returnFocus={() => trigger}
focusFirst={byKeyboard()}
open={open()}
onClose={() => open.set(false)}
left={24}
bottom={24}
width={240}
items={[
{
label: 'Language',
icon: 'translate',
submenu: [
{ label: '简体中文', mark: '简', checked: lang() === 'zh-CN', onSelect: () => pick('zh-CN') },
{ label: '繁體中文', mark: '繁', checked: lang() === 'zh-HK', onSelect: () => pick('zh-HK') },
{ label: 'English', mark: 'EN', checked: lang() === 'en', onSelect: () => pick('en') },
],
},
{ type: 'separator' },
{ label: 'Log out', icon: 'logout', destructive: true, onSelect: () => open.set(false) },
]}
footer={
<GrowMenuFooter
leading={<Avatar name="Zhiyuan" self size={28} />}
title="Zhiyuan"
subtitle="Connection lost, reconnecting…"
subtitleTone="warning"
onPress={() => open.set(false)}
/>
}
/>
</>
)
}
Key Action
↑ ↓ Move through available menu items and the footer, wrapping at the ends. Skip disabled items and collapsed children.
Home / End Go to the first available item or the footer
Space / Return Choose the current row; a row with a submenu expands or collapses in place
Esc Close and return focus to the entry point (returnFocus)
  • MenuMark draws the leading presence dot, icon, color swatch or language mark. The menu item supplies its accessible name.
  • The panel’s role is menu; checked items read as checked, and rows with a submenu read as expanded / collapsed.
  • GrowMenuFooter is a button whose screen reader name defaults to title; override it with accessibilityLabel.
  • Always pass returnFocus: after closing, keyboard focus returns to the entry point (WCAG 2.4.3).

Do

  • Return focus to the entry point on close (returnFocus)
  • Set heading explicitly for group titles; longer notes (error reasons) are headings too and wrap
  • Expand only one submenu at a time (the component enforces this)
  • Set keepOpen on toggles people tick several of in a row

Don’t

  • Use it as a regular dropdown (use DropdownMenu)
  • Use it when there is no room above the entry point (the panel only grows upward)

Property descriptions follow the Chinese source comments.

Prop Type Default Description
open * boolean —
onClose * () => void —
items * readonly GrowMenuEntry[] —
footer * JSX.Element — 面板底部那一行:与触发行同一个位置、同一个内容,按下收起
left * number — 面板在窗口里的位置(左、下)与宽度:底边对齐触发行,向上长
bottom * number —
width * number —
testID string —
returnFocus () => ViewRef | undefined — 收起后把键盘焦点交还的触发元素(WCAG 2.4.3:焦点回到触发点,与 DropdownMenu 一致)
focusFirst boolean — 打开后把焦点放到第一个可用行(显示当前行):键盘(Enter / Space,PressEvent.clickCount === 0)打开时给 true, 同 DropdownMenu;指针打开时不给,macOS 菜单不预先高亮(2026-11-27 组件交互复评:键盘打开后看不到当前行)

* required

Prop Type Default Description
leading * JSX.Element — 行首:和触发行同一个头像 / 图标(28)
title * string —
subtitle string —
subtitleTone 'muted' | 'warning' — 副行的语气:warning 是连接中断这类要注意的状态
onPress * () => void — 按下收起菜单
accessibilityLabel string —
testID string —

* required

Prop Type Default Description
item * MarkedItem —

* required