Components · engine.menu-item · version 0.1.0
Menu Item
One command in a menu.
Preview
Every variant in every state, drawn by the same definition that the Figma sync and the tests use.
| Component | rest | disabled | active | active, disabled |
|---|---|---|---|---|
| menuItem |
Install
npm install @uiuxengine/reactComponents come from npm and stay identical to their definition and their Figma component. See Installation.
Usage
import { MenuItem } from "@uiuxengine/react";
export function Example() {
return (
<MenuItem label="Menu item" value="value" />
);
}Guidelines
- Use only inside a menu.
- Labels are short verbs or verb phrases, for example 'Duplicate'. End with an ellipsis when the command asks for more before it runs, for example 'Rename…'.
- Values are unique within a menu and stay the same when labels change; the menu reports the value of the item that was pressed.
- Disable an item that can't run now rather than removing it. It stays focusable, so people still find it and hear that it's unavailable.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
value required | text, up to 200 | — | Identifies the item. The menu's itemPress reports it. |
label required | text, up to 120 | — | The text people read. |
disabled | boolean | false | Shown and focusable, but pressing it does nothing. |
Accessibility
- Renders a native <button> with the role
menuitem. disabledis announced asaria-disabled.
As a spec
Agents describe interfaces as JSON specs. A spec renders only after it validates against the installed contracts, the approved icons and the host's actions. Edit it to see. Menu Items render in a Menu, so this spec has some in one.
No actions yet.
JSON Schema of the props
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "urn:uiuxengine:component:engine.menu-item@0.1.0",
"title": "menuItem",
"description": "One command in a menu.",
"type": "object",
"properties": {
"value": {
"description": "Identifies the item. The menu's itemPress reports it.",
"type": "string",
"maxLength": 200
},
"label": {
"description": "The text people read.",
"type": "string",
"maxLength": 120
},
"disabled": {
"description": "Shown and focusable, but pressing it does nothing.",
"type": "boolean",
"default": false
}
},
"required": [
"value",
"label"
],
"additionalProperties": false,
"$defs": {
"iconRef": {
"type": "object",
"description": "A reference to an icon in the host's approved catalog.",
"properties": {
"type": {
"const": "icon"
},
"id": {
"type": "string",
"pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
},
"style": {
"type": "string",
"pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
},
"weight": {
"type": "string",
"pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
}
},
"required": [
"type",
"id"
],
"additionalProperties": false
}
}
}