Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@rmwc/menu

Package Overview
Dependencies
Maintainers
1
Versions
176
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rmwc/menu

RMWC Menu component

  • 2.0.0-alpha.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.4K
decreased by-43.92%
Maintainers
1
Weekly downloads
 
Created
Source

Menus

Menus display a list of choices on a transient sheet of material.

  • import from '@rmwc/menu';
  • import styles:
    • import '@material/menu/dist/mdc.menu.css';
    • import '@material/menu-surface/dist/mdc.menu-surface.css';
    • import '@material/list/dist/mdc.list.css';
  • MDC Docs: https://material.io/develop/web/components/menus/

Menu with Items

You can compose a menu with the given components, and manually manage the open state.

import { Menu, MenuItem, MenuSurfaceAnchor } from '@rmwc/menu';
import { Button } from '@rmwc/button';

<MenuSurfaceAnchor>
  <Menu
    open={this.state.menuIsOpen}
    onSelect={evt => console.log(evt.detail.index)}
    onClose={evt => this.setState({menuIsOpen: false})}
  >
    <MenuItem>Cookies</MenuItem>
    <MenuItem>Pizza</MenuItem>
    <MenuItem>Icecream</MenuItem>
  </Menu>

  <Button
    raised
    onClick={evt => this.setState({'menuIsOpen': !this.state.menuIsOpen})}
  >
    Open Menu
  </Button>
</MenuSurfaceAnchor>

Generic Menu Surface

MenuSurface allows you to create a menu with any kind of content.

import { MenuSurface, MenuSurfaceAnchor } from '@rmwc/menu';
import { Button } from '@rmwc/button';

<MenuSurfaceAnchor>
  <MenuSurface
    open={this.state.genericMenuIsOpen}
    onClose={evt => this.setState({genericMenuIsOpen: false})}
  >
    <div style={{padding: '1rem', width: '8rem'}}>Make the content whatever you want.</div>
  </MenuSurface>

  <Button
    raised
    onClick={evt => this.setState({'genericMenuIsOpen': !this.state.genericMenuIsOpen})}
  >
    Open Generic Menu
  </Button>
</MenuSurfaceAnchor>

Simplified usage

RMWC provides a non-standard convenience SimpleMenu component that takes a handle as a prop, and manages the open state for you.

import { SimpleMenu, SimpleMenuSurface, MenuItem } from '@rmwc/menu';
import { Button } from '@rmwc/button';

<SimpleMenu
  handle={ <Button raised>Open Simple Menu</Button> }
>
  <MenuItem>Cookies</MenuItem>
  <MenuItem>Pizza</MenuItem>
  <MenuItem>Icecream</MenuItem>
</SimpleMenu>

<SimpleMenuSurface
  handle={ <Button raised>Open Simple Menu Surface</Button> }
>
  <div style={{padding: '1rem', width: '8rem'}}>Make the content whatever you want.</div>
</SimpleMenuSurface>
import { DocumentComponent } from '@rmwc/base/utils/DocumentComponent';
import * as docs from './docgen.json';

<DocumentComponent docs={docs} displayName="Menu" />
<DocumentComponent docs={docs} displayName="MenuItem" composes={['ListItem']}/>
<DocumentComponent docs={docs} displayName="MenuSurface" />
<DocumentComponent docs={docs} displayName="MenuSurfaceAnchor" />
<DocumentComponent docs={docs} displayName="SimpleMenu" />
<DocumentComponent docs={docs} displayName="SimpleMenuSurface" />

Keywords

FAQs

Package last updated on 06 Sep 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc