Polymer - Paper Fab
Paper-fab is a floating action button, which provides a ripple effect, when the user touches the button. This button can have an image placed in the center. To get paper-fab and ironicons in your directory, you should run the following command in the command prompt.
bower install --save PolymerElements/paper-fab
Example
The following example specifies the use of paper-ripple 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/iron-icons/iron-icons.html">
<link rel = "import" href = "bower_components/paper-fab/paper-fab.html">
<dom-module id = 'my-app'>
<template>
<style is = "custom-style">
paper-fab {
display: inline-block;
margin: 8px;
}
paper-fab[mini] {
--paper-fab-background: #FF5722;
}
paper-fab[label] {
font-size: 20px;
--paper-fab-background: #2196F3;
}
</style>
<h3>Paper-Fab Example </h3>
<paper-fab icon = "alarm-on"></paper-fab>
<paper-fab mini icon = "android"></paper-fab>
<paper-fab mini icon = "home"></paper-fab>
</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