options
Description
Optional. A set of menu optionsUsage
options?: {
  id?: string | number;
  text?: string;
  subtext?: string;
  handler?: (ev: IMenuOptionClick) => void;
  data?: IMenuOption[];
  css?: string;
  icon?: string;
  type?: string | Component<any>; // @deprecated use `comp` instead. Will be removed in v3.0 
  comp?: string | Component<any>;
}[];
Parameters
A menu item object in the options array may contain a set of properties. The list of available properties is given below:
- id- (optional) the id of a menu item
- text- (optional) the text of a menu item
- subtext- (optional) a dimmed text displayed to the right of the main item's text, such as a hot key or other additional info
- icon- (optional) the name of an icon displayed before the text. It converts to adding- <i class={item.icon}>, so any icons with the- wxi-prefix can be used here, e.g ".wxi-plus" or any customer icons defined on the page. Read more about the usage of icons
- css- (optional) the name of a CSS class that will be applied to an item
- type- (optional) the type of an item. It can be a predefined string such as "separator" or a custom Svelte component to render a menu item in place of the default renderer. Will be removed in SVAR 3.0 so use- compinstead
- data- (optional) an array of sub items for a menu item. Used to create a tree-like menu structure; the same as- options
- handler- (optional) a click handler function for the menu item. It receives an object with the parameters described here: onclick
- comp– (optional) the component used to render the menu item. It can be the name of a built-in component (string) or a custom Svelte component reference
Example
<script>
  import { Menu } from "@svar-ui/svelte-core";
  // custom component for rendering a menu item
  const CustomItem = (props) => {
    return <div class="custom-item">⭐ {props.text}</div>;
  };
  // plain structure + custom types/components
  const options = [
    { id: "add-task:child", text: "Child task" },
    { id: "add-task:above", text: "Task above" },
    { id: "add-task:below", text: "Task below" },
    { type: "separator" }, // predefined string type
    { id: "special", text: "Special action", comp: CustomItem }, // custom component
  ];
</script>
<Menu {options}/>
Details
The Menu widget can have a more complex tree-like structure. Here's an example:
<script>
  // tree-like structure
  const options = [
      { id: "add-task", text: "Add", icon: "wxi wxi-plus", data:[
          { id: "child", text: "Child task" },
          { id: "above", text: "Task above" },
          { id: "below", text: "Task below" }
      ]}
  ];
</script>
<Menu {options}/>
Related article: Loading options
Related sample: Menu basic