Badge - 图1

Badge

Badges are used to display/indicate count numbers and labels on different elements of your app.

Badge Layout

Badges have a super simple layout, it’s just an element with a **badge** class:

  1. <span class="badge">32</span>

Badge Colors

Badges support all default colors:

  1. <!-- Green badge -->
  2. <span class="badge color-green">32</span>
  3. <!-- Red badge -->
  4. <span class="badge color-red">15</span>

CSS Variables

Below is the list of related CSS variables (CSS custom properties).

  1. :root {
  2. --f7-badge-text-color: #fff;
  3. --f7-badge-bg-color: #8e8e93;
  4. --f7-badge-padding: 0 4px;
  5. --f7-badge-in-icon-size: 16px;
  6. --f7-badge-in-icon-font-size: 10px;
  7. --f7-badge-font-weight: normal;
  8. --f7-badge-font-size: 12px;
  9. }
  10. .ios {
  11. --f7-badge-size: 20px;
  12. }
  13. .md {
  14. --f7-badge-size: 18px;
  15. }
  16. .aurora {
  17. --f7-badge-size: 18px;
  18. --f7-badge-font-weight: 600;
  19. --f7-badge-in-icon-size: 15px;
  20. }

Examples

  1. <div class="page">
  2. <div class="navbar">
  3. <div class="navbar-inner">
  4. <div class="left"></div>
  5. <div class="title">Badge</div>
  6. <div class="right">
  7. <a class="link icon-only">
  8. <i class="icon f7-icons if-not-md">person_fill<span class="badge color-red">5</span></i>
  9. <i class="icon material-icons md-only">person<span class="badge color-red">5</span></i>
  10. </a>
  11. </div>
  12. </div>
  13. </div>
  14. <div class="toolbar tabbar tabbar-labels toolbar-bottom">
  15. <div class="toolbar-inner">
  16. <a href="#tab-1" class="tab-link tab-link-active">
  17. <i class="icon icon-fill f7-icons if-not-md">email_fill<span class="badge color-green">5</span></i>
  18. <i class="icon material-icons md-only">email<span class="badge color-green">5</span></i>
  19. <span class="tabbar-label">Inbox</span>
  20. </a>
  21. <a href="#tab-2" class="tab-link">
  22. <i class="icon f7-icons if-not-md">today<span class="badge color-red">7</span></i>
  23. <i class="icon material-icons md-only">today<span class="badge color-red">7</span></i>
  24. <span class="tabbar-label">Calendar</span>
  25. </a>
  26. <a href="#tab-3" class="tab-link">
  27. <i class="icon f7-icons if-not-md">cloud<span class="badge color-red">1</span></i>
  28. <i class="icon material-icons md-only">file_upload<span class="badge color-red">1</span></i>
  29. <span class="tabbar-label">Upload</span>
  30. </a>
  31. </div>
  32. </div>
  33. <div class="page-content">
  34. <div class="list">
  35. <ul>
  36. <li>
  37. <div class="item-content">
  38. <div class="item-inner">
  39. <div class="item-title">Foo Bar</div>
  40. <div class="item-after"><span class="badge">0</span></div>
  41. </div>
  42. </div>
  43. </li>
  44. <li>
  45. <div class="item-content">
  46. <div class="item-inner">
  47. <div class="item-title">Ivan Petrov</div>
  48. <div class="item-after"><span class="badge color-blue">CEO</span></div>
  49. </div>
  50. </div>
  51. </li>
  52. <li>
  53. <div class="item-content">
  54. <div class="item-inner">
  55. <div class="item-title">John Doe</div>
  56. <div class="item-after"><span class="badge color-green">5</span></div>
  57. </div>
  58. </div>
  59. </li>
  60. <li>
  61. <div class="item-content">
  62. <div class="item-inner">
  63. <div class="item-title">Jane Doe</div>
  64. <div class="item-after"><span class="badge color-orange">NEW</span></div>
  65. </div>
  66. </div>
  67. </li>
  68. </ul>
  69. </div>
  70. </div>
  71. </div>