Button - 图1

Button

Framework7 comes with a bunch of ready to use buttons. All you need to do is add the appropriate classes to your links or submit/button inputs:

Button Layout

Button layout is pretty simple. Just add button class to links or submit/button inputs:

  1. <!-- link as button -->
  2. <a class="button">Button</a>
  3. <!-- <button> as button -->
  4. <button class="button">Button</button>
  5. <!-- <input type="submit"> as button -->
  6. <input type="submit" class="button" value="Button">

Button Modifier Classes

There is a variety of different buttons in Framework7. Different button styles achieved by additional modifier classes and their combinations:

button-fillFilled-style button
button-fill-iosButton will have filled-style only in iOS theme
button-fill-mdButton will have filled-style only in MD theme
button-fill-auroraButton will have filled-style only in Aurora theme
button-roundRounded button
button-round-iosButton will be rounded only in iOS theme
button-round-mdButton will be rounded only in MD theme
button-round-auroraButton will be rounded only in Aurora theme
button-smallSmall button
button-small-iosButton will be small only in iOS theme
button-small-mdButton will be small only in MD theme
button-small-auroraButton will be small only in Aurora theme
button-largeLarge button
button-large-iosButton will be large only in iOS theme
button-large-mdButton will be large only in MD theme
button-large-auroraButton will be large only in Aurora theme
button-raisedRaised button
button-raised-iosRaised button in iOS theme only
button-raised-mdRaised button in MD theme only
button-raised-auroraRaised button in Aurora theme only
button-outlineOutline button
button-outline-iosOutline button in iOS theme only
button-outline-mdOutline button in MD theme only
button-outline-auroraOutline button in Aurora theme only
button-activeActive/selected button state. For use inside of Segmented
color-[color]Color button, where [color] is one of the default colors

And of course we can mix these classes:

  1. <!-- rounded button -->
  2. <a class="button button-round">Button</a>
  3. <!-- rounded and filled button -->
  4. <a class="button button-round button-fill">Button</a>
  5. <!-- raised, round, fill, large button -->
  6. <a class="button button-raised button-round button-fill button-large">Button</a>
  7. <!-- small red button -->
  8. <a class="button button-small color-red">Button</a>

Segmented Control

A segmented control is a linear set of two or more segments (buttons), each of which functions as a mutually exclusive button. Within the control, all buttons are equal in width. Segmented controls are often used to display different views (switch tabs).

Segmented Layout

Segmented control layout is pretty simple, just a <div> with a segmented class around buttons:

  1. <div class="segmented">
  2. <a class="button button-active">Tab 1</a>
  3. <a class="button">Tab 2</a>
  4. </div>

Segmented “strong” requires additional element to correctly indicate active state:

  1. <div class="segmented segmented-strong">
  2. <a class="button button-active">Tab 1</a>
  3. <a class="button">Tab 2</a>
  4. <!-- addition element required in segmented strong -->
  5. <span class="segmented-highlight"></span>
  6. </div>

Segmented Modifier Classes

As well as buttons, segmented also supports few additional classes for styling:

segmented-roundRounded segmented
segmented-round-iosRounded segmented in iOS theme
segmented-round-mdRounded segmented in MD theme
segmented-round-auroraRounded segmented in Aurora theme
segmented-raisedRaised segmented
segmented-raised-iosRaised segmented in iOS theme
segmented-raised-mdRaised segmented in MD theme
segmented-raised-auroraRaised segmented in Aurora theme
segmented-strongStrong segmented
segmented-strong-iosStrong segmented in iOS theme
segmented-strong-mdStrong segmented in MD theme
segmented-strong-auroraStrong segmented in Aurora theme

CSS Variables

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

Note that commented variables are not specified by default and their values is what they fallback to in this case.

  1. :root {
  2. --f7-button-min-width: 32px;
  3. --f7-button-bg-color: transparent;
  4. --f7-button-border-width: 0px;
  5. /*
  6. --f7-button-text-color: var(--f7-theme-color);
  7. --f7-button-pressed-text-color: var(--f7-button-text-color, var(--f7-theme-color));
  8. --f7-button-border-color: var(--f7-theme-color);
  9. --f7-button-fill-text-color: #fff;
  10. --f7-button-fill-bg-color: var(--f7-theme-color);
  11. --f7-button-outline-border-color: var(--f7-theme-color);
  12. */
  13. --f7-button-outline-border-width: 2px;
  14. --f7-button-raised-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0,0,0,0.24);
  15. --f7-button-raised-pressed-box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0,0,0,0.23);
  16. --f7-segmented-raised-divider-color: rgba(0, 0, 0, 0.1);
  17. --f7-segmented-strong-padding: 2px;
  18. --f7-segmented-strong-between-buttons: 4px;
  19. --f7-segmented-strong-button-font-weight: 500;
  20. --f7-segmented-strong-button-active-box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.25);
  21. --f7-segmented-strong-bg-color: rgba(0, 0, 0, 0.07);
  22. --f7-segmented-strong-button-text-color: #000;
  23. --f7-segmented-strong-button-pressed-bg-color: rgba(0, 0, 0, 0.07);
  24. --f7-segmented-strong-button-hover-bg-color: rgba(0, 0, 0, 0.04);
  25. --f7-segmented-strong-button-active-text-color: #000;
  26. --f7-segmented-strong-button-active-bg-color: #fff;
  27. }
  28. :root .theme-dark,
  29. :root.theme-dark {
  30. --f7-segmented-strong-bg-color: rgba(255, 255, 255, 0.1);
  31. --f7-segmented-strong-button-pressed-bg-color: rgba(255, 255, 255, 0.04);
  32. --f7-segmented-strong-button-hover-bg-color: rgba(255, 255, 255, 0.02);
  33. --f7-segmented-strong-button-active-bg-color: rgba(255, 255, 255, 0.14);
  34. --f7-segmented-strong-button-text-color: #fff;
  35. --f7-segmented-strong-button-active-text-color: #fff;
  36. }
  37. .ios {
  38. --f7-button-font-size: 13px;
  39. --f7-button-height: 28px;
  40. --f7-button-padding-horizontal: 10px;
  41. --f7-button-border-radius: 5px;
  42. --f7-button-font-weight: 600;
  43. --f7-button-letter-spacing: 0;
  44. --f7-button-text-transform: uppercase;
  45. /*
  46. --f7-button-pressed-bg-color: rgba(var(--f7-theme-color-rgb), .15);
  47. --f7-button-fill-pressed-bg-color: var(--f7-theme-color-tint);
  48. */
  49. --f7-button-large-height: 44px;
  50. --f7-button-large-font-size: 17px;
  51. --f7-button-large-font-weight: 500;
  52. --f7-button-large-text-transform: none;
  53. --f7-button-small-height: 26px;
  54. --f7-button-small-font-size: 13px;
  55. --f7-button-small-font-weight: 600;
  56. --f7-button-small-text-transform: uppercase;
  57. --f7-button-small-outline-border-width: 2px;
  58. --f7-segmented-strong-button-text-transform: none;
  59. --f7-segmented-strong-button-active-font-weight: 600;
  60. }
  61. .md {
  62. --f7-button-font-size: 14px;
  63. --f7-button-height: 36px;
  64. --f7-button-padding-horizontal: 8px;
  65. --f7-button-border-radius: 4px;
  66. --f7-button-font-weight: 500;
  67. --f7-button-letter-spacing: 0.03em;
  68. --f7-button-text-transform: uppercase;
  69. /*
  70. --f7-button-fill-pressed-bg-color: var(--f7-theme-color-shade);
  71. */
  72. --f7-button-large-height: 48px;
  73. --f7-button-large-font-size: 14px;
  74. --f7-button-large-font-weight: 500;
  75. --f7-button-large-text-transform: uppercase;
  76. --f7-button-small-height: 28px;
  77. --f7-button-small-font-size: 12px;
  78. --f7-button-small-font-weight: 500;
  79. --f7-button-small-text-transform: uppercase;
  80. --f7-button-small-outline-border-width: 2px;
  81. --f7-segmented-strong-button-text-transform: uppercase;
  82. --f7-segmented-strong-button-active-font-weight: 500;
  83. --f7-button-pressed-bg-color: rgba(0, 0, 0, 0.1);
  84. }
  85. .md .theme-dark,
  86. .md.theme-dark {
  87. --f7-button-pressed-bg-color: rgba(255, 255, 255, 0.1);
  88. }
  89. .aurora {
  90. /*
  91. --f7-button-hover-bg-color: rgba(var(--f7-theme-color-rgb), .07);
  92. --f7-button-fill-hover-bg-color: var(--f7-theme-color-tint);
  93. */
  94. --f7-button-font-size: 14px;
  95. --f7-button-height: 28px;
  96. --f7-button-min-width: 24px;
  97. --f7-button-padding-horizontal: 10px;
  98. --f7-button-border-radius: 4px;
  99. --f7-button-font-weight: 500;
  100. --f7-button-letter-spacing: 0.02;
  101. --f7-button-text-transform: none;
  102. /*
  103. --f7-button-pressed-bg-color: rgba(var(--f7-theme-color-rgb), .15);
  104. --f7-button-fill-pressed-bg-color: var(--f7-theme-color-shade);
  105. */
  106. --f7-button-large-height: 34px;
  107. --f7-button-large-font-size: 14px;
  108. --f7-button-large-font-weight: 600;
  109. --f7-button-large-text-transform: none;
  110. --f7-button-small-height: 24px;
  111. --f7-button-small-font-size: 12px;
  112. --f7-button-small-font-weight: 600;
  113. --f7-button-small-text-transform: none;
  114. --f7-button-small-outline-border-width: 1px;
  115. --f7-segmented-strong-button-text-transform: none;
  116. --f7-segmented-strong-button-active-font-weight: 600;
  117. }

Examples

Usual Buttons

Add button class.

  1. <div class="block">
  2. <div class="row">
  3. <button class="button col">Button</button>
  4. <button class="button col">Button</button>
  5. <button class="button col button-round">Round</button>
  6. </div>
  7. </div>

Fill Buttons

Add button-fill class.

  1. <div class="block">
  2. <div class="row">
  3. <button class="col button button-fill">Button</button>
  4. <button class="col button button-fill">Button</button>
  5. <button class="col button button-fill button-round">Round</button>
  6. </div>
  7. </div>

Outline Buttons

Add button-outline class.

  1. <div class="block">
  2. <div class="row">
  3. <button class="col button button-outline">Button</button>
  4. <button class="col button button-outline">Button</button>
  5. <button class="col button button-outline button-round">Round</button>
  6. </div>
  7. </div>

Raised Buttons

Add button-raised class.

  1. <div class="block">
  2. <p class="row">
  3. <button class="col button button-raised">Button</button>
  4. <button class="col button button-raised button-fill">Fill</button>
  5. <button class="col button button-outline button-raised">Outline</button>
  6. </p>
  7. <p class="row">
  8. <button class="col button button-raised button-round">Round</button>
  9. <button class="col button button-raised button-fill button-round">Fill</button>
  10. <button class="col button button-outline button-round button-raised">Outline</button>
  11. </p>
  12. </div>

Segmented Buttons

Put buttons inside of segmented

  1. <div class="block">
  2. <p class="segmented segmented-raised">
  3. <button class="button">Button</button>
  4. <button class="button">Button</button>
  5. <button class="button button-active">Active</button>
  6. </p>
  7. <p class="segmented segmented-strong">
  8. <button class="button">Button</button>
  9. <button class="button">Button</button>
  10. <button class="button button-active">Active</button>
  11. <span class="segmented-highlight"></span>
  12. </p>
  13. <p class="segmented">
  14. <button class="button button-outline">Outline</button>
  15. <button class="button button-outline">Outline</button>
  16. <button class="button button-outline button-active">Active</button>
  17. </p>
  18. <p class="segmented segmented-raised segmented-round">
  19. <button class="button button-round">Button</button>
  20. <button class="button button-round">Button</button>
  21. <button class="button button-round button-active">Active</button>
  22. </p>
  23. <p class="segmented segmented-round">
  24. <button class="button button-round button-outline">Outline</button>
  25. <button class="button button-round button-outline">Outline</button>
  26. <button class="button button-round button-outline button-active">Active</button>
  27. </p>
  28. </div>

Large Buttons

Add button-large class.

  1. <div class="block">
  2. <p class="row">
  3. <button class="col button button-large">Button</button>
  4. <button class="col button button-large button-fill">Fill</button>
  5. </p>
  6. <p class="row">
  7. <button class="col button button-large button-raised">Raised</button>
  8. <button class="col button button-large button-raised button-fill">Raised Fill</button>
  9. </p>
  10. </div>

Small Buttons

Add button-small class.

  1. <div class="block">
  2. <p class="row">
  3. <button class="col button button-small">Button</button>
  4. <button class="col button button-small button-outline">Outline</button>
  5. <button class="col button button-small button-fill">Fill</button>
  6. </p>
  7. <p class="row">
  8. <button class="col button button-small button-round">Button</button>
  9. <button class="col button button-small button-round button-outline">Outline</button>
  10. <button class="col button button-small button-round button-fill">Fill</button>
  11. </p>
  12. </div>

Color Buttons

Add color-[color] class. Where [color] is one of the default colors.

  1. <div class="block">
  2. <p class="row">
  3. <button class="col button color-red">Red</button>
  4. <button class="col button color-green">Green</button>
  5. <button class="col button color-blue">Blue</button>
  6. </p>
  7. <p class="row">
  8. <button class="col button color-pink">Pink</button>
  9. <button class="col button color-yellow">Yellow</button>
  10. <button class="col button color-orange">Orange</button>
  11. </p>
  12. <p class="row">
  13. <button class="col button color-gray">Gray</button>
  14. <button class="col button color-black">Black</button>
  15. </p>
  16. </div>

Color Fill Buttons

Add button-fill and color-[color] class. Where [color] is one of the default colors.

  1. <div class="block">
  2. <p class="row">
  3. <button class="col button button-fill color-red">Red</button>
  4. <button class="col button button-fill color-green">Green</button>
  5. <button class="col button button-fill color-blue">Blue</button>
  6. </p>
  7. <p class="row">
  8. <button class="col button button-fill color-pink">Pink</button>
  9. <button class="col button button-fill color-yellow">Yellow</button>
  10. <button class="col button button-fill color-orange">Orange</button>
  11. </p>
  12. <p class="row">
  13. <button class="col button button-fill color-gray">Gray</button>
  14. <button class="col button button-fill color-black">Black</button>
  15. <button class="col button button-fill color-white text-color-black">White</button>
  16. </p>
  17. </div>

← Block / Content Block

Calendar / Datepicker →