{"id":13780823,"url":"https://github.com/github/details-menu-element","last_synced_at":"2025-05-14T00:07:28.605Z","repository":{"id":37549976,"uuid":"138936382","full_name":"github/details-menu-element","owner":"github","description":"A menu opened with \u003cdetails\u003e.","archived":false,"fork":false,"pushed_at":"2025-03-11T18:46:14.000Z","size":742,"stargazers_count":593,"open_issues_count":2,"forks_count":40,"subscribers_count":258,"default_branch":"main","last_synced_at":"2025-05-10T13:54:20.081Z","etag":null,"topics":["custom-elements","web-components"],"latest_commit_sha":null,"homepage":"https://github.github.io/details-menu-element/examples","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/github.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-27T21:48:29.000Z","updated_at":"2025-04-12T20:58:40.000Z","dependencies_parsed_at":"2024-06-18T13:32:46.566Z","dependency_job_id":"fc764baf-8ad1-4b3d-838b-d4be42bc71ce","html_url":"https://github.com/github/details-menu-element","commit_stats":{"total_commits":177,"total_committers":11,"mean_commits":16.09090909090909,"dds":0.5649717514124294,"last_synced_commit":"7270356713b471c4914abe68ae9bb41c4d19f9cf"},"previous_names":[],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/github%2Fdetails-menu-element","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/github%2Fdetails-menu-element/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/github%2Fdetails-menu-element/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/github%2Fdetails-menu-element/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/github","download_url":"https://codeload.github.com/github/details-menu-element/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254043775,"owners_count":22005013,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["custom-elements","web-components"],"created_at":"2024-08-03T18:01:20.147Z","updated_at":"2025-05-14T00:07:28.572Z","avatar_url":"https://github.com/github.png","language":"JavaScript","readme":"# \u0026lt;details-menu\u0026gt; element\n\nA menu that's opened with a \u0026lt;details\u003e button.\n\n## Installation\n\n```\n$ npm install @github/details-menu-element\n```\n\n## Usage\n\n### Script\n\nImport as a module:\n\n```js\nimport '@github/details-menu-element'\n```\n\nWith a script tag:\n\n```html\n\u003cscript type=\"module\" src=\"./node_modules/@github/details-menu-element/dist/index.js\"\u003e\n```\n\n### Markup\n\n\n```html\n\u003cdetails\u003e\n  \u003csummary\u003eRobots\u003c/summary\u003e\n  \u003cdetails-menu role=\"menu\"\u003e\n    \u003cbutton type=\"button\" role=\"menuitem\"\u003eHubot\u003c/button\u003e\n    \u003cbutton type=\"button\" role=\"menuitem\"\u003eBender\u003c/button\u003e\n    \u003cbutton type=\"button\" role=\"menuitem\"\u003eBB-8\u003c/button\u003e\n  \u003c/details-menu\u003e\n\u003c/details\u003e\n```\n\nUse `data-menu-button` and `data-menu-button-text` to update the button's text on menu item activation.\n\n```html\n\u003cdetails\u003e\n  \u003csummary\u003ePreferred robot: \u003cspan data-menu-button\u003eNone\u003c/span\u003e\u003c/summary\u003e\n  \u003cdetails-menu role=\"menu\"\u003e\n    \u003cbutton type=\"button\" role=\"menuitem\" data-menu-button-text\u003eHubot\u003c/button\u003e\n    \u003cbutton type=\"button\" role=\"menuitem\" data-menu-button-text\u003eBender\u003c/button\u003e\n    \u003cbutton type=\"button\" role=\"menuitem\" data-menu-button-text\u003eBB-8\u003c/button\u003e\n  \u003c/details-menu\u003e\n\u003c/details\u003e\n```\n\nUse `data-menu-button` and `data-menu-button-contents` to update the button's HTML content on menu item activation.\n\n```html\n\u003cdetails\u003e\n  \u003csummary\u003ePreferred robot: \u003cspan data-menu-button\u003eNone\u003c/span\u003e\u003c/summary\u003e\n  \u003cdetails-menu role=\"menu\"\u003e\n    \u003cbutton type=\"button\" role=\"menuitem\" data-menu-button-contents\u003e\u003cimg src=\"hubot.png\"\u003e Hubot\u003c/button\u003e\n    \u003cbutton type=\"button\" role=\"menuitem\" data-menu-button-contents\u003e\u003cimg src=\"bender.png\"\u003e Bender\u003c/button\u003e\n    \u003cbutton type=\"button\" role=\"menuitem\" data-menu-button-contents\u003e\u003cimg src=\"bb8.png\"\u003e BB-8\u003c/button\u003e\n  \u003c/details-menu\u003e\n\u003c/details\u003e\n```\n\nUse `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.\n\n```html\n\u003cdetails\u003e\n  \u003csummary\u003ePreferred robot\u003c/summary\u003e\n  \u003cdetails-menu role=\"menu\"\u003e\n    \u003clabel tabindex=\"0\" role=\"menuitemradio\"\u003e\n      \u003cinput type=\"radio\" name=\"robot\" value=\"Hubot\"\u003e Hubot\n    \u003c/label\u003e\n    \u003clabel tabindex=\"0\" role=\"menuitemradio\"\u003e\n      \u003cinput type=\"radio\" name=\"robot\" value=\"Bender\"\u003e Bender\n    \u003c/label\u003e\n    \u003clabel tabindex=\"0\" role=\"menuitemradio\"\u003e\n      \u003cinput type=\"radio\" name=\"robot\" value=\"BB-8\"\u003e BB-8\n    \u003c/label\u003e\n  \u003c/details-menu\u003e\n\u003c/details\u003e\n```\n\n### Events\n\n- `details-menu-select` (cancelable) - fired on `\u003cdetails-menu\u003e` with `event.detail.relatedTarget` being the item to be selected.\n- `details-menu-selected` - fired on `\u003cdetails-menu\u003e` with `event.detail.relatedTarget` being the item selected, after label is updated and menu is closed.\n\n### Deferred loading\n\nMenu content can be loaded from a server by embedding an\n[`\u003cinclude-fragment\u003e`][fragment] element.\n\n[fragment]: https://github.com/github/include-fragment-element/\n\n```html\n\u003cdetails\u003e\n  \u003csummary\u003eRobots\u003c/summary\u003e\n  \u003cdetails-menu src=\"/robots\" preload\u003e\n    \u003cinclude-fragment\u003eLoading…\u003c/include-fragment\u003e\n  \u003c/details-menu\u003e\n\u003c/details\u003e\n```\n\nThe `src` attribute value is copied to the `\u003cinclude-fragment\u003e` the first\ntime the `\u003cdetails\u003e` button is toggled open, which starts the server fetch.\n\nIf the `preload` attribute is present, the server fetch will begin on mouse\nhover over the `\u003cdetails\u003e` button, so the content may be loaded by the time\nthe menu is opened.\n\n## Browser support\n\nBrowsers without native [custom element support][support] require a [polyfill][].\n\n- Chrome\n- Firefox\n- Safari\n- Microsoft Edge\n\n[support]: https://caniuse.com/#feat=custom-elementsv1\n[polyfill]: https://github.com/webcomponents/custom-elements\n\n## Development\n\n```\nnpm install\nnpm test\n```\n\n## License\n\nDistributed under the MIT license. See LICENSE for details.\n","funding_links":[],"categories":["Element Extensions","JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgithub%2Fdetails-menu-element","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgithub%2Fdetails-menu-element","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgithub%2Fdetails-menu-element/lists"}