Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies – such as screen readers. Ensure that information denoted by the color is either obvious from the content itself (e.g. the visible text), or is included through alternative means, such as additional text hidden with the
.visually-hidden
class.
$btn-padding-y:$input-btn-padding-y;$btn-padding-x:$input-btn-padding-x;$btn-font-family:$input-btn-font-family;$btn-font-size:$input-btn-font-size;$btn-line-height:$input-btn-line-height;$btn-white-space:null;// Set to `nowrap` to prevent text wrapping
$btn-padding-y-sm:$input-btn-padding-y-sm;$btn-padding-x-sm:$input-btn-padding-x-sm;$btn-font-size-sm:$input-btn-font-size-sm;$btn-padding-y-lg:$input-btn-padding-y-lg;$btn-padding-x-lg:$input-btn-padding-x-lg;$btn-font-size-lg:$input-btn-font-size-lg;$btn-border-width:$input-btn-border-width;$btn-font-weight:$font-weight-normal;$btn-box-shadow:inset01px0rgba($white,.15),01px1pxrgba($black,.075);$btn-focus-width:$input-btn-focus-width;$btn-focus-box-shadow:$input-btn-focus-box-shadow;$btn-disabled-opacity:.65;$btn-active-box-shadow:inset03px5pxrgba($black,.125);$btn-link-color:$link-color;$btn-link-hover-color:$link-hover-color;$btn-link-disabled-color:$gray-600;// Allows for customizing button radius independently from global border radius
$btn-border-radius:$border-radius;$btn-border-radius-sm:$border-radius-sm;$btn-border-radius-lg:$border-radius-lg;$btn-transition:color.15sease-in-out,background-color.15sease-in-out,border-color.15sease-in-out,box-shadow.15sease-in-out;$btn-hover-bg-shade-amount:15%;$btn-hover-bg-tint-amount:15%;$btn-hover-border-shade-amount:20%;$btn-hover-border-tint-amount:10%;$btn-active-bg-shade-amount:20%;$btn-active-bg-tint-amount:20%;$btn-active-border-shade-amount:25%;$btn-active-border-tint-amount:10%;
Mixins
There are three mixins for buttons: button and button outline variant mixins (both based on $theme-colors), plus a button size mixin.
@mixin button-variant($background,$border,$color:color-contrast($background),$hover-background:if($color==$color-contrast-light,shade-color($background,$btn-hover-bg-shade-amount),tint-color($background,$btn-hover-bg-tint-amount)),$hover-border:if($color==$color-contrast-light,shade-color($border,$btn-hover-border-shade-amount),tint-color($border,$btn-hover-border-tint-amount)),$hover-color:color-contrast($hover-background),$active-background:if($color==
$color-contrast-light,shade-color($background,$btn-active-bg-shade-amount),tint-color($background,$btn-active-bg-tint-amount)),$active-border:if($color==$color-contrast-light,shade-color($border,$btn-active-border-shade-amount),tint-color($border,$btn-active-border-tint-amount)),$active-color:color-contrast($active-background),$disabled-background:$background,$disabled-border:$border,$disabled-color:color-contrast($disabled-background)color:$color;@include gradient-bg($background);border-color:$border;@include box-shadow($btn-box-shadow);&:hover{color:$hover-color;@include gradient-bg($hover-background);border-color:$hover-border;.btn-check:focus+&,&:focus{color:$hover-color;@include gradient-bg($hover-background);border-color:$hover-border;@if$enable-shadows{@include box-shadow($btn-box-shadow,000$btn-focus-widthrgba(mix($color,$border,15%),.5));}@else{// Avoid using mixin so we can pass custom focus shadow properly
box-shadow:000$btn-focus-widthrgba(mix($color,$border,15%),.5);.btn-check:checked+&,.btn-check:active+&,&:active,&.active,.show>&.dropdown-toggle{color:$active-color;background-color:$active-background;// Remove CSS gradients if they're enabled
background-image:if($enable-gradients,none,null);border-color:$active-border;&:focus{@if$enable-shadows{@include box-shadow($btn-active-box-shadow,000$btn-focus-widthrgba(mix($color,$border,15%),.5));}@else{// Avoid using mixin so we can pass custom focus shadow properly
box-shadow:000$btn-focus-widthrgba(mix($color,$border,15%),.5);&:disabled,&.disabled{color:$disabled-color;background-color:$disabled-background;// Remove CSS gradients if they're enabled
background-image:if($enable-gradients,none,null);border-color:$disabled-border;
@mixin button-outline-variant($color,$color-hover:color-contrast($color),$active-background:$color,$active-border:$color,$active-color:color-contrast($active-background)color:$color;border-color:$color;&:hover{color:$color-hover;background-color:$active-background;border-color:$active-border;.btn-check:focus+&,&:focus{box-shadow:000$btn-focus-widthrgba($color,.5);.btn-check:checked+&,.btn-check:active+&,&:active,&.active,&.dropdown-toggle.show{color:$active-color;background-color:$active-background;border-color:$active-border;&:focus{@if$enable-shadows{@include box-shadow($btn-active-box-shadow,000$btn-focus-widthrgba($color,.5));}@else{// Avoid using mixin so we can pass custom focus shadow properly
box-shadow:000$btn-focus-widthrgba($color,.5);&:disabled,&.disabled{color:$color;background-color:transparent;
@mixin button-size($padding-y,$padding-x,$font-size,$border-radius){padding:$padding-y$padding-x;@include font-size($font-size);// Manually declare to provide an override to the browser default
@include border-radius($border-radius,0);
Loops
Button variants (for regular and outline buttons) use their respective mixins with our $theme-colors map to generate the modifier classes in scss/_buttons.scss.