Menu

June 1, 2019 ยท View on GitHub

A local popup menu with a list of choices. A menu contains one or more Lists with List Tiles as menu elements.

Main features

  • Choose menu type: dropdown, exposing dropdown, dialog
  • Anchor menu to position "top left", "bottom right", etcetera
  • Tweak positioning with an offset
  • Dropdown menu: optionally reposition according to selected item
  • Long list: scroll selected item into view
  • Custom transitions
  • Optional backdrop
  • All List main features

Usage

Options

ParameterRequiredTypeDefaultDescription
backdropoptionalBooleanfalseSet to true to add a backdrop below the menu
heightoptionalString or NumberUse "max" to use the maximum available height within the parent element (the top position and bottom margin will be subtracted automatically); otherwise use a number with or without pixels or percentage, for example: 160, "160px" or "75%" (when using percentage the parent element must have a height)
offsetHoptionalNumber or String0Horizontal offset relative to target element; use a number with or without pixels or percentage, for example: 16, "16px" or "75%"
offsetVoptionalNumber or String"79%"Vertical offset relative to target element; use a number with or without pixels or percentage, for example: 16, "16px" or "75%"
originoptionalString"top" (if target is specified)Makes the menu appear from a corner or a side; use any combination of "top", "right", "bottom", "left"; for example: "top left", "bottom right", "top"; but not: "top bottom", "right left"
permanentoptionalBooleanfalseSet to true to always show the menu (mostly used for demonstration purposes)
repositionoptionalBooleanfalseSet to true to position the menu to the menu item (List Tile) that has class "selected"
scrollTargetoptionalStringHTML element selector to scroll to at appearance, for example ".list-item-12"
shadowDepthoptionalNumber 0-53Depth of the shadow
showoptionalBooleanfalseSet to true to show the menu
targetrecommendedStringHTML element selector to position to, for example "#my-button"
topMenuoptionalBooleanfalseSet to true to make the menu appear full width at the top
transitionsoptionalObjectSee "Transition options" below
widthoptionalNumber: 1, 1.5, 2, 3, 4, 5, 6, 7, or "auto"Multiplication factor of width unit (56px); with "auto" the menu takes the width of the widest element; note that on smaller devices a large size may get clipped by the screen

Transition options

See: Transitions

Common component options

ParameterRequiredTypeDefaultDescription
afteroptionalString, hyperscript or componentExtra content after main content; note that this content is placed right of preceding elements with a higher stacking depth
beforeoptionalString, hyperscript or componentExtra content before main content; note that this content is placed left of subsequent elements with a lower stacking depth
classNameoptionalStringExtra CSS class appended to pe-menu
contentuse content or childrenString, hyperscript or componentExpects a List, or an array of lists; replaces children
elementoptionalString"div"HTML element tag
eventsoptionalObjectOptions object containing one or more standard events such as onclick (React: onClick)
idoptionalStringHTML element id
styleoptionalObjectFor setting simple style attributes
toneoptionalString: "dark" or "light"Renders the component light on dark (sets class pe-dark-tone); use "light" to locally inverse (sets class pe-light-tone)

Composition

Menu is usually composed from:

Menu also contains:

  • Shadow (when option shadowDepth is not 0)

CSS classes

Future

  • Take the browser window into account to make sure that the menu is always in view
  • Scrolling high menu content, style scrollbar
  • Cascading menus