ActionMenu draws a list of actions as a dropdown menu, with groups as submenus. Its child is the button that opens
it.
An action is a label, an icon and the function it runs. You build the list with MenuBuilder and
useMenuBuilder. Because the list is data, other code can add to it. This is how PLEX plugins add items to each
other’s menus.
The actions live in an atom.
Wrap your app in RegistryProvider from @effect/atom-react. This is best practice, because your app then controls
the registry that the menu reads. Without a provider, the menu reads the library’s default registry.
Add the package’s strings from @dxos/react-ui-menu/translations to the resourceExtensions of Theme.Provider.
Convenience wrapper around useMenuActions that creates the backing atom inline.
Pass a builder thunk and a dependency list — the hook memoizes Atom.make(build) and threads
it through useMenuActions. Saves the useMemo(() => Atom.make(...), deps) boilerplate when
the action graph is composed from local state (e.g. a toolbar driven by component state).
Read reactive state via get inside the builder; deps should hold only stable references.
useMenuBuilder } from'@dxos/react-ui-menu';
3
import*as
import Button
Buttonfrom'@dxos/react-ui/Button';
4
import*as
import Typography
Typographyfrom'@dxos/react-ui/Typography';
5
6
/** A dropdown menu built from actions, opened by the button you pass as its child. */
7
exportconst
constRowMenu: () =>React.JSX.Element
A dropdown menu built from actions, opened by the button you pass as its child.
Convenience wrapper around useMenuActions that creates the backing atom inline.
Pass a builder thunk and a dependency list — the hook memoizes Atom.make(build) and threads
it through useMenuActions. Saves the useMemo(() => Atom.make(...), deps) boilerplate when
the action graph is composed from local state (e.g. a toolbar driven by component state).
Read reactive state via get inside the builder; deps should hold only stable references.
Text whose first line is centred in a block, so it lines up with a Block or control beside it however many lines
it wraps to. Renders a <p>; asChild puts the metrics on a heading or other text element instead.
Text
tone?: Typography.TextTone | undefined
Emphasis below the default (DESIGN.md "Text emphasis"): description for secondary content, subdued for
interface text.
Text whose first line is centred in a block, so it lines up with a Block or control beside it however many lines
it wraps to. Renders a <p>; asChild puts the metrics on a heading or other text element instead.
Text>
42
</>
43
);
44
};
45
MenuBuilder makes three actions, with a separator before Delete. The icon-only Button.Root is the trigger, and
each action’s function records its name in state.