Styled Dropdown is a user-friendly, pre-styled dropdown component for your web applications. It injects styles directly into the DOM, eliminating the need to import any separate CSS files.
- Easy to install and use.
- Pre-styled, no need to import styles separately.
- Pure JavaScript, no dependencies.
Install styled-dropdown
via npm:
npm install styled-dropdown
To use the styled-dropdown component in your project, follow the example below:
- add div with dropdown id to your html page
<div id="dropdown"></div>
- import styledDropdown into your Javascript code
import styledDropdown from 'styledDropdown';
- and the code below
createStyledDropdown("dropdown", [
{ href: "#", label: "Link 1" },
{ href: "#", label: "Link 2" },
{ href: "#", label: "Link 3" },
]);
In this example:
-
'dropdown' is the id of the HTML element where the dropdown menu will be rendered.
-
The array provides the options for the dropdown menu. Each option is an object with two properties: href and label. href is the link to be used when this option is selected. label is the text to be displayed for this option in the dropdown menu.