Skip to content
Back

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-menu
MCP
Dioxus
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),
    }
}

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.

Terminal
cargo install --git https://github.com/ismailqureshi72/Oxyn oxyn-cli
oxyn init
oxyn add dropdown-menu
Rust
use 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

Dioxus · rust
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.

Right-click this message (or Shift+F10)
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

PropTypeDefaultDescription
itemsrequiredVec<MenuItem>—Rows.
triggerString"Options"Trigger label (ignored in context mode).
iconOption<String>Default::default()Trigger icon.
alignString"start"`start` · `end`.
sideString"bottom"`bottom` · `top`.
titleOption<String>Default::default()Heading row.
widthOption<f32>Default::default()Width px.
emptyString"Nothing here yet"Empty text.
openboolDefault::default()Start open.
highlightOption<usize>Default::default()Review sheets: highlight row `i` (and open its submenu when it has one).
searchableboolDefault::default()Filter field.
densityString"comfortable"`compact` · `comfortable`.
contextboolDefault::default()Context-menu mode: wraps `children` and opens on right-click / Shift+F10.
childrenElementDefault::default()Wrapped content in context mode.
nowClockMsDefault::default()Clock (type-ahead window).
on_actionEventHandler<String>—An action ran.
on_toggleEventHandler<(String, bool)>—A checkbox / radio row changed.
on_open_changeEventHandler<bool>—Open state changed.

Read from the Rust signature and doc comments.

Keyboard interactions

KeyAction
EnterorSpaceor↓Open on the first item (↑ opens on the last)
↑or↓orHomeorEndMove
→or←Open / close a submenu
TypeJump to the next item starting with that letter
EnterorSpaceRun, check or pick
EscorTabClose
ShiftF10orContextMenuOpen 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
TransitionDurationDelayEasingReduced motion
Open180 ms, scale 0.960ease.out80 ms fade
Close120 ms0ease.in80 ms
Row stagger20 ms per row, cap 80 ms—ease.outnone
Highlight glide (pointer)214 ms0spring.snapjump
Highlight (keyboard)jump0—jump
Submenu open on hover140 ms fade80 ms intentease.outinstant
Check draw / dot pop240 / 200 ms0ease.outdrawn
Type-ahead window500 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 DropdownMenu from oxyn_dioxus and include PRIMITIVES_CSS plus the token stylesheet once.
  • A GPUI version exists: MenuEl in oxyn_gpui.
  • Props to set first: items.
  • Keep its states and timings as they ship; restyle it through the CSS variables rather than by hand.

Guides

Oxyn · 74 free components · 264 Pro components · 96 screens · 20 blocks · Dioxus and GPUI