# @bluecoaster455/dropdownjs

> A vanilla javascript dropdown library/plugin.

Latest version **0.1.9** (published 2020-09-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install @bluecoaster455/dropdownjs
pnpm add @bluecoaster455/dropdownjs
yarn add @bluecoaster455/dropdownjs
bun add @bluecoaster455/dropdownjs
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.9 |
| Published | 2020-09-20 |
| First published | 2020-09-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 45.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Bluecoaster455 |
| Maintainers | indiegamelover, bluecoaster |
| Keywords | javascript, vanilla, plugin, library, dropdown, front-end, menu, context, ui |

## Links

- npm: https://www.npmjs.com/package/@bluecoaster455/dropdownjs
- Repository: https://github.com/Bluecoaster455/dropdown-js
- Issues: https://github.com/Bluecoaster455/dropdown-js/issues
- npm.io page: https://npm.io/package/@bluecoaster455/dropdownjs

## 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

- 0.1.9 (latest) — 2020-09-20
- 0.1.8 — 2020-09-20
- 0.1.7 — 2020-09-20
- 0.1.6 — 2020-09-20
- 0.1.5 — 2020-09-19
- 0.1.4 — 2020-09-19
- 0.1.3 — 2020-09-19
- 0.1.2 — 2020-09-19
- 0.1.1 — 2020-09-19
- 0.1.0 — 2020-09-19

## README

# DropdownJS - Dropdowns using vanilla javascript

Demo: [https://bluecoaster455.github.io/dropdown-js/demo](https://bluecoaster455.github.io/dropdown-js/demo)

## Installation

Add the css and the script files to your project:
```html
<html>
  <head>
    ...
    <link href="/path/to/DropdownJS.css" type="text/css" rel="stylesheet"/>
  </head>
  <body>
    ...
    <script src="/path/to/DropdownJS.js" type="text/javascript"></script>
  </body>
</html>
```

## Add a dropdown
Simply have a ``<div>`` inside your ``<body>`` with the `dropdown` attribute and an `id`.
Everything inside the ``<div>`` is the content of your dropdown. You can override the styles
if needed.

The `dropdown-container` attribute defines the container of the dropdown and must not go
outside the container's boundaries (unless the dropdown is too big...)

```html
<div id="dropdown" dropdown dropdown-container="#dropdown-container" style="margin-top: 5px;">
    <ul>
        <li>
            <a href="javascript:;"><i class="far fa-user"></i> My account</a>
        </li>
        <li>
            <a href="javascript:;"><i class="far fa-newspaper"></i> Posts </a>
        </li>
        <li>
            <a href="javascript:;"><i class="fas fa-cog"></i> Settings</a>
        </li>
    </ul>
</div>
```

## Add a dropdown trigger

Add a button in your HTML page and assign the `dropdown-id` attribute to open/close
the respective dropdown in the HTML. You can add more than one button to open/close
the same dropdown. The `dropdown-align` will align the dropdown to the button `left` or `right`

```html
<button dropdown-id="dropdown" dropdown-align="left">Click me to open the dropdown</button>
```

# DropdownJS API functions
```js
DropdownJS.show("dropdownid"); // display the dropdown by id.
DropdownJS.hide("dropdownid"); // hide a dropdown by id. You can specify nothing as id to hide all dropdowns.
DropdownJS.isOpen("dropdownid"); // checks if the dropdown is open.
DropdownJS.find("dropdownid"); // Find a dropdown by id and return a Dropdown instance.
DropdownJS.findByElement(document.querySelector("#dropdown")); // Find a dropdown by element.
```

## Licence
DropdownJS is under [MIT licence](https://opensource.org/licenses/mit-license.php)

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