npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mui-menubar

v0.1.8

Published

A React MenuBar component using Material-UI.

Downloads

566

Readme

Ⓜ ─ mui-menubar ─ 🍫

Build Code Climate Package Quality NPM Version TypeScript

A React MenuBar component built with Material-UI (MUI) and TypeScript. A menu bar is common in desktop applications and provides quick access to a consistent set of commands (e.g. File, Edit, View).

🚀 Features

  • Flexible Configuration: Define multiple top-level menus with nested items, submenus, dividers, actions and hotkeys.
  • TypeScript: Strongly typed components and configurations.
  • Material-UI: Integrates with MUI's theming and styling.
  • Accessibility: Keyboard navigation is supported within dropdowns (e.g., Arrow keys to navigate, Enter to select).

📦 Installation

  1. Ensure your project meets the peer dependencies before installing.

    npm install react react-dom @mui/material@^5.0.0 @mui/icons-material@^5.0.0 @emotion/react @emotion/styled
  2. Install mui-menubar

    npm install mui-menubar

🎮 Usage

Import the Component

import React from "react";
import { MenuStrip, MenuConfig } from "react-mui-menustrip-ts";
import { Home, Settings, Help } from "@mui/icons-material";

Define the Menu Configuration

const menuConfig: MenuConfig[] = [
    {
        label: "File",
        items: [
            { label: "New", action: () => console.log("New clicked"), icon: Home },
            { label: "Open", action: () => console.log("Open clicked") },
            { kind: "divider" },
            {
                kind: "submenu",
                label: "Recent",
                items: [
                    { label: "Document 1", action: () => console.log("Document 1 clicked") },
                    { label: "Document 2", action: () => console.log("Document 2 clicked") },
                ],
            },
            { label: "Exit", action: () => console.log("Exit clicked") },
        ],
    },
    {
        label: "Edit",
        items: [
            { label: "Undo", action: () => console.log("Undo clicked"), icon: Settings },
            { label: "Redo", action: () => console.log("Redo clicked") },
        ],
    },
    {
        label: "Help",
        items: [
            { label: "Documentation", action: () => console.log("Documentation clicked"), icon: Help },
            { label: "About", action: () => console.log("About clicked") },
        ],
    },
];

Example Integration

import React from "react";
import { MenuBar, MenuConfig } from "mui-menubar";
import { Home, Settings, Help } from "@mui/icons-material";
import { ThemeProvider, createTheme } from "@mui/material/styles";

const menuConfig: MenuConfig[] = [
    /* ... as defined above ... */
];

const theme = createTheme({
    palette: {
        mode: "light", // Change to 'dark' for dark mode
    },
});

const App: React.FC = () => (
    <ThemeProvider theme={theme}>
        <MenuBar config={menuConfig} darkMode={false} />
    </ThemeProvider>
);

export default App;

🔧 API Reference

MenuStrip Props

| Prop | Type | Description | Default | | ------------ | ---------------- | -------------------------------------------- | ------- | | config | MenuConfig[] | Required. Array defining the menu structure. | - | | colorTheme | string | Changes color styles (e.g. "light" / "dark") | light | | sx | SxProps<Theme> | Custom styles for the AppBar component. | - |

Type Definitions

MenuConfig

interface MenuConfig {
    label: string;
    items: MenuItemDefinitionUnion[];
}

MenuItemDefinitionUnion

type MenuItemDefinitionUnion = MenuItemActionDefinition | MenuItemDividerDefinition | MenuItemSubmenuDefinition;

MenuItemActionDefinition

interface MenuItemActionDefinition {
    kind?: "action";
    label: string;
    action: () => void;
    icon?: React.ComponentType<SvgIconProps>;
    shortcut?: string;
}

MenuItemDividerDefinition

interface MenuItemDividerDefinition {
    kind: "divider";
}

MenuItemSubmenuDefinition

export interface MenuItemSubmenuDefinition {
    kind: "submenu";
    label: string;
    items: MenuItemDefinitionUnion[];
    icon?: React.ComponentType<SvgIconProps>;
}

🗺️ Roadmap

  • ARIA Attributes: Properly set for screen readers.