Right-click anywhere
The shadcn demo: back, forward and reload with keycaps, a sub-menu, ticked rows and a radio group. The slip opens where you clicked (or press the menu key on the focused note).
The right-click menu, written on the same slip of paper as the dropdown and set down where the pointer was. Highlighter rows, drawn keycaps, pencil boxes and felt ticks, a red pencil hatch for what deletes. It opens on a right click, a long press on touch, or the menu key, and pops in where the pointer was.
npx shadcn@latest add @wobko/context-menu第一次使用?先把 registry 加进 components.json。 如何安装
The shadcn demo: back, forward and reload with keycaps, a sub-menu, ticked rows and a radio group. The slip opens where you clicked (or press the menu key on the focused note).
asChild makes each row its own region, so the menu knows which row you clicked. The chosen row is remembered below the list; rows are focusable, so the menu key works from the keyboard.
A composed use: right-click a sticky note to choose the pen it is written with. The menu is a second sticky, in another color so it reads as its own note, taped down; the radio rows tick the choice.
The slip: a Paper that is also the Radix content (role=menu), opened at the pointer. A CSS sheet with no SVG unless a torn edge is asked for; rows scroll in a viewport inside it so the shadow is not cut. `max-h-*`, `overflow-*` and `overscroll-*` in `className` are applied to that viewport (shadcn code writes them on the content), the rest stays on the slip. Every Radix Content prop passes through.
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| stock | StockName | "slip" | What it is made of: slip, paper, kraft, sticky-*, index-card ... |
| edge | EdgeSpec | "cut" | Cut (pure CSS), torn, deckle ... |
| tilt | boolean | number | true | Small seeded tilt of the sheet; text stays upright. |
| tape | "corner" | "top" | "both" | false | false | Strips of masking tape holding the slip down. |
| seed | string | number | - | Pins the hand. |
A heading in the typewriter.
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| inset | boolean | false | Lines the text up with rows that carry a tick or an icon. |
A row; the highlighter is a CSS background, so it costs no ink.
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| inset | boolean | false | Lines the text up with rows that carry a tick or an icon. |
| variant | "default" | "destructive" | "default" | Destructive is red, and its highlight is a red pencil hatch. |
| onSelect | (event: Event) => void | - | Runs when it is chosen; `event.preventDefault()` keeps the menu open. |
A pencil box at the start of the row, ticked in blue felt when `checked`.
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| checked | boolean | 'indeterminate' | - | Controlled state. |
| onCheckedChange | (checked: boolean) => void | - | Called when toggled. |
One choice: a pencil ring with a bold felt dot in the chosen one.
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| value | string | - | The value this row stands for. |
The row that opens it, with a hand-drawn chevron; it keeps the highlighter while its sub-menu is open.
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| inset | boolean | false | Lines the text up with rows that carry a tick or an icon. |
CLI 会复制进你项目的文件。
正在加载源码