Skip to main content

registerMenuItem

Description

Registers custom menu options

Usage

registerMenuItem(type: string, handler: Component<{ option?: any }>): void;
note

For backward compatibility item is still used instead of option until SVAR 3.0

Parameters

  • type - (required) a string that defines the unique name of the custom menu option. This value will be used as the type property when creating menu items

  • handler - (required) a React component that implements the rendering and behavior of the custom menu option. It receives a single prop:

    • option - an optional object that can contain any configuration data for the component

Example

You can use a custom component inside of an Action Menu item. To add a custom menu item, you need to create a file that will contain the code of your item. When a component is ready, you should register it like this:

App.jsx
import { Button } from "@svar-ui/react-core";
import { ActionMenu } from "@svar-ui/react-menu";

import ButtonMenuItem from "./your_items/ButtonMenuItem.jsx";
import { registerMenuItem } from "../your_sources/helpers";
registerMenuItem("button", ButtonMenuItem);

The above code has added the type:"button" component.