// Embedded icons from Open Iconic. // Released under MIT and copyright 2014 Waybury. // https://useiconic.com/open // Checkboxes and radios // // Base class takes care of all the key behavioral aspects. .custom-control { position: relative; display: block; min-height: (@font-size-base * @line-height-base); padding-left: (@custom-control-gutter + @custom-control-indicator-size); } .custom-control-inline { display: inline-flex; margin-right: @custom-control-spacer-x; } .custom-control-input { position: absolute; left: 0; z-index: -1; // Put the input behind the label so it doesn't overlay text width: @custom-control-indicator-size; height: ((@font-size-base * @line-height-base + @custom-control-indicator-size) / 2); opacity: 0; &:checked ~ .custom-control-label::before { color: @custom-control-indicator-checked-color; border-color: @custom-control-indicator-checked-border-color; #gradient-bg(@custom-control-indicator-checked-bg); #box-shadow(@custom-control-indicator-checked-box-shadow); } &:focus ~ .custom-control-label::before { // the mixin is not used here to make sure there is feedback & when (@enable-shadows) { box-shadow: @input-box-shadow, @input-focus-box-shadow; } & when not (@enable-shadows) { box-shadow: @custom-control-indicator-focus-box-shadow; } } &:focus:not(:checked) ~ .custom-control-label::before { border-color: @custom-control-indicator-focus-border-color; } &:not(:disabled):active ~ .custom-control-label::before { color: @custom-control-indicator-active-color; background-color: @custom-control-indicator-active-bg; border-color: @custom-control-indicator-active-border-color; #box-shadow(@custom-control-indicator-active-box-shadow); } // Use disabled attribute instead of :disabled pseudo-class // Workaround for: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/11295231 &[disabled] { ~ .custom-control-label { color: @custom-control-label-disabled-color; &::before { background-color: @custom-control-indicator-disabled-bg; } } } } // Custom control indicators // // Build the custom controls out of pseudo-elements. .custom-control-label { position: relative; margin-bottom: 0; // LESS PORT: Less doesn’t strip “empty” property values so we have to check for a value first. & when not (@custom-control-label-color = ~"") { color: @custom-control-label-color; } vertical-align: top; // LESS PORT: Less doesn’t strip “empty” property values so we have to check for a value first. & when not (@custom-control-cursor = ~"") { cursor: @custom-control-cursor; } // Background-color and (when enabled) gradient &::before { position: absolute; top: ((@font-size-base * @line-height-base - @custom-control-indicator-size) / 2); left: -(@custom-control-gutter + @custom-control-indicator-size); display: block; width: @custom-control-indicator-size; height: @custom-control-indicator-size; pointer-events: none; content: ""; background-color: @custom-control-indicator-bg; border: @custom-control-indicator-border-color solid @custom-control-indicator-border-width; #box-shadow(@custom-control-indicator-box-shadow); } // Foreground (icon) &::after { position: absolute; top: ((@font-size-base * @line-height-base - @custom-control-indicator-size) / 2); left: -(@custom-control-gutter + @custom-control-indicator-size); display: block; width: @custom-control-indicator-size; height: @custom-control-indicator-size; content: ""; background: no-repeat 50% ~"/" @custom-control-indicator-bg-size; } } // Checkboxes // // Tweak just a few things for checkboxes. .custom-checkbox { .custom-control-label::before { #border-radius(@custom-checkbox-indicator-border-radius); } .custom-control-input:checked ~ .custom-control-label { &::after { background-image: escape-svg(@custom-checkbox-indicator-icon-checked); } } .custom-control-input:indeterminate ~ .custom-control-label { &::before { border-color: @custom-checkbox-indicator-indeterminate-border-color; #gradient-bg(@custom-checkbox-indicator-indeterminate-bg); #box-shadow(@custom-checkbox-indicator-indeterminate-box-shadow); } &::after { background-image: escape-svg(@custom-checkbox-indicator-icon-indeterminate); } } .custom-control-input:disabled { &:checked ~ .custom-control-label::before { background-color: @custom-control-indicator-checked-disabled-bg; } &:indeterminate ~ .custom-control-label::before { background-color: @custom-control-indicator-checked-disabled-bg; } } } // Radios // // Tweak just a few things for radios. .custom-radio { .custom-control-label::before { border-radius: @custom-radio-indicator-border-radius; } .custom-control-input:checked ~ .custom-control-label { &::after { background-image: escape-svg(@custom-radio-indicator-icon-checked); } } .custom-control-input:disabled { &:checked ~ .custom-control-label::before { background-color: @custom-control-indicator-checked-disabled-bg; } } } // switches // // Tweak a few things for switches .custom-switch { padding-left: (@custom-switch-width + @custom-control-gutter); .custom-control-label { &::before { left: -(@custom-switch-width + @custom-control-gutter); width: @custom-switch-width; pointer-events: all; border-radius: @custom-switch-indicator-border-radius; } &::after { // LESS PORT: Using format strings here so we can put computed values in the `calc()`. top: add(((@font-size-base * @line-height-base - @custom-control-indicator-size) / 2), (@custom-control-indicator-border-width * 2)); left: add(-(@custom-switch-width + @custom-control-gutter), (@custom-control-indicator-border-width * 2)); width: @custom-switch-indicator-size; height: @custom-switch-indicator-size; background-color: @custom-control-indicator-border-color; border-radius: @custom-switch-indicator-border-radius; #transition(transform 0.15s ease-in-out, @custom-forms-transition); } } .custom-control-input:checked ~ .custom-control-label { &::after { background-color: @custom-control-indicator-bg; transform: translateX((@custom-switch-width - @custom-control-indicator-size)); } } .custom-control-input:disabled { &:checked ~ .custom-control-label::before { background-color: @custom-control-indicator-checked-disabled-bg; } } } // Select // // Replaces the browser default select with a custom one, mostly pulled from // https://primer.github.io/. // .custom-select { display: inline-block; width: 100%; height: @custom-select-height; padding: @custom-select-padding-y (@custom-select-padding-x + @custom-select-indicator-padding) @custom-select-padding-y @custom-select-padding-x; // LESS PORT: Less doesn’t strip “empty” property values so we have to check for a value first. & when not (@custom-select-font-family = ~"") { font-family: @custom-select-font-family; } #font-size(@custom-select-font-size); font-weight: @custom-select-font-weight; line-height: @custom-select-line-height; color: @custom-select-color; vertical-align: middle; background: @custom-select-bg @custom-select-background; border: @custom-select-border-width solid @custom-select-border-color; #border-radius(@custom-select-border-radius, 0); #box-shadow(@custom-select-box-shadow); appearance: none; &:focus { border-color: @custom-select-focus-border-color; outline: 0; & when (@enable-shadows) { box-shadow: @custom-select-box-shadow, @custom-select-focus-box-shadow; } & when not (@enable-shadows) { box-shadow: @custom-select-focus-box-shadow; } &::-ms-value { // For visual consistency with other platforms/browsers, // suppress the default white text on blue background highlight given to // the selected option text when the (still closed)