An open API service indexing awesome lists of open source software.

https://github.com/oom-components/horizontal-menu

Web component to create a responsive horizontal menu
https://github.com/oom-components/horizontal-menu

Last synced: 28 days ago
JSON representation

Web component to create a responsive horizontal menu

Awesome Lists containing this project

README

          

# Horizontal menu

Web component to create a responsive horizontal menu. In narrow screens, the
items that don't fit in the menu are moved to a dropdown list.

- No dependencies
- Very light
- Follow the **progressive enhancement strategy**. If the JavaScript fails, the
links are still visible.
- No styles or themes are provided with this package. Just the basic styles.
- Build with modern javascript, using ES6 modules and custom elements

## Usage

Import and register the component with the desired tag name:

```js
import Menu from "horizontal-menu/horizontal-menu.js";

customElements.define("oom-menu", Menu);
```

Create the menu with the following HTML code:

```html

Link 1
Link 2
Link 3
Link 4
Link 5

```

Use CSS to customize your menu. This web component uses a shadow dom and _parts_
to customize the internal elements.

```css
my-menu {
/* Generic styles */
display: flex;

a {
white-space: nowrap;
}

&::part(menu) {
/* Main container */
}
&::part(links) {
/* Horizontal links */
}
&::part(dropdown) {
/* Dropdown container */
}
&::part(dropdown-button) {
/* Button to show/hide the dropdown */
}
&::part(dropdown-links) {
/* Dropdown links */
}
}
```

The HTML structure of the shadow DOM is:

```html














```