🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@reach/menu-button

Package Overview
Dependencies
Maintainers
4
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@reach/menu-button

Accessible React button dropdown menu.

0.18.0
latest
Source
npm
Version published
Weekly downloads
275K
36.2%
Maintainers
4
Weekly downloads
 
Created

What is @reach/menu-button?

@reach/menu-button is a React component library that provides accessible menu button components. It helps developers create dropdown menus that are fully accessible and compliant with WAI-ARIA standards.

What are @reach/menu-button's main functionalities?

Basic Menu Button

This code demonstrates a basic menu button with a list of menu items. When a menu item is selected, an alert is shown with the corresponding action.

import { Menu, MenuList, MenuButton, MenuItem } from '@reach/menu-button';

function BasicMenuButton() {
  return (
    <Menu>
      <MenuButton>
        Actions <span aria-hidden>▾</span>
      </MenuButton>
      <MenuList>
        <MenuItem onSelect={() => alert('Download')}>Download</MenuItem>
        <MenuItem onSelect={() => alert('Create a Copy')}>Create a Copy</MenuItem>
        <MenuItem onSelect={() => alert('Mark as Draft')}>Mark as Draft</MenuItem>
        <MenuItem onSelect={() => alert('Delete')}>Delete</MenuItem>
      </MenuList>
    </Menu>
  );
}

Menu Button with Links

This example shows how to create a menu button with links. Each menu item is a link that navigates to a different page.

import { Menu, MenuList, MenuButton, MenuLink } from '@reach/menu-button';

function MenuButtonWithLinks() {
  return (
    <Menu>
      <MenuButton>
        More Options <span aria-hidden>▾</span>
      </MenuButton>
      <MenuList>
        <MenuLink as="a" href="/profile">Profile</MenuLink>
        <MenuLink as="a" href="/settings">Settings</MenuLink>
        <MenuLink as="a" href="/logout">Logout</MenuLink>
      </MenuList>
    </Menu>
  );
}

Menu Button with Custom Styling

This code demonstrates how to apply custom styling to the menu button and its items using CSS classes.

import { Menu, MenuList, MenuButton, MenuItem } from '@reach/menu-button';
import './customStyles.css';

function CustomStyledMenuButton() {
  return (
    <Menu>
      <MenuButton className="custom-button">
        Custom Menu <span aria-hidden>▾</span>
      </MenuButton>
      <MenuList className="custom-menu-list">
        <MenuItem className="custom-menu-item" onSelect={() => alert('Option 1')}>Option 1</MenuItem>
        <MenuItem className="custom-menu-item" onSelect={() => alert('Option 2')}>Option 2</MenuItem>
        <MenuItem className="custom-menu-item" onSelect={() => alert('Option 3')}>Option 3</MenuItem>
      </MenuList>
    </Menu>
  );
}

Other packages similar to @reach/menu-button

FAQs

Package last updated on 13 Oct 2022

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