Component

Dropdown

安装 Installation

npx timkit add dropdown-menu --yes --framework react

用法 Usage

import { DropdownMenu } from "@/components/ui/dropdown-menu"

className 与 variant、size 可以一起用。字段以 timkit agent inspect dropdown-menu --json 的 props 为准。

示例

Examples

一次看一个示例。左侧按名称筛选,预览里可切换源码和框架。

15 / 15

Dropdown · Open edit menu · 01

Loading preview...

结构化 API

Structured API

与 UCS schema 对齐的 props、逻辑机与多框架运行时。

Component

dropdown-menu

Logic

zag / menu

Runtime Frameworks

Not declared

Supported Platforms

WebWeChat Mini Program

Configuration

PropTypeDefaultDescription
logic.provider*
enum (zag | native | none)
zagState and interaction provider used by this component.
logic.machine
string
menuUnderlying state machine identifier when provider is zag.
platforms*
array
Web, WeChat Mini ProgramPlatforms officially supported by this schema.
frameworks*
array
-Framework demos/code currently available in registry files.
dependencies
array
-Runtime package dependencies required by this registry item.
optionalPeerDependencies
array
-Optional peer dependencies used by this registry item.
registryDependencies
array
-Dependent Timkit registry components/hook entries.

Props

PropTypeDefaultDescription
disabled
boolean
falseWhen true, opening and selection are ignored.
open
boolean
-The controlled open state.
defaultOpen
boolean
-The default open state of the menu when uncontrolled.

Events

PropTypeDefaultDescription
onOpenChange
event
-Event handler called when the open state changes.

TypeScript

来自 TypeScript 导出。

PropTypeDefaultDescription
id
string
-Overlay visibility and positioning behavior for id.
onSelect
event
-Callback fired when an item is selected.

Slots

PropTypeDefaultDescription
default
slot
-The dropdown segments

Parts

PropTypeDefaultDescription
root*
root
-The dropdown container
trigger
part
-The toggle button
content
part
-The menu dropdown
item
part
-A standard menu item
checkboxItem
part
-A menu item with a checkbox
radioItem
part
-A menu item in a radio group
radioGroup
part
-A group for radio items
group
part
-A group of menu items
label
part
-A group label
separator
part
-A separator line
shortcut
part
-A keyboard shortcut hint
sub
part
-A submenu container
subTrigger
part
-A button to trigger a submenu
subContent
part
-The submenu dropdown
This API reference is generated from `/packages/core` component schemas to keep React/Vue/Weapp docs consistent.

该组件尚无扩展说明文档。

键盘与焦点

Keyboard

跨 React、Vue 与小程序共享的交互与可读名称约定。

  • ArrowDown opens the menu.
  • ArrowDown and ArrowUp move the highlighted item and skip a disabled item.
  • Home moves to the first enabled item.
  • End moves to the last.
  • A letter moves to the next enabled item whose label starts with that letter and does not select it.
  • A closed menu ignores that letter.
  • Enter selects it.
  • Escape closes the menu.
  • The trigger names the menu.
  • The trigger controls the menu.
  • The trigger is in the tab order unless it is disabled.
  • The highlighted item is visible as Item N of the item count.
  • A closed menu has no item status.
  • The highlighted item is in the tab order.
  • The other items are not.
  • On the mini program, the check mark beside a checkbox or radio item is not part of its name.
  • The shortcut is hidden from the item name.
  • In static HTML, the closed menu stays hidden and its content uses tabindex 0.
  • On the mini program, aria-controls is set only while the popup is open.
  • On the mini program, the open menu uses tabindex 0.

行为契约

Contract

props、默认值和运行时状态。

  • defaultOpen is the menu state when open is not controlled.