r-right-menu
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

React Right Menu

Live Demo

Demo

import { useRightMenu } from 'r-right-menu';
import 'r-right-menu/style.css';

function App() {
    const ref = useRightMenu([
        { label: '返回' },
        {
            label: '前进',
            disabled: true,
        },
        {
            label: '重新加载',
            icon: <ReloadOutlined />,
            click() {
                window.location.reload();
            },
        },
        { type: 'divider' },
        {
        label: '多级菜单测试',
            children: [
                { label: '菜单-1' },
                {
                    label: '菜单-2',
                    children: [{ label: '菜单-1' }, { label: '菜单-2' }, { label: '菜单-3' }],
                },
                { label: '菜单-3' },
            ],
        },
    ], {
        // 菜单的额外样式
        className: '',
        style: {},
        zIndex: 100,
        // 判断是否禁用
        disabled: async (ev) => false,
        // 自定义渲染
        renderMenuItem: ({
            label, icon, disabled, hasChildren, isSelected
        }) => {
            return <><>;
        },
    });
    return (
        <div
            ref={ref}
            style={{
                width: '100%',
                height: 'calc(100vh + 10px)',
                overflow: 'hidden',
                background: 'rgb(245, 245, 245)',
                color: 'rgba(0, 0, 0, 0.45)',
                display: 'flex',
                justifyContent: 'center',
                alignItems: 'center',
            }}
        >
            Right Click on here
        </div>
    );
}

Readme

Keywords

Package Sidebar

Install

npm i r-right-menu

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

103 kB

Total Files

14

Last publish

Collaborators

  • supyp