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 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

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-font-size: 14px;
  3. --f7-button-min-width: 32px;
  4. --f7-button-bg-color: transparent;
  5. --f7-button-border-width: 0px;
  6. /*
  7. --f7-button-text-color: var(--f7-theme-color);
  8. --f7-button-pressed-text-color: var(--f7-button-text-color, var(--f7-theme-color));
  9. --f7-button-border-color: var(--f7-theme-color);
  10. --f7-button-fill-text-color: #fff;
  11. --f7-button-fill-bg-color: var(--f7-theme-color);
  12. --f7-button-outline-border-color: var(--f7-theme-color);
  13. */
  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. }
  18. .ios {
  19. --f7-button-height: 29px;
  20. --f7-button-padding-horizontal: 10px;
  21. --f7-button-border-radius: 5px;
  22. --f7-button-font-weight: 400;
  23. --f7-button-letter-spacing: 0;
  24. --f7-button-text-transform: none;
  25. /*
  26. --f7-button-pressed-bg-color: rgba(var(--f7-theme-color-rgb), .15);
  27. --f7-button-fill-pressed-bg-color: var(--f7-theme-color-tint);
  28. */
  29. --f7-button-outline-border-width: 1px;
  30. --f7-button-large-height: 44px;
  31. --f7-button-large-font-size: 17px;
  32. --f7-button-large-font-weight: 400;
  33. --f7-button-small-height: 26px;
  34. --f7-button-small-font-size: 13px;
  35. --f7-button-small-font-weight: 600;
  36. --f7-button-small-text-transform: uppercase;
  37. --f7-button-small-outline-border-width: 2px;
  38. }
  39. .md {
  40. --f7-button-height: 36px;
  41. --f7-button-padding-horizontal: 8px;
  42. --f7-button-border-radius: 4px;
  43. --f7-button-font-weight: 500;
  44. --f7-button-letter-spacing: 0.03em;
  45. --f7-button-text-transform: uppercase;
  46. --f7-button-pressed-bg-color: rgba(0, 0, 0, 0.1);
  47. /*
  48. --f7-button-fill-pressed-bg-color: var(--f7-theme-color-shade);
  49. */
  50. --f7-button-outline-border-width: 2px;
  51. --f7-button-large-height: 48px;
  52. --f7-button-large-font-size: 14px;
  53. --f7-button-large-font-weight: 500;
  54. --f7-button-small-height: 28px;
  55. --f7-button-small-font-size: 12px;
  56. --f7-button-small-font-weight: 500;
  57. --f7-button-small-text-transform: uppercase;
  58. --f7-button-small-outline-border-width: 2px;
  59. }
  60. .md .theme-dark,
  61. .md.theme-dark {
  62. --f7-button-pressed-bg-color: rgba(255, 255, 255, 0.1);
  63. }
  64. .aurora {
  65. /*
  66. --f7-button-hover-bg-color: rgba(var(--f7-theme-color-rgb), .07);
  67. --f7-button-fill-hover-bg-color: var(--f7-theme-color-tint);
  68. */
  69. --f7-button-font-size: 14px;
  70. --f7-button-height: 28px;
  71. --f7-button-min-width: 24px;
  72. --f7-button-padding-horizontal: 10px;
  73. --f7-button-border-radius: 4px;
  74. --f7-button-font-weight: 400;
  75. --f7-button-letter-spacing: 0.02;
  76. --f7-button-text-transform: none;
  77. /*
  78. --f7-button-pressed-bg-color: rgba(var(--f7-theme-color-rgb), .15);
  79. --f7-button-fill-pressed-bg-color: var(--f7-theme-color-shade);
  80. */
  81. --f7-button-outline-border-width: 2px;
  82. --f7-button-large-height: 34px;
  83. --f7-button-large-font-size: 14px;
  84. --f7-button-large-font-weight: 600;
  85. --f7-button-small-height: 22px;
  86. --f7-button-small-font-size: 12px;
  87. --f7-button-small-font-weight: 600;
  88. --f7-button-small-text-transform: none;
  89. --f7-button-small-outline-border-width: 1px;
  90. }

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">
  8. <button class="button button-outline">Outline</button>
  9. <button class="button button-outline">Outline</button>
  10. <button class="button button-outline button-active">Active</button>
  11. </p>
  12. <p class="segmented segmented-raised segmented-round">
  13. <button class="button button-round">Button</button>
  14. <button class="button button-round">Button</button>
  15. <button class="button button-round button-active">Active</button>
  16. </p>
  17. <p class="segmented segmented-round">
  18. <button class="button button-round button-outline">Outline</button>
  19. <button class="button button-round button-outline">Outline</button>
  20. <button class="button button-round button-outline button-active">Active</button>
  21. </p>
  22. </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>