@dnb/eufemia
Version:
DNB Eufemia Design System UI Library
382 lines • 12.3 kB
CSS
/*
* Tabs component
*
*/
/*
* Utilities
*/
/*
* Utilities
*/
/*
* Button mixins
*
*/
.dnb-tabs {
--tablist-border-color--default: grey;
--tab-title-font-weight: var(--font-weight-regular);
--tab-title-font-size: var(--font-size-basis);
--tab-title-font-color: dimgray;
--tab-title-background--hover: darkgrey;
--tab-title-color--hover: inherit;
--tab-title-border--hover: black;
--tab-title-background--disabled: inherit;
--tab-title-color--disabled: lightgrey;
--tab-title-border--active-selected: black;
--tab-title-color--active-selected: black;
--tab-title-font-weight--selected: var(--font-weight-medium);
}
.dnb-tabs__tabs {
position: relative;
z-index: 1;
display: flex;
align-items: center;
}
.dnb-tabs__tabs, .dnb-tabs__tabs.dnb-section--spacing {
padding-bottom: 0;
}
.dnb-tabs__tabs__tablist {
display: flex;
flex: 0 1 auto;
}
.dnb-tabs__tabs__tablist:focus {
outline: none;
}
html[data-whatinput=keyboard] .dnb-tabs__tabs__tablist:focus {
--border-color: var(--focus-ring-color);
--border-width: var(--focus-ring-width);
box-shadow: 0 0 0 var(--border-width) var(--border-color);
border-color: transparent;
}
.dnb-tabs__tabs__tablist:focus {
border-radius: 0.5rem;
}
.dnb-tabs__tabs__tablist {
overflow-x: auto;
}
@media (prefers-reduced-motion: reduce) {
.dnb-tabs__tabs__tablist {
scroll-behavior: auto;
}
}
.dnb-tabs__tabs__tablist {
overscroll-behavior: contain;
}
html:not([data-visual-test]) .dnb-tabs__tabs__tablist {
scroll-behavior: smooth;
}
.dnb-tabs__tabs__tablist {
-webkit-overflow-scrolling: touch;
-ms-overflow-style: auto;
scrollbar-color: var(--scrollbar-thumb-color, #888) transparent;
}
@supports not (scrollbar-color: auto) {
.dnb-tabs__tabs__tablist::-webkit-scrollbar:vertical {
width: var(--scrollbar-track-width, 0.5rem);
}
.dnb-tabs__tabs__tablist::-webkit-scrollbar:horizontal {
height: var(--scrollbar-track-width, 0.5rem);
}
.dnb-tabs__tabs__tablist::-webkit-scrollbar {
border-radius: var(--scrollbar-thumb-width, 0.5rem);
background-color: var(--scrollbar-track-color, #eee);
}
.dnb-tabs__tabs__tablist::-webkit-scrollbar-thumb {
background-color: var(--scrollbar-thumb-color, #888);
}
.dnb-tabs__tabs__tablist::-webkit-scrollbar-thumb:hover {
background-color: var(--scrollbar-thumb-hover-color, #666);
}
.dnb-tabs__tabs__tablist::-webkit-scrollbar-thumb {
border-radius: var(--scrollbar-thumb-width, 0.5rem);
}
}
.dnb-tabs__tabs__tablist {
/* Hide scrollbar for Chrome, Safari */
/* stylelint-disable-next-line */
}
.dnb-tabs__tabs__tablist::-webkit-scrollbar {
display: none;
}
.dnb-tabs__tabs__tablist {
-ms-overflow-style: none; /* IE and Edge */
scrollbar-width: none; /* Firefox */
}
.dnb-tabs__tabs--left .dnb-tabs__tabs__tablist {
justify-content: flex-start;
}
.dnb-tabs__tabs--right .dnb-tabs__tabs__tablist {
flex: 1;
justify-content: flex-end;
}
.dnb-tabs__tabs--center .dnb-tabs__tabs__tablist {
flex: 1;
justify-content: center;
}
.dnb-tabs__tabs::before {
content: "";
position: absolute;
z-index: -1;
bottom: 0;
width: 100%;
height: 1px;
}
.dnb-tabs__tabs--no-border::before {
content: none;
}
.dnb-tabs__tabs--breakout::before {
left: -100vw;
width: 100vw;
}
.dnb-tabs__tabs:not(.dnb-section)::before {
background-color: var(--tablist-border-color--default);
box-shadow: 100vw 0 0 0 var(--tablist-border-color--default);
}
.dnb-tabs__scroll-nav-button {
position: absolute;
z-index: 2;
right: -2px;
}
.dnb-tabs__scroll-nav-button:first-of-type {
left: -2px;
right: auto;
}
.dnb-tabs__scroll-nav-button {
display: none;
opacity: 0;
pointer-events: none;
transition: opacity 600ms ease-out;
}
.dnb-tabs__scroll-nav-button--visible {
display: flex;
pointer-events: initial;
opacity: 1;
}
.dnb-tabs__scroll-nav-button--hide {
pointer-events: none;
opacity: 0 ;
}
.dnb-tabs--at-edge .dnb-tabs__scroll-nav-button:first-of-type {
border-radius: 0 50% 50% 0;
}
.dnb-tabs--at-edge .dnb-tabs__scroll-nav-button:last-of-type {
border-radius: 50% 0 0 50%;
}
.dnb-tabs--at-edge .dnb-tabs__tabs__tablist:focus {
border-radius: 0;
}
.dnb-tabs__button, .dnb-core-style .dnb-tabs__button {
position: relative;
z-index: 1;
}
.dnb-tabs__button:has(.dnb-badge), .dnb-core-style .dnb-tabs__button:has(.dnb-badge) {
margin-right: 1.5rem;
}
.dnb-tabs__button, .dnb-core-style .dnb-tabs__button {
user-select: none;
/* stylelint-disable-next-line */
-webkit-user-select: none;
margin: 0;
padding: 0 0.125rem; /* 1/16*4 */
background-color: transparent;
border-bottom: 1px solid transparent;
cursor: pointer;
outline: none;
border: none;
font-size: var(--font-size-basis);
line-height: var(--line-height-basis);
-webkit-text-decoration: none;
text-decoration: none;
white-space: nowrap;
transition: margin 400ms ease-out;
}
.dnb-tabs__button__title, .dnb-core-style .dnb-tabs__button__title {
font-weight: var(--tab-title-font-weight);
font-size: var(--tab-title-font-size);
text-align: center;
display: block;
color: var(--tab-title-font-color);
padding: 0.5rem 0 0.25rem;
}
html:not([data-whatintent=touch]) .dnb-tabs__button__title:hover[disabled], html:not([data-whatintent=touch]) .dnb-core-style .dnb-tabs__button__title:hover[disabled] {
cursor: not-allowed;
}
html:not([data-whatintent=touch]) .dnb-tabs__button__title:hover:not([disabled]), html:not([data-whatintent=touch]) .dnb-core-style .dnb-tabs__button__title:hover:not([disabled]) {
color: var(--tab-title-color--hover);
}
.dnb-tabs__button__title .dnb-icon, .dnb-core-style .dnb-tabs__button__title .dnb-icon {
font-size: var(--font-size-small);
transform: translateY(-0.125rem);
}
html:not([data-whatintent=touch]) .dnb-tabs__button:hover[disabled], html:not([data-whatintent=touch]) .dnb-core-style .dnb-tabs__button:hover[disabled] {
cursor: not-allowed;
}
html:not([data-whatintent=touch]) .dnb-tabs__button:hover:not([disabled]), html:not([data-whatintent=touch]) .dnb-core-style .dnb-tabs__button:hover:not([disabled]) {
background-color: var(--tab-title-background--hover);
}
html:not([data-whatintent=touch]) .dnb-tabs__button:hover:not([disabled])::after, html:not([data-whatintent=touch]) .dnb-core-style .dnb-tabs__button:hover:not([disabled])::after {
height: 2px;
border-radius: 2px;
background-color: var(--tab-title-border--hover);
}
.dnb-tabs__button .dnb-dummy, .dnb-core-style .dnb-tabs__button .dnb-dummy {
display: flex;
flex-direction: column;
height: 0;
visibility: hidden;
overflow: hidden;
}
.dnb-tabs__button .dnb-dummy, .dnb-core-style .dnb-tabs__button .dnb-dummy {
margin-top: 0.25rem;
}
.dnb-tabs__button::after, .dnb-core-style .dnb-tabs__button::after {
content: "";
position: absolute;
z-index: -1;
left: 0;
right: 0;
bottom: 0;
width: 100%;
height: 1px;
}
.dnb-tabs__button[disabled], .dnb-core-style .dnb-tabs__button[disabled] {
background-color: var(--tab-title-background--disabled);
}
.dnb-tabs__button[disabled] .dnb-tabs__button__title, .dnb-tabs__button[disabled] .dnb-core-style .dnb-tabs__button__title, .dnb-core-style .dnb-tabs__button[disabled] .dnb-tabs__button__title, .dnb-core-style .dnb-tabs__button[disabled] .dnb-core-style .dnb-tabs__button__title {
color: var(--tab-title-color--disabled);
}
.dnb-tabs__button span[hidden], .dnb-core-style .dnb-tabs__button span[hidden] {
font-weight: var(--tab-title-font-weight--selected);
}
.dnb-tabs__button, .dnb-core-style .dnb-tabs__button {
/* stylelint-disable no-descending-specificity */
}
.dnb-tabs__button:focus::before, .dnb-core-style .dnb-tabs__button:focus::before {
content: "";
position: absolute;
z-index: 1;
top: 0;
left: -0.5rem;
bottom: 0;
right: -0.5rem;
height: inherit;
border-radius: inherit;
outline: none;
}
html[data-whatinput=keyboard] .dnb-tabs__button:focus::before, html[data-whatinput=keyboard] .dnb-core-style .dnb-tabs__button:focus::before {
--border-color: var(--focus-ring-color);
--border-width: var(--focus-ring-width);
box-shadow: 0 0 0 var(--border-width) var(--border-color);
border-color: transparent;
}
.dnb-tabs__button:focus, .dnb-core-style .dnb-tabs__button:focus {
overflow: visible;
}
.dnb-tabs__button:focus::before, .dnb-core-style .dnb-tabs__button:focus::before {
top: 0.5rem;
left: -0.375rem;
right: -0.375rem;
bottom: 0.5rem;
border-radius: 1.5rem;
background-color: var(--tab-focus-background-color, none);
}
.dnb-tabs__button:not([disabled]):active::after, .dnb-tabs__button:not([disabled]).selected::after, .dnb-core-style .dnb-tabs__button:not([disabled]):active::after, .dnb-core-style .dnb-tabs__button:not([disabled]).selected::after {
height: 2px;
border-radius: 2px;
background-color: var(--tab-title-border--active-selected);
}
.dnb-tabs__button:not([disabled]):active .dnb-tabs__button__title, .dnb-tabs__button:not([disabled]).selected .dnb-tabs__button__title, .dnb-tabs__button:not([disabled]):active .dnb-core-style .dnb-tabs__button__title, .dnb-tabs__button:not([disabled]).selected .dnb-core-style .dnb-tabs__button__title, .dnb-core-style .dnb-tabs__button:not([disabled]):active .dnb-tabs__button__title, .dnb-core-style .dnb-tabs__button:not([disabled]).selected .dnb-tabs__button__title, .dnb-core-style .dnb-tabs__button:not([disabled]):active .dnb-core-style .dnb-tabs__button__title, .dnb-core-style .dnb-tabs__button:not([disabled]).selected .dnb-core-style .dnb-tabs__button__title {
color: var(--tab-title-color--active-selected);
}
.dnb-tabs__button:not([disabled]).selected .dnb-tabs__button__title, .dnb-tabs__button:not([disabled]).selected .dnb-core-style .dnb-tabs__button__title, .dnb-core-style .dnb-tabs__button:not([disabled]).selected .dnb-tabs__button__title, .dnb-core-style .dnb-tabs__button:not([disabled]).selected .dnb-core-style .dnb-tabs__button__title {
font-weight: var(--tab-title-font-weight--selected);
}
.dnb-tabs__button, .dnb-core-style .dnb-tabs__button {
/* stylelint-enable no-descending-specificity */
}
.dnb-tabs__button__snap {
display: flex;
padding: 0 1rem 0 1.5rem;
}
@media screen and (max-width: 40em) {
.dnb-tabs__button__snap {
padding: 0 1rem;
}
}
.dnb-tabs__button__snap:first-of-type {
padding-left: 0;
}
.dnb-tabs__button__snap:last-of-type {
padding-right: 0.5rem;
}
.dnb-tabs__button__snap {
will-change: padding;
transition: padding 1s var(--easing-default);
}
.dnb-tabs__button__snap:has(.dnb-badge) {
margin-right: -0.5rem;
}
html[data-whatinput=keyboard] .dnb-tabs__button__snap:first-of-type.focus .dnb-tabs__button:focus {
margin-left: 0.5rem;
}
html[data-whatinput=keyboard] .dnb-tabs__button__snap:last-of-type.focus {
/* stylelint-disable */
}
html[data-whatinput=keyboard] .dnb-tabs__button__snap:last-of-type.focus .dnb-tabs__button:focus {
margin-right: 0.5rem;
}
html[data-whatinput=keyboard] .dnb-tabs__button__snap:last-of-type.focus {
/* stylelint-enable */
}
.dnb-tabs__cached {
opacity: 1;
transition: opacity 1s var(--easing-default);
}
.dnb-tabs__cached--hidden {
opacity: 0;
visibility: hidden;
height: 0 ;
overflow: hidden;
}
.dnb-tabs__cached--hidden * {
height: 0 ;
}
.dnb-tabs {
/* stylelint-disable */
}
html[data-visual-test] .dnb-tabs .dnb-tabs__cached, html[data-visual-test] .dnb-tabs .dnb-tabs__button, html[data-visual-test] .dnb-tabs .dnb-tabs__button__snap, html[data-visual-test] .dnb-tabs .dnb-tabs__scroll-nav-button {
transition: none ;
}
.dnb-tabs {
/* stylelint-enable */
}
.dnb-tabs__content {
padding-bottom: 0;
}
.dnb-tabs__content:focus {
position: relative;
}
.dnb-tabs__content:focus::before {
content: "";
position: absolute;
z-index: calc(var(--section-z-index) + 1);
pointer-events: none;
top: 0.125rem;
bottom: -0.5rem;
left: -0.5rem;
right: -0.5rem;
max-width: 100vw;
border-radius: 0.5rem;
outline: none;
}
html[data-whatinput=keyboard] .dnb-tabs__content:focus::before {
--border-color: var(--focus-ring-color);
--border-width: var(--focus-ring-width);
box-shadow: 0 0 0 var(--border-width) var(--border-color);
border-color: transparent;
}
.dnb-tabs__button__title > .dnb-badge {
position: absolute;
top: auto;
margin-left: 0.25rem;
}