bootstrap/scss/_button-group.scss

148 lines
3.6 KiB
SCSS

// Make the div behave like a button
.button-group,
.button-group-vertical {
position: relative;
display: inline-flex;
vertical-align: middle; // match .button alignment given font-size hack above
> .button {
position: relative;
flex: 1 1 auto;
}
// Bring the hover, focused, and "active" buttons to the front to overlay
// the borders properly
> .button-check:checked + .button,
> .button-check:focus + .button,
> .button:hover,
> .button:focus,
> .button:active,
> .button.active {
z-index: 1;
}
}
// Optional: Group multiple button groups together for a toolbar
.button-group-toolbar {
display: flex;
flex-wrap: wrap;
justify-content: flex-start;
.input-group {
width: auto;
}
}
.button-group {
@include border-radius($btn-border-radius);
// Prevent double borders when buttons are next to each other
> :not(.button-check:first-child) + .button,
> .button-group:not(:first-child) {
margin-left: calc(-1 * #{$btn-border-width}); // stylelint-disable-line function-disallowed-list
}
// Reset rounded corners
> .button:not(:last-child):not(.dropdown-toggle),
> .button.dropdown-toggle-split:first-child,
> .button-group:not(:last-child) > .button {
@include border-end-radius(0);
}
// The left radius should be 0 if the button is:
// - the "third or more" child
// - the second child and the previous element isn't `.button-check` (making it the first child visually)
// - part of a button-group which isn't the first child
> .button:nth-child(n + 3),
> :not(.button-check) + .button,
> .button-group:not(:first-child) > .button {
@include border-start-radius(0);
}
}
// Sizing
//
// Remix the default button sizing classes into new ones for easier manipulation.
.button-group-small > .button { @extend .button-small; }
.button-group-large > .button { @extend .button-large; }
//
// Split button dropdowns
//
.button-group-dropdown-toggle {
padding-right: $btn-padding-x * .75;
padding-left: $btn-padding-x * .75;
&::after,
.dropup &::after,
.dropend &::after {
margin-left: 0;
}
.dropstart &::before {
margin-right: 0;
}
}
.button-small + .button-group-dropdown-toggle {
padding-right: $btn-padding-x-sm * .75;
padding-left: $btn-padding-x-sm * .75;
}
.button-large + .button-group-dropdown-toggle {
padding-right: $btn-padding-x-lg * .75;
padding-left: $btn-padding-x-lg * .75;
}
// The clickable button for toggling the menu
// Set the same inset shadow as the :active state
.button-group.show .button-group-dropdown-toggle {
@include box-shadow($btn-active-box-shadow);
// Show no shadow for `.button-link` since it has no other button styles.
&.button-link {
@include box-shadow(none);
}
}
//
// Vertical button groups
//
.button-group-vertical {
flex-direction: column;
align-items: flex-start;
justify-content: center;
> .button,
> .button-group {
width: 100%;
}
> .button:not(:first-child),
> .button-group:not(:first-child) {
margin-top: calc(-1 * #{$btn-border-width}); // stylelint-disable-line function-disallowed-list
}
// Reset rounded corners
> .button:not(:last-child):not(.dropdown-toggle),
> .button-group:not(:last-child) > .button {
@include border-bottom-radius(0);
}
// The top radius should be 0 if the button is:
// - the "third or more" child
// - the second child and the previous element isn't `.button-check` (making it the first child visually)
// - part of a button-group which isn't the first child
> .button:nth-child(n + 3),
> :not(.button-check) + .button,
> .button-group:not(:first-child) > .button {
@include border-top-radius(0);
}
}