MenuButton
Reference
- The
MenuButtoncomponent is display combination of button (or anchor) with dropdown menu.
Props
-
anchorComponent- Type:
ReactNode - Description: The component that acts as the anchor for the menu.
- Type:
-
menuComponent- Type:
ReactNode - Description: The content to display inside the dropdown menu.
- Type:
-
initialComponent- Type:
ReactNode - Description: The component displayed initially (e.g., a button or icon).
- Type:
-
style- Type:
object - Default:
{} - Description: Custom styles for the anchor component.
- Type:
-
placement- Type:
string - Default:
'bottom' - Description: Controls the placement of the menu relative to the anchor (e.g.,
'top','bottom','left','right').
- Type:
Usage Example
function Example(pageContext) {
const { protrakComponents } = React.useContext(customWidgetContext);
const { MenuButton } = protrakComponents;
return(
<MenuButton
initialComponent={<button>Open Menu</button>}
anchorComponent={<span>Anchor</span>}
menuComponent={<div>Menu Content</div>}
placement="bottom-end"
/>
);
}
- This renders a button that toggles a dropdown menu with the content "Menu Content" positioned at the bottom-end of the anchor.