Polymer - Paper Dropdown Menu
The paper-dropdown-menu is a simple dropdown-menu, which works with selectable content. You can use this element in your application, by running the following commands to install them in your project directory.
bower install --save PolymerElements/paper-dropdown-menu bower install --save PolymerElements/paper-item bower install --save PolymerElements/paper-listbox
Example
The following example specifies the use of paper-dropdown-menu element in Polymer.js. Create an index.html file and add the following code in it.
<!doctype html>
<html>
<head>
<link rel = 'import' href = 'my-app.html'>
</head>
<body>
<my-app></my-app>
</body>
</html>
Now, open the my-app.html file and include the following code in it.
<link rel = 'import' href='bower_components/polymer/polymer.html'>
<link rel = "import" href = "bower_components/paper-dropdown-menu/paper-dropdown-menu.html">
<link rel = "import" href = "bower_components/paper-item/paper-item.html">
<link rel = "import" href = "bower_components/paper-listbox/paper-listbox.html">
<dom-module id = 'my-app'>
<template>
<style is = "custom-style">
paper-dropdown-menu {
width:250px;
}
paper-dropdown-menu {
height: 200px;
display: block;
}
</style>
<h3>Paper-Dropdown-Menu Example </h3>
<paper-dropdown-menu>
<paper-listbox class = "dropdown-content" selected = "1">
<paper-item>Java Tutorial</paper-item>
<paper-item>C Tutorial</paper-item>
<paper-item>PHP Tutorial</paper-item>
<paper-item>C++ Tutorial</paper-item>
</paper-listbox>
</paper-dropdown-menu>
</template>
<script>
Polymer ({
is: 'my-app', ready: function() {
this.async(function() {
});
}
});
</script>
</dom-module>
Output
To run the application, navigate to the created project directory and run the following command.
polymer serve
Now open the browser and navigate to http://127.0.0.1:8081/. Following will be the output.
polymer_elements.htm
Advertisements