PathLogs UI
Русский

Components

Menu

A fold for secondary actions with a dropdown panel.

A fold for secondary actions: a «More» button and a dropdown panel. You put ready-made buttons inside as they are — they need to know nothing about the menu.

Example

An entry with href renders as a link rather than a button — so that Ctrl+click and «open in new tab» work.

Dialogs inside a menu

The most common scenario: a menu item opens a modal. The naive implementation breaks right here.

tsx
<Menu>
  <MenuItem onClick={() => setOpen(true)}>Delete project</MenuItem>
  <ConfirmDialog open={open} onConfirm={remove} onCancel={() => setOpen(false)} />
</Menu>

Your own button

The default button is three dots with a caption. If you need a different one, pass a trigger: it receives the open state and a toggle.

tsx
<Menu
  trigger={({ open, toggle }) => (
    <Button variant={open ? "primary" : "secondary"} onClick={toggle}>
      Actions {open ? "▲" : "▼"}
    </Button>
  )}
>
  <MenuItem onClick={…}>…</MenuItem>
</Menu>

Props

children*ReactNode

The panel's contents.

labelstring

defaults to: "More"

The button caption. Hidden on narrow screens, leaving the icon.

trigger(props: { open, toggle }) => ReactNode

Your own button instead of the default one.

countnumber

How many actions are hidden — as a number on the button.

align"start" | "end"

defaults to: "end"

Which side the panel drops from.

tipstring

A tooltip on the button.

MenuItem takes onClick or href, icon, tone (default or danger) and disabled.