https://github.com/ddosnotification/interactive-cli-menu
A sleek and customizable CLI menu with arrow key navigation and actions. No external dependencies!
https://github.com/ddosnotification/interactive-cli-menu
cli cli-navigation cli-tool command-line command-line-interface interactive menu node-cli nodejs nodejs-menu npm-package terminal terminal-ui ux-design
Last synced: 4 months ago
JSON representation
A sleek and customizable CLI menu with arrow key navigation and actions. No external dependencies!
- Host: GitHub
- URL: https://github.com/ddosnotification/interactive-cli-menu
- Owner: ddosnotification
- Created: 2024-11-26T19:50:42.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-26T19:58:17.000Z (over 1 year ago)
- Last Synced: 2025-04-11T18:16:56.817Z (about 1 year ago)
- Topics: cli, cli-navigation, cli-tool, command-line, command-line-interface, interactive, menu, node-cli, nodejs, nodejs-menu, npm-package, terminal, terminal-ui, ux-design
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/interactive-cli-menu
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ๐ interactive-cli-menu



**interactive-cli-menu** is a sleek, modern, and customizable NPM package for creating interactive CLI menus. It supports smooth arrow key navigation, actionable items, and beautiful terminal UIโall without external dependencies! Perfect for making your command-line tools pop! ๐
---
## ๐ Features
- ๐ผ **Arrow Key Navigation**: Effortlessly navigate menus with the up/down arrows.
- ๐จ **Customizable Styling**: Choose colors, widths, borders, and more.
- โก **Actionable Items**: Attach custom actions to menu selections.
- ๐ชถ **Lightweight**: No external dependenciesโ100% native Node.js.
- ๐ **Graceful Exit**: Cleanly handles `Ctrl+C` to terminate.
---
## ๐ฆ Installation
Install via NPM:
```bash
npm install interactive-cli-menu
```
---
## ๐ ๏ธ Usage
### โจ Simple Example
```javascript
const { createMenu } = require('interactive-cli-menu');
const menu = createMenu({
title: '๐ Main Menu',
width: 50,
borderColor: 36, // Cyan
highlightColor: 33, // Yellow
textColor: 37, // White
items: [
{ label: '๐ Search', action: () => console.log('Searching... ๐') },
{ label: 'โ๏ธ Settings', action: () => console.log('Opening settings... ๐ ๏ธ') },
{ label: 'โ Exit', action: () => console.log('Goodbye! ๐') }
]
});
menu.render();
```
### ๐ฅ๏ธ Output
```
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ Main Menu
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ Search
> โ๏ธ Settings
โ Exit
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
```
### Interact:
- Use **โฌ๏ธ Up** and **โฌ๏ธ Down** to navigate.
- Press **โ Enter** to select.
---
## ๐จ API
### `createMenu(options)`
#### `options` (object)
| Option | Type | Default | Description |
|------------------|----------|---------------|-----------------------------------------------------------------------------|
| `title` | `string` | `'Menu'` | Title displayed at the top of the menu. |
| `width` | `number` | `60` | Width of the menu in characters. |
| `borderColor` | `number` | `90` (Gray) | ANSI color code for the border. |
| `highlightColor` | `number` | `34` (Blue) | ANSI color code for the selected menu item. |
| `textColor` | `number` | `37` (White) | ANSI color code for unselected menu items. |
| `items` | `array` | `[]` | Array of menu items (see below). |
---
### Menu Items (`items`)
Each item is an object with the following properties:
| Property | Type | Description |
|------------|------------|--------------------------------------------------------|
| `label` | `string` | The text displayed for the menu item (supports emojis).|
| `action` | `function` | The function executed when the item is selected. |
---
## ๐ Advanced Example: Dynamic Menus with Emojis
```javascript
const { createMenu } = require('interactive-cli-menu');
let items = [
{ label: '๐ View Files', action: () => console.log('Listing files... ๐๏ธ') },
{ label: 'โ Add Item', action: () => console.log('Adding item... โ
') },
{ label: 'โ Exit', action: () => console.log('Goodbye! ๐') }
];
const menu = createMenu({
title: '๐ ๏ธ My CLI Tool',
width: 60,
borderColor: 35, // Magenta
highlightColor: 32, // Green
textColor: 37, // White
items
});
menu.render();
```
---
## ๐ฃ๏ธ Roadmap
๐ฎ Future Enhancements:
- ๐ **Nested Menus**: Add support for multi-level menus.
- ๐ **Extended Themes**: More built-in color schemes and styles.
- ๐ต๏ธ **Search**: Enable searchable menus for longer lists.
- โจ๏ธ **Custom Keybindings**: Allow custom navigation keys.
---
## ๐ Contributing
We โค๏ธ contributions! If you find a bug or have an idea for improvement, feel free to [open an issue](https://github.com/ddosnotification/interactive-cli-menu/issues) or submit a pull request.
---
## ๐ License
**interactive-cli-menu** is open-source and available under the [MIT License](https://opensource.org/licenses/MIT).
---
โจ **Make your CLI tools stylish and user-friendly with interactive-cli-menu!** ๐