Bootstrap Buttons

1.1

Button styles can be applied to anything with the .btn class applied.
However, typically you'll want to apply these to only a and button elements for the best rendering.

  • :hover - Buttons love hover states.
  • :focus - Keyboard accessibility.
  • :active - Button pressed.
  • .active - Same as the active pseudo-class.
  • .disabled - For when you shouldn't be able to click on it.
  • .btn-primary - Provides extra visual weight and identifies the primary action in a set of buttons.
  • .btn-info - Used as an alternative to the default styles.
  • .btn-success - Indicates a successful or positive action
  • .btn-warning - Indicates caution should be taken with this action
  • .btn-danger - Indicates a dangerous or potentially negative action
  • .btn-inverse - Alternate dark gray button, not tied to a semantic action or use
Example Button Link
:hover Example Button Link
:focus Example Button Link
:active Example Button Link
.active Example Button Link
.disabled Example Button Link
.btn-primary Example Button Link
.btn-info Example Button Link
.btn-success Example Button Link
.btn-warning Example Button Link
.btn-danger Example Button Link
.btn-inverse Example Button Link
1
2
    <button class="btn">Example Button</button>
    <a class="btn" href="#">Example Button Link</a>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
  /*
  Button styles can be applied to anything with the .btn class applied.<br/>
  However, typically you'll want to apply these to only a and button elements for the best rendering.

  :hover        - Buttons love hover states.
  :focus        - Keyboard accessibility.
  :active       - Button pressed.
  .active       - Same as the active pseudo-class.
  .disabled     - For when you shouldn't be able to click on it.
  .btn-primary  - Provides extra visual weight and identifies the primary action in a set of buttons.
  .btn-info     - Used as an alternative to the default styles.
  .btn-success  - Indicates a successful or positive action
  .btn-warning  - Indicates caution should be taken with this action
  .btn-danger   - Indicates a dangerous or potentially negative action
  .btn-inverse  - Alternate dark gray button, not tied to a semantic action or use

  Styleguide 1.1
  */

  @import 'src/css/plugins/bootstrap-variables';
  @import 'src/css/plugins/bootstrap-mixins';

  .btn {
    display: inline-block;
    @include ie7-inline-block();
    padding: 4px 12px;
    margin-bottom: 0; // For input.btn
    font-size: $baseFontSize;
    line-height: $baseLineHeight;
    *line-height: $baseLineHeight;
    text-align: center;
    vertical-align: middle;
    cursor: pointer;
    @include buttonBackground($btnBackground, $btnBackgroundHighlight, $grayDark, 0 1px 1px rgba(255,255,255,.75));
    border: 1px solid $btnBorder;
    *border: 0; // Remove the border to prevent IE7's black border on input:focus
    border-bottom-color: darken($btnBorder, 10%);
    @include border-radius($baseBorderRadius);
    @include ie7-restore-left-whitespace(); // Give IE7 some love
    @include box-shadow(inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05));

    // Hover state
    &:hover {
      color: $grayDark;
      text-decoration: none;
      background-color: darken($white, 10%);
      *background-color: darken($white, 15%); /* Buttons in IE7 don't get borders, so darken on hover */
      background-position: 0 -15px;

      // transition is only when going to hover, otherwise the background
      // behind the gradient (there for IE<=9 fallback) gets mismatched
      @include transition(background-position .1s linear);
    }

    // Focus state for keyboard and accessibility
    &:focus {
      @include tab-focus();
    }

    // Active state
    &.active,
    &:active {
      background-color: darken($white, 10%);
      background-color: darken($white, 15%) \9;
      background-image: none;
      outline: 0;
      @include box-shadow(inset 0 2px 4px rgba(0,0,0,.15), 0 1px 2px rgba(0,0,0,.05));
    }

    // Disabled state
    &.disabled,
    &[disabled] {
      cursor: default;
      background-color: darken($white, 10%);
      background-image: none;
      @include opacity(65);
      @include box-shadow(none);
    }
  }

  // Alternate buttons
  // --------------------------------------------------

  // Provide *some* extra contrast for those who can get it
  .btn-primary.active,
  .btn-warning.active,
  .btn-danger.active,
  .btn-success.active,
  .btn-info.active,
  .btn-inverse.active {
    color: rgba(255,255,255,.75);
  }

  // Set the backgrounds
  // -------------------------
  .btn {
    // reset here as of 2.0.3 due to Recess property order
    border-color: #c5c5c5;
    border-color: rgba(0,0,0,.15) rgba(0,0,0,.15) rgba(0,0,0,.25);
  }
  .btn-primary {
    @include buttonBackground($btnPrimaryBackground, $btnPrimaryBackgroundHighlight);
  }
  // Warning appears are orange
  .btn-warning {
    @include buttonBackground($btnWarningBackground, $btnWarningBackgroundHighlight);
  }
  // Danger and error appear as red
  .btn-danger {
    @include buttonBackground($btnDangerBackground, $btnDangerBackgroundHighlight);
  }
  // Success appears as green
  .btn-success {
    @include buttonBackground($btnSuccessBackground, $btnSuccessBackgroundHighlight);
  }
  // Info appears as a neutral blue
  .btn-info {
    @include buttonBackground($btnInfoBackground, $btnInfoBackgroundHighlight);
  }
  // Inverse appears as dark gray
  .btn-inverse {
    @include buttonBackground($btnInverseBackground, $btnInverseBackgroundHighlight);
  }

1.2

Fancy larger or smaller buttons? Add .btn-large, .btn-small, or .btn-mini for additional sizes.

  • .btn-large - Buttons love hover states.
  • .btn-small - Buttons love hover states.
  • .btn-mini - Buttons love hover states.
.btn-large
.btn-small
.btn-mini
1
    <button class="btn">Example Button</button>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
  /*
  Fancy larger or smaller buttons? Add .btn-large, .btn-small, or .btn-mini for additional sizes.

  .btn-large - Buttons love hover states.
  .btn-small - Buttons love hover states.
  .btn-mini  - Buttons love hover states.

  Styleguide 1.2
  */

  @import 'src/css/plugins/bootstrap-variables';
  @import 'src/css/plugins/bootstrap-mixins';

  .btn {
    display: inline-block;
    @include ie7-inline-block();
    padding: 4px 12px;
    margin-bottom: 0; // For input.btn
    font-size: $baseFontSize;
    line-height: $baseLineHeight;
    *line-height: $baseLineHeight;
    text-align: center;
    vertical-align: middle;
    cursor: pointer;
    @include buttonBackground($btnBackground, $btnBackgroundHighlight, $grayDark, 0 1px 1px rgba(255,255,255,.75));
    border: 1px solid $btnBorder;
    *border: 0; // Remove the border to prevent IE7's black border on input:focus
    border-bottom-color: darken($btnBorder, 10%);
    @include border-radius($baseBorderRadius);
    @include ie7-restore-left-whitespace(); // Give IE7 some love
    @include box-shadow(inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05));

    // Hover state
    &:hover {
      color: $grayDark;
      text-decoration: none;
      background-color: darken($white, 10%);
      *background-color: darken($white, 15%); /* Buttons in IE7 don't get borders, so darken on hover */
      background-position: 0 -15px;

      // transition is only when going to hover, otherwise the background
      // behind the gradient (there for IE<=9 fallback) gets mismatched
      @include transition(background-position .1s linear);
    }

    // Focus state for keyboard and accessibility
    &:focus {
      @include tab-focus();
    }

    // Active state
    &.active,
    &:active {
      background-color: darken($white, 10%);
      background-color: darken($white, 15%) \9;
      background-image: none;
      outline: 0;
      @include box-shadow(inset 0 2px 4px rgba(0,0,0,.15), 0 1px 2px rgba(0,0,0,.05));
    }

    // Disabled state
    &.disabled,
    &[disabled] {
      cursor: default;
      background-color: darken($white, 10%);
      background-image: none;
      @include opacity(65);
      @include box-shadow(none);
    }
  }

  // Large
  .btn-large {
    padding: $paddingLarge;
    font-size: $fontSizeLarge;
    @include border-radius($borderRadiusLarge);
  }
  .btn-large [class^="icon-"],
  .btn-large [class*=" icon-"] {
    margin-top: 2px;
  }

  // Small
  .btn-small {
    padding: $paddingSmall;
    font-size: $fontSizeSmall;
    @include border-radius($borderRadiusSmall);
  }
  .btn-small [class^="icon-"],
  .btn-small [class*=" icon-"] {
    margin-top: 0;
  }

  // Mini
  .btn-mini {
    padding: $paddingMini;
    font-size: $fontSizeMini;
    @include border-radius($borderRadiusSmall);
  }