All Projects → github → Details Menu Element

github / Details Menu Element

Licence: mit
A menu opened with <details>.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Details Menu Element

custom-element-boilerplate
Boilerplate for creating a custom element.
Stars: ✭ 137 (-69.89%)
Mutual labels:  web-components, custom-elements
bui
‹b› Web components for creating applications – built by Blackstone Publishing using lit-html and lit-element
Stars: ✭ 29 (-93.63%)
Mutual labels:  web-components, custom-elements
ascii-image
Web Component that displays an image as ASCII art
Stars: ✭ 15 (-96.7%)
Mutual labels:  web-components, custom-elements
Synergy
Synergy is a tiny runtime library for building web user interfaces
Stars: ✭ 296 (-34.95%)
Mutual labels:  web-components, custom-elements
Three Elements
Web Components-powered custom HTML elements for building Three.js-powered games and interactive experiences. 🎉
Stars: ✭ 331 (-27.25%)
Mutual labels:  web-components, custom-elements
typing-effect-element
A custom element that shows text as if it were being typed
Stars: ✭ 81 (-82.2%)
Mutual labels:  web-components, custom-elements
custom-elements-manifest
Custom Elements Manifest is a file format that describes custom elements in your project.
Stars: ✭ 81 (-82.2%)
Mutual labels:  web-components, custom-elements
g-emoji-element
Backports native emoji characters to browsers that don't support them by replacing the characters with fallback images.
Stars: ✭ 112 (-75.38%)
Mutual labels:  web-components, custom-elements
Monogatari
Monogatari is a simple web visual novel engine, created to bring Visual Novels to the web.
Stars: ✭ 357 (-21.54%)
Mutual labels:  web-components, custom-elements
storify
Instagram/Whatsapp stories clone built on Web Components and Web Animations API. 🔥
Stars: ✭ 64 (-85.93%)
Mutual labels:  web-components, custom-elements
Include Fragment Element
A client-side includes tag.
Stars: ✭ 380 (-16.48%)
Mutual labels:  web-components, custom-elements
Weightless
High-quality web components with a small footprint
Stars: ✭ 284 (-37.58%)
Mutual labels:  web-components, custom-elements
toggle-icon
toggle-icon is a custom element created with Polymer. It provides an extremely powerful and customizable switch that looks like a paper-icon-button.
Stars: ✭ 21 (-95.38%)
Mutual labels:  web-components, custom-elements
vue-custom-element
Vue Custom Element - Web Components' Custom Elements for Vue.js
Stars: ✭ 1,886 (+314.51%)
Mutual labels:  web-components, custom-elements
inclusive-elements
Accessible, lightweight, unstyled implementations of common UI controls.
Stars: ✭ 17 (-96.26%)
Mutual labels:  web-components, custom-elements
cwco
Powerful and Fast Web Component Library with a Simple API
Stars: ✭ 27 (-94.07%)
Mutual labels:  web-components, custom-elements
11ty-web-component-generator
Use the power of 11ty to generate web components (custom elements).
Stars: ✭ 51 (-88.79%)
Mutual labels:  web-components, custom-elements
lit-components
Moved to https://github.com/vaadin/component-mixins
Stars: ✭ 59 (-87.03%)
Mutual labels:  web-components, custom-elements
svelte-webcomponents
A ready-to-use project template to build custom elements (web components) with Svelte 3 with support and examples for web components, jest, sass, nested components with props, eslinting, stylelinting, Github actions, propagating custom events from shadow-DOM to real-DOM etc.
Stars: ✭ 22 (-95.16%)
Mutual labels:  web-components, custom-elements
anywhere-webcomponents
A UI work in progress based on custom elements (web components) for use in anywhere.
Stars: ✭ 17 (-96.26%)
Mutual labels:  web-components, custom-elements

<details-menu> element

A menu that's opened with a <details> button.

Installation

$ npm install @github/details-menu-element

Usage

Script

Import as a module:

import '@github/details-menu-element'

With a script tag:

<script type="module" src="./node_modules/@github/details-menu-element/dist/index.js">

Markup

<details>
  <summary>Robots</summary>
  <details-menu role="menu">
    <button type="button" role="menuitem">Hubot</button>
    <button type="button" role="menuitem">Bender</button>
    <button type="button" role="menuitem">BB-8</button>
  </details-menu>
</details>

Use data-menu-button and data-menu-button-text to update the button's text on menu item activation.

<details>
  <summary>Preferred robot: <span data-menu-button>None</span></summary>
  <details-menu role="menu">
    <button type="button" role="menuitem" data-menu-button-text>Hubot</button>
    <button type="button" role="menuitem" data-menu-button-text>Bender</button>
    <button type="button" role="menuitem" data-menu-button-text>BB-8</button>
  </details-menu>
</details>

Use data-menu-button and data-menu-button-contents to update the button's HTML content on menu item activation.

<details>
  <summary>Preferred robot: <span data-menu-button>None</span></summary>
  <details-menu role="menu">
    <button type="button" role="menuitem" data-menu-button-contents><img src="hubot.png"> Hubot</button>
    <button type="button" role="menuitem" data-menu-button-contents><img src="bender.png"> Bender</button>
    <button type="button" role="menuitem" data-menu-button-contents><img src="bb8.png"> BB-8</button>
  </details-menu>
</details>

Use label[tabindex="0"][role=menuitemradio/menuitemcheckbox] when dealing with radio and checkbox inputs menu items. Check states of the input element and the label will be synchronized.

<details>
  <summary>Preferred robot</summary>
  <details-menu role="menu">
    <label tabindex="0" role="menuitemradio">
      <input type="radio" name="robot" value="Hubot"> Hubot
    </label>
    <label tabindex="0" role="menuitemradio">
      <input type="radio" name="robot" value="Bender"> Bender
    </label>
    <label tabindex="0" role="menuitemradio">
      <input type="radio" name="robot" value="BB-8"> BB-8
    </label>
  </details-menu>
</details>

Events

  • details-menu-select (cancelable) - fired on <details-menu> with event.detail.relatedTarget being the item to be selected.
  • details-menu-selected - fired on <details-menu> with event.detail.relatedTarget being the item selected, after label is updated and menu is closed.

Deferred loading

Menu content can be loaded from a server by embedding an <include-fragment> element.

<details>
  <summary>Robots</summary>
  <details-menu src="/robots" preload>
    <include-fragment>Loading…</include-fragment>
  </details-menu>
</details>

The src attribute value is copied to the <include-fragment> the first time the <details> button is toggled open, which starts the server fetch.

If the preload attribute is present, the server fetch will begin on mouse hover over the <details> button, so the content may be loaded by the time the menu is opened.

Browser support

Browsers without native custom element support require a polyfill.

  • Chrome
  • Firefox
  • Safari
  • Microsoft Edge

Development

npm install
npm test

License

Distributed under the MIT license. See LICENSE for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].