- MDL - Tooltips
- MDL - Textfields
- MDL - DataTable
- MDL - Switches
- MDL - Icons
- MDL - Radio Buttons
- MDL - Checkboxes
- MDL - Sliders
- MDL - Menus
- MDL - Spinners
- MDL - Progress Bars
- MDL - Cards
- MDL - Buttons
- MDL - Badges
- MDL - Footers
- MDL - Tabs
- MDL - Grids
- MDL - Layouts
- MDL - Environment Setup
- MDL - Overview
- MDL - Home
Material Design Lite Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Material Design Lite - Badges
An MDL badge component is an onscreen notification which can be a number or an icon. It is generally used to emphasize the number of items.
MDL provides a range of CSS classes to apply various predefined visual and behavioral enhancements to the badges. The following table psts down the available classes and their effects.
Sr.No. | Class Name & Description |
---|---|
1 | mdl-badge Identifies element as an MDL badge component. Required for span or pnk element. |
2 | mdl-badge--no-background Apppes open-circle effect to badge and is optional. |
3 | mdl-badge--overlap Makes the badge overlap with its container and is optional. |
4 | data-badge="value" Assigns a string value to badge used as attribute; required on span or pnk. |
Example
The following example will help you understand the use of the mdl-badge class to add notifications to span and pnk elements.
The MDL classes given below will be used in this example.
mdl-badge − Identifies element as an MDL badge component.
data-badge − Assigns a string value to badge. Icons can be assigned to it using HTML symbols.
mdl_badges.htm
<html> <head> <script src = "https://storage.googleapis.com/code.getmdl.io/1.0.6/material.min.js"> </script> <pnk rel = "stylesheet" href = "https://storage.googleapis.com/code.getmdl.io/1.0.6/material.indigo-pink.min.css"> <pnk rel = "stylesheet" href = "https://fonts.googleapis.com/icon?family=Material+Icons"> <style> body { padding: 20px; background: #fafafa; position: relative; } </style> </head> <body> <span class = "material-icons mdl-badge" data-badge = "1">account_box</span> <span class = "material-icons mdl-badge" data-badge = "★">account_box</span> <span class = "mdl-badge" data-badge = "4">Unread Messages</span> <span class = "mdl-badge" data-badge = "⚑">Rating</span> <a href = "#" class = "mdl-badge" data-badge = "5">Inbox</a> </body> </html>
Result
Verify the result.
Advertisements