<zg-menu>
Version 1
Interactive Storybook Playground
The <zg-menu>
tag is a web component container for a custom menu that can be used as a context or static (aka "Hamburger") menu. The element is generally dynamically inserted by the library, but the developer can append or overwrite the menu with custom entries. The element can be styled using CSS variables and CSS selectors.
Component | Relationship | Type | Ancestor |
---|
Related Web Components
Usage
The <zg-menu>
is always available through right-click interactions on the grid. A <zg-menu>
tag can be manually inserted inside the grid as slotted content, like so:
<zing-grid src="https://cdn.zinggrid.com/datasets/user-roles.json" context-menu="mymenu"> <zg-menu id="mymenu" replace="true"> <p>This content replaces the built-in menu</p> </zg-menu> </zing-grid>
You can also add a default menu via the static-menu
attribute, like so:
<zing-grid src="https://cdn.zinggrid.com/datasets/user-roles.json" static-menu> </zing-grid>
Attributes
There are a couple attributes to add and replace <zg-menu>
.
CSS Variables
<zg-menu>
can be styled with CSS variables, like so:
:root { --zg-menu-font-size: 1.2rem; }
Below is a list of all the associated --zg-menu
CSS variables. Check out the full list of CSS variables or our Styling Basics guide to learn more about styling the grid.
Name | Default | Description | Demo | CSS Ref |
---|---|---|---|---|
--zg-menu-background | Browser's defaul value | Styles background of menu dropdown | ||
--zg-menu-border | 1px solid var(--theme-border-color) | Styles the border of menu dropdown | ||
--zg-menu-border-bottom | var(--zg-menu-border, 1px solid var(--theme-border-color)) | Styles the bottom border of menu dropdown | ||
--zg-menu-border-left | var(--zg-menu-border, 1px solid var(--theme-border-color)) | Styles the left border of menu dropdown | ||
--zg-menu-border-right | var(--zg-menu-border, 1px solid var(--theme-border-color)) | Styles the right border of menu dropdown | ||
--zg-menu-border-top | var(--zg-menu-border, 1px solid var(--theme-border-color)) | Styles the top border of menu dropdown | ||
--zg-menu-box-shadow | 0 3px 3px #ccc | Applies a box shadow to menu dropdown | ||
--zg-menu-font-size | 0.8rem | Sets the font size of menu dropdown | ||
--zg-menu-padding | 0 | Sets the padding of the menu dropdown |
CSS Selector
<zg-menu>
can be styled by common CSS selectors, like so:
zg-menu { background: red; }
CSS Shadow Parts
<zg-menu>
exposed elements within the shadow can be styled by CSS shadow parts, like so:
zg-menu::part(menu) { background-color: red; }
Below is a list of all the associated ZGMenu shadow parts. Check out the full list of CSS shadow parts or our Styling Basics guide to learn more about styling the grid.
Name | Description |
---|---|
menu | The container for the menu |
Slots
<zg-menu>
contains placeholders to allow adding markup inside the component.
<zg-menu>Slotted Content</zg-menu>
Below is a list of all the associated ZGMenu slots. Check out the full list of slots.
[api: <zg-menu>]