Dropdown Menu
Actions and choices behind any trigger: icons, shortcuts, checks and radios, red items and submenus, a gliding highlight, type-ahead, search and a context-menu mode.
oxyn add dropdown-menulet items = vec![
MenuItem::action("rename", "Rename").icon("pencil").shortcut("Mod+R"),
MenuItem::submenu("move", "Move to", vec![MenuItem::action("archive", "Archive")]),
MenuItem::divider(),
MenuItem::checkbox("wrap", "Wrap long lines", true),
MenuItem::radio("fast", "Fast model", "model", true),
MenuItem::divider(),
MenuItem::action("del", "Delete thread").icon("trash").danger(),
];
rsx! {
DropdownMenu {
items: items,
trigger: "Thread",
icon: "thread",
title: "Thread actions",
on_action: move |id: String| run(id),
}
}Rendered from Rust at build time · goes live when visible
When to use
- Actions and choices behind a trigger: thread actions, "Move to", model and view options, a right-click menu on a message or file.
- Agent apps put a lot here (rename, branch, export, delete), so it must be fast from the keyboard and calm under the pointer.
When not to use
- A main action with a menu of alternatives: use Split button instead.
- Pick one option in the text field's look: use Select instead.
- Choose which tools the agent may use: use Tools menu instead.
Installation
Dropdown Menu is free and MIT. The oxyn CLI copies its code, and the components it needs, into src/oxyn/ of your Dioxus or GPUI project, so it is yours to change.
cargo install --git https://github.com/ismailqureshi72/Oxyn oxyn-cli
oxyn init
oxyn add dropdown-menuuse crate::oxyn::{DropdownMenu, PRIMITIVES_CSS};Rather depend on the crate? cargo add oxyn-dioxus oxyn-core --git https://github.com/ismailqureshi72/Oxyn, then use oxyn_dioxus::{DropdownMenu, PRIMITIVES_CSS};
Usage
let items = vec![
MenuItem::action("rename", "Rename").icon("pencil").shortcut("Mod+R"),
MenuItem::submenu("move", "Move to", vec![MenuItem::action("archive", "Archive")]),
MenuItem::divider(),
MenuItem::checkbox("wrap", "Wrap long lines", true),
MenuItem::radio("fast", "Fast model", "model", true),
MenuItem::divider(),
MenuItem::action("del", "Delete thread").icon("trash").danger(),
];
rsx! {
DropdownMenu {
items: items,
trigger: "Thread",
icon: "thread",
title: "Thread actions",
on_action: move |id: String| run(id),
}
}Examples
Menu
Every row type.
Code
let items = vec![
MenuItem::action("rename", "Rename").icon("pencil").shortcut("Mod+R"),
MenuItem::submenu("move", "Move to", vec![MenuItem::action("archive", "Archive")]),
MenuItem::divider(),
MenuItem::checkbox("wrap", "Wrap long lines", true),
MenuItem::radio("fast", "Fast model", "model", true),
MenuItem::divider(),
MenuItem::action("del", "Delete thread").icon("trash").danger(),
];
rsx! {
DropdownMenu {
items: items,
trigger: "Thread",
icon: "thread",
title: "Thread actions",
on_action: move |id: String| run(id),
}
}Searchable compact
A filter field, compact rows.
Code
let items = vec![
MenuItem::action("rename", "Rename").icon("pencil").shortcut("Mod+R"),
MenuItem::submenu("move", "Move to", vec![MenuItem::action("archive", "Archive")]),
MenuItem::divider(),
MenuItem::checkbox("wrap", "Wrap long lines", true),
MenuItem::radio("fast", "Fast model", "model", true),
MenuItem::divider(),
MenuItem::action("del", "Delete thread").icon("trash").danger(),
];
rsx! {
DropdownMenu {
items: items,
trigger: "Thread",
icon: "thread",
searchable: true,
density: "compact",
on_action: move |id: String| run(id),
}
}Context
Opens on right-click.
Code
let items = vec![
MenuItem::action("rename", "Rename").icon("pencil").shortcut("Mod+R"),
MenuItem::submenu("move", "Move to", vec![MenuItem::action("archive", "Archive")]),
MenuItem::divider(),
MenuItem::checkbox("wrap", "Wrap long lines", true),
MenuItem::radio("fast", "Fast model", "model", true),
MenuItem::divider(),
MenuItem::action("del", "Delete thread").icon("trash").danger(),
];
rsx! {
DropdownMenu {
items: items,
context: true,
div { "Right-click this message" }
on_action: move |id: String| run(id),
}
}Empty
Nothing to show.
Code
let items = vec![
MenuItem::action("rename", "Rename").icon("pencil").shortcut("Mod+R"),
MenuItem::submenu("move", "Move to", vec![MenuItem::action("archive", "Archive")]),
MenuItem::divider(),
MenuItem::checkbox("wrap", "Wrap long lines", true),
MenuItem::radio("fast", "Fast model", "model", true),
MenuItem::divider(),
MenuItem::action("del", "Delete thread").icon("trash").danger(),
];
rsx! {
DropdownMenu {
items: items,
trigger: "Thread",
icon: "thread",
on_action: move |id: String| run(id),
}
}API reference
DropdownMenu
| Prop | Type | Default | Description |
|---|---|---|---|
itemsrequired | Vec<MenuItem> | — | Rows. |
trigger | String | "Options" | Trigger label (ignored in context mode). |
icon | Option<String> | Default::default() | Trigger icon. |
align | String | "start" | `start` · `end`. |
side | String | "bottom" | `bottom` · `top`. |
title | Option<String> | Default::default() | Heading row. |
width | Option<f32> | Default::default() | Width px. |
empty | String | "Nothing here yet" | Empty text. |
open | bool | Default::default() | Start open. |
highlight | Option<usize> | Default::default() | Review sheets: highlight row `i` (and open its submenu when it has one). |
searchable | bool | Default::default() | Filter field. |
density | String | "comfortable" | `compact` · `comfortable`. |
context | bool | Default::default() | Context-menu mode: wraps `children` and opens on right-click / Shift+F10. |
children | Element | Default::default() | Wrapped content in context mode. |
now | ClockMs | Default::default() | Clock (type-ahead window). |
on_action | EventHandler<String> | — | An action ran. |
on_toggle | EventHandler<(String, bool)> | — | A checkbox / radio row changed. |
on_open_change | EventHandler<bool> | — | Open state changed. |
Read from the Rust signature and doc comments.
Keyboard interactions
| Key | Action |
|---|---|
| EnterorSpaceor↓ | Open on the first item (↑ opens on the last) |
| ↑or↓orHomeorEnd | Move |
| →or← | Open / close a submenu |
| Type | Jump to the next item starting with that letter |
| EnterorSpace | Run, check or pick |
| EscorTab | Close |
| ShiftF10orContextMenu | Open in context-menu mode |
Accessibility
- role=menu with menuitem, menuitemcheckbox and menuitemradio rows.
- Disabled items stay readable and are skipped by the keyboard.
- Shortcuts are spelled out for screen readers.
From the spec
role=menu with roving focus (the menu element holds focus; rows are tabindex=-1), full WAI menu keyboard, type-ahead, aria-checked on choice rows, aria-haspopup + aria-expanded on submenu rows and on the trigger. Esc restores focus to the trigger; Tab closes and moves on.
Motion & interaction
- The menu fades and scales in (0.96 → 1) from the corner it is attached to; submenus fade in beside their item; rows fade in with a short stagger (Arc).
- One highlight glides between rows for the pointer (
spring.snap) and jumps for the keyboard (Arc); red-tinted on a danger row. - The check on a choice draws itself; the radio dot pops in.
- Context mode grows from the pointer even when clamped away from an edge; reopening fades the old menu out in place (Arc).
Timing
| Transition | Duration | Delay | Easing | Reduced motion |
|---|---|---|---|---|
| Open | 180 ms, scale 0.96 | 0 | ease.out | 80 ms fade |
| Close | 120 ms | 0 | ease.in | 80 ms |
| Row stagger | 20 ms per row, cap 80 ms | — | ease.out | none |
| Highlight glide (pointer) | 214 ms | 0 | spring.snap | jump |
| Highlight (keyboard) | jump | 0 | — | jump |
| Submenu open on hover | 140 ms fade | 80 ms intent | ease.out | instant |
| Check draw / dot pop | 240 / 200 ms | 0 | ease.out | drawn |
| Type-ahead window | 500 ms | — | — | — |
Responsive behaviour
- align end keeps it inside the right edge; compact density for dense apps.
Edge cases (spec)
Long labels: the menu widens to content up to 340 px, then labels ellipsize (shortcuts never truncate). Menus near the bottom open upward (placement::place). Submenus near the right edge open to the left. A filter with no matches shows the empty text and keeps the field. Activating a disabled row (pointer) does nothing. Items changing while open keep the highlight on the same index if it is still focusable.
Notes for AI
- Import
DropdownMenufromoxyn_dioxusand includePRIMITIVES_CSSplus the token stylesheet once. - A GPUI version exists:
MenuElinoxyn_gpui. - Props to set first:
items. - Keep its states and timings as they ship; restyle it through the CSS variables rather than by hand.