The Flyout component is used to create flyout menus in the WebViewer UI. You can instantiate it with a unique dataElement and an array of items. Items can be simple objects with labels and click handlers, or they can be nested to create sub-menus.
FlyoutItem Configuration
Each item in the items array can be one of the following:
- An object defining the item properties (see
flyoutItemBase). - A string, which acts as a divider.
- A React element.
- An object with a
type that matches a valid FLYOUT_ITEM_TYPES value.
flyoutItemBase properties:
label (string, optional): The text displayed for the item.onClick (function, optional): The callback triggered when the item is clicked.icon (string, optional): A path to an image, base64 data, or a filename of an .svg from the WebViewer icons folder (e.g., icon-save to use icon-save.svg).render (string or function, optional): A preset component name (e.g., 'stylePanel') or a custom render function.children (Array, optional): An array of FlyoutItem objects to create a nested sub-menu.dataElement (string, optional): A unique identifier for the item.
const flyout = new UI.Components.Flyout({
dataElement: 'exampleFlyout',
label: 'Flyout',
});
flyout.setItems([
{
label: 'Item 1',
onClick: () => {
console.log('Item 1 clicked');
},
},
{
label: 'Sub-menu',
children: [
{
label: 'Nested Item',
onClick: () => console.log('Nested clicked'),
}
]
},
'divider-string' // Acts as a divider
]);