{"id":23053565,"url":"https://github.com/component/dropdown","last_synced_at":"2025-08-15T04:30:43.820Z","repository":{"id":4226441,"uuid":"5348897","full_name":"component/dropdown","owner":"component","description":"Dropdown menu","archived":false,"fork":false,"pushed_at":"2016-03-15T10:33:04.000Z","size":180,"stargazers_count":16,"open_issues_count":7,"forks_count":15,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-05-08T17:12:39.892Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/component.png","metadata":{"files":{"readme":"Readme.md","changelog":"History.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-08-08T23:26:22.000Z","updated_at":"2023-08-17T22:30:59.000Z","dependencies_parsed_at":"2022-09-14T17:02:49.630Z","dependency_job_id":null,"html_url":"https://github.com/component/dropdown","commit_stats":null,"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/component%2Fdropdown","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/component%2Fdropdown/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/component%2Fdropdown/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/component%2Fdropdown/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/component","download_url":"https://codeload.github.com/component/dropdown/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229790894,"owners_count":18124595,"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":[],"created_at":"2024-12-16T00:18:40.245Z","updated_at":"2024-12-16T00:18:40.654Z","avatar_url":"https://github.com/component.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dropdown\n\n  Dropdown component with structural styling.\n\n  ![js dropdown\n  component](http://f.cl.ly/items/010I1g3E2I3j2j2E3j0F/Screen%20Shot%202012-08-10%20at%2011.40.20%20AM.png)\n\n  See Dropdown in action in [here](http://component.github.com/dropdown/).\n\n## Installation\n\n```\n$ component install component/dropdown\n```\n\n## Features\n\n  It inherits all properties of [Menu component](https://github.com/component/menu)\n\n  - events for composition\n  - structural CSS letting you decide on style\n  - fluent API\n  - arrow key navigation\n\n## Events\n\n  It inherits all events of [Menu component](https://github.com/component/menu)\n  and add:\n\n  - `focus`: when an item is correctly selected.\n\n## Dependencies\n\n  * menu-component\n\n## Example\n\n```js\nvar Dropdown = require('dropdown');\n\nvar dropdown = new Dropdown('.fruits-dropdown');\n\ndropdown\n.add('Banana')\n.add('Apple', function(){ console.log('Apple selected'); })\n.add('Lemon', function(){ console.log('Lemon'); })\n.add('Remove \"Apple\"', function(){\n  dropdown.remove('Lemon');\n})\n.focus('Apple');\n\n```\n\n## API\n  \n### Dropdown(ref, options)\n *\n * Emits:\n *  `focus` when an item is really selected\n *  `check` when an item is checked (multiple mode)\n *  `uncheck` when an item is unchecked (multiple mode)\n\n  Create a new `Dropdown` associated to `ref` element. Also support the follow\n  options:\n\n  - menu: `{String}` Set menu behaviur (default 'left').\n  - items: `{Array}` Array of initial items.\n  - select: `{String}` Initial focused item\n  - selectable: `{Boolean}` Defines if dropdown is selectable (default true)\n  - classname: `{String}` Additional class(es) to menu element container\n  - muliple: `{Boolean}` allow check more than one item\n\n```js\nvar Dropdown = require('dropdown');\nvar dropdown = Dropdown('.dropdown-link', {\n    menu: 'right'\n  , items: [\n        ['apple', function (){ console.log('It\\'s an Apple!') }]\n      , ['orange', '\u003cem\u003eorange\u003c/em\u003e']\n      , ['banana', '\u003cstrong\u003eBanana\u003c/strong\u003e']\n      , ['strawberry', function() {\n            console.log('remove the orange');\n            dropdown.remove('orange');\n          }\n        ]\n    ]\n  , select: 'banana'\n});\n```\n\n### Menu inherits methods:\n\n  * Dropdown#add([slug], text, [fn])\n  * Dropdown#remove(slug)\n  * Dropdown#has(slug)\n  * Dropdown#show()\n  * Dropdown#hide()\n\n### Dropdown#focus(slug):\n\n  Focus dropdown with the item given.\n\n```js\n  dropdown.focus('banana');\n```\n\n### Dropdown#select(slug):\n\n  Select dropdown with the item given. it doesn't emit `focus` event.\n\n```js\n  dropdown.focus('banana');\n```\n\n## License\n\n  (The MIT License)\n  Copyright(c) 2012 Damian Suarez \u0026lt;rdsuarez@gmail.com\u0026gt;\n  \n  Permission is hereby granted, free of charge, to any person obtaining\n  a copy of this software and associated documentation files (the\n  'Software'), to deal in the Software without restriction, including\n  without limitation the rights to use, copy, modify, merge, publish,\n  distribute, sublicense, and/or sell copies of the Software, and to\n  permit persons to whom the Software is furnished to do so, subject to\n  the following conditions:\n  \n  The above copyright notice and this permission notice shall be\n  included in all copies or substantial portions of the Software.\n  \n  THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\n  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n  TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcomponent%2Fdropdown","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcomponent%2Fdropdown","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcomponent%2Fdropdown/lists"}