# ngx-menubar

> Simple basic menubar with step-into view display menu items(not tree view display) for angular14+.

Latest version **1.0.9** (published 2024-11-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install ngx-menubar
pnpm add ngx-menubar
yarn add ngx-menubar
bun add ngx-menubar
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.9 |
| Published | 2024-11-29 |
| First published | 2023-12-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 134.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | chengyuxing |
| Maintainers | chengyuxing |
| Keywords | angular, sidebar, menubar, tree, menu |

## Links

- npm: https://www.npmjs.com/package/ngx-menubar
- Repository: https://github.com/chengyuxing/ngx-dev-project
- Homepage: https://github.com/chengyuxing/ngx-dev-project/blob/main/projects/ngx-menubar/README.md
- Issues: https://github.com/chengyuxing/ngx-dev-project/issues
- npm.io page: https://npm.io/package/ngx-menubar

## Dependencies (1)

- [tslib](https://npm.io/package/tslib.md) ^2.3.0

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.0.9 (latest) — 2024-11-29
- 1.0.8 — 2024-11-29
- 1.0.7 — 2024-11-26
- 1.0.6 — 2024-01-12
- 1.0.5 — 2023-12-29
- 1.0.4 — 2023-12-29
- 1.0.3 — 2023-12-25
- 1.0.2 — 2023-12-25
- 1.0.1 — 2023-12-25
- 1.0.0 — 2023-12-25

## README

# Ngx Menubar component

Simple basic menubar with step-into view display menu items(not tree view display).

Open [Menubar](https://stackblitz.com/edit/stackblitz-starters-pnujrb?file=src%2Fmain.ts) demo preview.

## Installation

1. Install: `npm i ngx-menubar`;

2. Add to module or standalone component:

   ```typescript
   import {CyxMenubarComponent} from "ngx-menubar";
   
   @NgModule({
     // ...
     imports: [
       // ...
       CyxMenubarComponent
     ]
   })
   ```

   or

   ```typescript
   import {CyxMenubarComponent} from "ngx-menubar";
   
   @Component({
     // ...
     imports: [
       CyxMenubarComponent
     ]
     // ...
   })
   export class AppComponent {
   
   }
   ```

## Example

`app.component.css`

```css
.container {
  width: 350px;
  height: 500px;
  box-shadow: 1px 2px 8px rgba(0, 0, 0, .45);
}
```

`app.component.html`

```html

<div class="container">
  <cyx-menubar #menubar [datasource]="items">
    <!-- some elements can be here if property 'showDocPanel' set to true. -->
  </cyx-menubar>
</div>
```

`app.component.ts`

```typescript

@Component({...})
export class AppComponent {
  items: IMenuItem[] = [
    {id: 1, title: 'runtime', icon: 'deployed_code', children: []},
    {
      id: 2, title: 'main', children: [
        {id: 5, title: 'app-routing.module.ts', children: []},
        {id: 6, title: 'app.module.ts', children: []},
        {id: 7, title: 'app.component.ts', children: []}
      ]
    },
    //...
  ]
}
```

## Directives

| Name                                                 | Default value                 | Description                                                  |
|------------------------------------------------------|-------------------------------|--------------------------------------------------------------|
| @Input() title: string                               | 'Menu'                        | Default Top menu title.                                      |
| @Input() datasource: [IMenuItem](#IMenuItem)[]       | []                            | Menu items.                                                  |
| @Input() color: string                               | 'dark'                        | Theme color, 'dark' or 'light'.                              |
| @Input() active: string \| number                    | null                          | current active menu item id.                                 |
| @Input() showDocPanel: boolean                       | false                         | Show bottom doc panel.                                       |
| @Input() showMenuIcon: boolean                       | true                          | Show menu icon.                                              |
| @Input() [iconParser](#IconParser): Function         | (icon: string) => icon        | Parse icon which from menu item data field `IMenuItem#icon`. |
| @Input() searchConfig: [SearchConfig](#SearchConfig) | [{...}](#DefaultSearchConfig) | Global menu item search configuration.                       |
| @Output() itemClick: EventEmitter&lt;IMenuItem&gt;   |                               | Menu item click event.                                       |

## Properties

| Name                    | Default value | Description        |
|-------------------------|---------------|--------------------|
| selectedItem: IMenuItem | null          | Selected item.     |
| `get` isTopMenu         | true          | Is menu top level. |

## Appendix

### IconParser

Example of parse icon name to icon html.

```javascript
// menu item data.
// {id: 1, title: '...', icon: 'deployed_code'}

// font icon.
icon => `<span class="material-symbols-sharp">${icon}</span>`
// svg icon.
icon => `<svg viewBox="...">...</svg>`
```

### IMenuItem

Menubar menu item type.

```typescript
export interface IMenuItem {
  id: number | string;
  title: string;
  icon?: string;
  children?: IMenuItem[];
  data?: { [key: string]: any }
}
```

### SearchConfig

```typescript
export interface SearchConfig {
  placeHolder?: string;
  predicate?: (keyword: string, item: IMenuItem) => boolean;
}
```

#### DefaultSearchConfig

```typescript
{
  placeHolder: 'search',
  predicate: (keyword, item) => item.title.toLowerCase().includes(keyword.toLowerCase())
}
```

---
_Source: https://npm.io/package/ngx-menubar · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
