registerMenuItem
Description
Registers custom menu optionsUsage
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 Svelte 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.svelte
<script>
import { Button} from "@svar-ui/svelte-core";
import { ActionMenu } from "@svar-ui/svelte-menu";
import ButtonMenuItem from "./your_items/ButtonMenuItem.svelte";
import { registerMenuItem } from "../your_sources/helpers";
registerMenuItem("button", ButtonMenuItem);
</script>
The above code has added the type:"button" component.