Modify .card-header-tabs .nav-link.active colors#28833
Conversation
Set `.card-header-tabs .nav-link.active` background / border colors to better match card.
|
Should also care for hover? |
…-tabs` changes Use `border-bottom-color` instead of `border-color`, to ensure only the neccessary part of the border changes.
|
Since I did make a change to my pull request though: Previous: New: Now only the bottom border colour changes, to match the card background. |
mdo
left a comment
There was a problem hiding this comment.
I think I’m in favor of this. Feels like a helpful consideration for folks who may modify the $body-bg to be something different. Otherwise though, it’s unnecessary. Thoughts from @twbs/css-review for how to account for that and avoid including CSS that’s not used by default?
Use `background-color` instead of `background` so it doesn't override additional `background-` properties. Co-Authored-By: Mark Otto <otto@github.com>
|
@mdo Indeed. Some frameworks like Laravel modify the |
|
There's probably a way to modify this to play nice with #background-and-color as well, but that's a seperate issue. EDIT: _card.scss: .card-header-tabs {
margin-right: -$card-spacer-x / 2;
margin-bottom: -$card-spacer-y;
margin-left: -$card-spacer-x / 2;
border-bottom: 0;
.nav-link {
color: inherit;
&:hover {
border-color: $card-border-color $card-border-color transparent;
}
&.active {
background-color: $card-bg;
border-color: $card-border-color $card-border-color $card-bg;
color: inherit;
}
}
}_background-variant.scss: @mixin bg-variant($parent, $color) {
#{$parent}{
background-color: $color !important;
.card-header-tabs .nav-link.active {
background-color: $color !important;
border-bottom-color: $color !important;
}
}
a#{$parent},
button#{$parent} {
@include hover-focus {
background-color: darken($color, 10%) !important;
}
}
}The tabs will then inherit whatever colors you assign to the card: There's likely a better way of doing this... but let me know if you'd like any of the above included in this (or in a seperate) pull-request and I'll be happy to do so. |
ysds
left a comment
There was a problem hiding this comment.
Thoughts from @twbs/css-review for how to account for that and avoid including CSS that’s not used by default?
@shaneparsons Could you change as the follows? 😄
.nav-link.active {
background-color: $card-bg;
border-bottom-color: $card-bg;
}to
@if $nav-tabs-link-active-bg != $card-bg {
.nav-link.active {
background-color: $card-bg;
border-bottom-color: $card-bg;
}
}
Done! See my edit to #28833 (comment) and let me know if the additions are of any interest to you. |
|
I think it's over-engineering to integrate with the background utilities. It would be better to solve it with custom variables in the future (v6?) |
Yeah I agree on that one. I don't have a ton of experience with advanced variables / utilities / mixins, so that was just my hacky take on the solution. I more so just intended to get the conversation started. |
|
I assume we don't want this backported, right? |



Set
.card-header-tabs .nav-link.activebackground / border colors to better match card.Fixes #28820.