diff --git a/scss/_mixins.scss b/scss/_mixins.scss index 9a579688..e40e6545 100644 --- a/scss/_mixins.scss +++ b/scss/_mixins.scss @@ -392,3 +392,14 @@ $gap-sm; color: $text--muted-color; } + +@mixin label-variant($color) { + background-color: $color; + + &[href] { + &:hover, + &:focus { + background-color: darken($color, 10%); + } + } +} diff --git a/scss/_utilities.scss b/scss/_utilities.scss index 54011865..3e1d4666 100644 --- a/scss/_utilities.scss +++ b/scss/_utilities.scss @@ -1517,6 +1517,69 @@ word-wrap: break-word; } +// +// Labels +// -------------------------------------------------- + +.label { + display: inline; + padding: 0.2em 0.6em 0.3em; + font-size: 75%; + font-weight: 700; + line-height: 1; + color: $label-color; + text-align: center; + white-space: nowrap; + vertical-align: baseline; + border-radius: 0.25em; + + // Empty labels collapse automatically (not available in IE8) + &:empty { + display: none; + } + + // Quick fix for labels in buttons + .btn & { + position: relative; + top: -1px; + } +} +a.label { + &:hover, + &:focus { + color: $label-link--hover-color; + text-decoration: none; + cursor: pointer; + } +} + +// Colors +// Contextual variations (linked labels get darker on :hover) + +.label-default { + @include label-variant($label--default-bg); +} + +.label-primary { + @include label-variant($label--primary-bg); +} + +.label-success { + @include label-variant($label--success-bg); +} + +.label-info { + @include label-variant($label--info-bg); +} + +.label-warning { + @include label-variant($label--warning-bg); +} + +.label-danger { + @include label-variant($label--danger-bg); +} + @keyframes apearSensor { from { opacity: 0; diff --git a/scss/_variables.scss b/scss/_variables.scss index d64c24c7..866b368b 100644 --- a/scss/_variables.scss +++ b/scss/_variables.scss @@ -138,6 +138,16 @@ $gap-lg: px2rem(30px) !default; $icon-color: $gray600 !default; $icon-onHover-color: $gray900 !default; +$label--default-bg: $gray700 !default; +$label--primary-bg: $primary !default; +$label--success-bg: $success !default; +$label--info-bg: $info !default; +$label--warning-bg: $warning !default; +$label--danger-bg: $danger !default; + +$label-color: #fff !default; +$label-link--hover-color: #fff !default; + // Components $scrollbar-width: px2rem(17px) !default;