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-roundRounded button
button-round-iosButton will be rounded only in iOS theme
button-round-mdButton will be rounded only in MD 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-bigBig button
button-big-iosButton will be big only in iOS theme
button-big-mdButton will be big only in MD theme
button-raisedRaised button This will have effect only in MD theme
button-outlineOutline button This will have effect only in MD theme
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, big button -->
  6. <a class="button button-round button-fill button-raised button-fill">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-raisedRaised segmented  This will have effect only in MD theme

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>

Big Buttons

Add button-big class.

  1. <div class="block">
  2. <p class="row">
  3. <button class="col button button-big">Button</button>
  4. <button class="col button button-big button-fill">Fill</button>
  5. </p>
  6. <p class="row">
  7. <button class="col button button-big button-raised">Raised</button>
  8. <button class="col button button-big 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>