Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
@rmwc/menu
Advanced tools
Menus display a list of choices on a transient sheet of material.
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>
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>
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';
<DocumentComponent displayName="Menu" />
<DocumentComponent displayName="MenuItem" composes={['ListItem']}/>
<DocumentComponent displayName="MenuSurface" />
<DocumentComponent displayName="MenuSurfaceAnchor" />
<DocumentComponent displayName="SimpleMenu" />
<DocumentComponent displayName="SimpleMenuSurface" />
FAQs
RMWC Menu component
The npm package @rmwc/menu receives a total of 6,890 weekly downloads. As such, @rmwc/menu popularity was classified as popular.
We found that @rmwc/menu demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.