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

@material/menu-surface

Package Overview
Dependencies
Maintainers
21
Versions
1656
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@material/menu-surface

The Material Components for the web menu surface component

  • 13.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
824K
increased by2.64%
Maintainers
21
Weekly downloads
 
Created

What is @material/menu-surface?

@material/menu-surface is a package from Material Design Components (MDC) that provides a foundation for creating menu surfaces. These are surfaces that can be used to display a list of choices, such as a dropdown menu or a context menu.

What are @material/menu-surface's main functionalities?

Basic Menu Surface

This code demonstrates how to create a basic menu surface and open it using the MDCMenuSurface class.


import {MDCMenuSurface} from '@material/menu-surface';

const menuSurfaceElement = document.querySelector('.mdc-menu-surface');
const menuSurface = new MDCMenuSurface(menuSurfaceElement);

menuSurface.open();

Anchor Menu Surface

This code shows how to anchor a menu surface to a specific element, making it appear relative to that element.


import {MDCMenuSurface} from '@material/menu-surface';

const menuSurfaceElement = document.querySelector('.mdc-menu-surface');
const menuSurface = new MDCMenuSurface(menuSurfaceElement);
const anchorElement = document.querySelector('.mdc-menu-surface--anchor');

menuSurface.setAnchorElement(anchorElement);
menuSurface.open();

Menu Surface with Event Listeners

This code demonstrates how to add event listeners to a menu surface to handle open and close events.


import {MDCMenuSurface} from '@material/menu-surface';

const menuSurfaceElement = document.querySelector('.mdc-menu-surface');
const menuSurface = new MDCMenuSurface(menuSurfaceElement);

menuSurface.listen('MDCMenuSurface:opened', () => {
  console.log('Menu surface opened');
});

menuSurface.listen('MDCMenuSurface:closed', () => {
  console.log('Menu surface closed');
});

menuSurface.open();

Other packages similar to @material/menu-surface

Keywords

FAQs

Package last updated on 24 Sep 2021

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