Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gregolive/dropdown-menu
A Javascript dropdown menu npm module.
https://github.com/gregolive/dropdown-menu
css javascript npm npm-module
Last synced: 25 days ago
JSON representation
A Javascript dropdown menu npm module.
- Host: GitHub
- URL: https://github.com/gregolive/dropdown-menu
- Owner: gregolive
- Created: 2022-03-06T04:31:29.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-03-07T08:01:59.000Z (almost 3 years ago)
- Last Synced: 2024-11-15T23:09:52.028Z (about 1 month ago)
- Topics: css, javascript, npm, npm-module
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/@gregolive/dropdown
- Size: 7.81 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Dropdown Menu
A simple Javascript-powered dropdown menu. Can be activated by click or hover.
[Live demo](https://gregolive.github.io/dynamic-ui-design/#dropdown-demo) 👈
[npm package](https://www.npmjs.com/package/@gregolive/dropdown) 📦
## Prerequisites
For icons to display, please install [font-awesome](https://www.npmjs.com/package/font-awesome).
## Installation
On the command line run:
```
npm i @gregolive/dropdown
```Import the function in your Javascript file with:
```
import dropdown from '@gregolive/dropdown';
```## Usage
Pass 2 or 3 arguments into the dropdown function:
1.
title
string for the dropdown button
2.links
object containing the text and href for the menu items
3.hover
boolean (optional, defaults to false)Append to the DOM.
Examples:
```
const links = [
{ text: 'Hello there 👋', href: '#' },
{ text: "I'm a dropdown link 🔗", href: '#' },
{ text: 'Me too 🤙', href: '#' },
];const clickDropdown = dropdown('Click Me', links);
document.body.appendChild(clickDropdown);const hoverDropdown dropdown('Hover Me', links, true);
document.body.appendChild(hoverkDropdown);
```Default styling (colors, padding, etc.) can be overridden by overriding the CSS variables in:
```
:root {
...
}
```## License
ISC