Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x

tabs.pcss.css

Same filename in this branch
  1. 11.1.x core/themes/olivero/css/components/tabs.pcss.css
/**
 * Tabs.
 */

:root {
  /**
  * Tabs.
  */
  --tabs-border-radius-size: var(--base-border-radius);
  --tabs--hover-height: 3px;
  --tabs--focus-height: 3px;
  --tabs--active-height: 3px;
  --tabs-link-height: 3rem; /* 48px */
  --tabs-secondary-link-height: 2.5rem; /* 40px */
  --tabs-base-border: 1px solid var(--color-gray-200);
  --tabs-base-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  --tabs-trigger-border: 1px solid rgba(216, 217, 224, 0.8);
  --tabs--hover-bg-color: var(--color-bgblue-active);
}

.tabs-wrapper {
  & > nav {
    width: 100%;
  }
}
.tabs {
  display: flex;
  flex-direction: column;
  width: 100%;
  margin: 0 0 var(--space-l) 0;
  border: var(--tabs-base-border);
  border-radius: var(--tabs-border-radius-size);
  box-shadow: var(--tabs-base-shadow);
}

.tabs__tab {
  position: relative;
  border-bottom: var(--tabs-base-border);
  background-color: var(--color-gray-025);
  font-size: var(--font-size-s);
  font-weight: bold;
  &:not(.is-active) {
    display: none;
  }
  &:last-child {
    border-bottom: 0;
  }
  &.is-active {
    display: flex;
    justify-content: space-between;
    background-color: var(--color-white);
    box-shadow: var(--tabs-base-shadow);
    &:focus::before {
      top: calc(var(--tabs--focus-height) * -1);
      height: calc(var(--tabs-link-height) + 2px);
    }
    &::before {
      z-index: 2;
      top: -1px;
      inset-inline-start: -1px;
      width: var(--tabs--active-height);
      height: calc(100% + 2px);
      border-inline-start: var(--tabs--active-height) solid var(--color-absolutezero);
      border-top-left-radius: var(--tabs-border-radius-size);
    }
  }
}

.tabs__link {
  position: relative;
  display: flex;
  overflow: hidden;
  flex-grow: 1;
  align-items: center;
  box-sizing: border-box;
  min-height: var(--tabs-link-height);
  padding: var(--space-s) var(--space-l);
  text-decoration: none;
  color: var(--color-gray-800);
  line-height: 1.2rem;
  &:focus {
    min-height: calc(var(--tabs-link-height) + var(--tabs--focus-height) - 1px);
    margin: -1px;
    padding-inline-start: calc(var(--space-l) - var(--tabs--focus-height) + 1px);
    text-decoration: none;
    color: var(--color-gray-800);
    border: var(--tabs--focus-height) solid var(--color-focus);
    border-radius: var(--tabs-border-radius-size);
    outline: none;
    box-shadow: none;
  }
  &:hover {
    text-decoration: none;
    color: var(--color-text);
  }
  &.is-active {
    z-index: 1;
    flex-grow: 1;
    color: var(--color-absolutezero);
    &:focus {
      margin: -1px 0;
      padding-right: var(--space-l);
      padding-left: var(--space-l);
      border-inline-start: none;
      border-radius: 0;
    }
    &:hover {
      color: var(--color-text);
    }
  }
  &:not(.is-active):focus {
    z-index: 3;
  }
}
/* Active and hover indicator. */
.tabs__tab::before,
.tabs__link::before {
  position: absolute;
  display: block;
  content: "";
}
.tabs {
  &.is-open {
    & .tabs__tab.is-active::before {
      border-bottom-left-radius: 0;
    }
  }
}
.tabs--secondary {
  & .tabs__tab:not(.is-active) {
    display: block;
  }
}
.tabs.is-open > .tabs__tab {
  display: flex;
}

.tabs__trigger {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: var(--tabs-link-height);
  padding-right: 1px;
  text-align: center;
  border-inline-start: var(--tabs-trigger-border);
  &:focus {
    padding-right: 0;
    border: var(--tabs--focus-height) solid var(--color-focus);
    border-radius: var(--tabs-border-radius-size);
    box-shadow: none;
  }
}

@media screen and (min-width: 48em) {
  .tabs-wrapper {
    display: flex;
  }

  .tabs-wrapper--secondary {
    position: relative;
  }

  .is-horizontal {
    & .tabs {
      flex-direction: row;
      align-items: flex-end;
      width: auto;
      margin: 0;
      border: 0;
      box-shadow: none;
    }
    & .tabs--secondary {
      overflow: hidden;
      margin: calc(calc(var(--tabs--focus-height) + 3px) * -1) calc(calc(var(--tabs--focus-height) + 3px) * -1) 0;
      padding: calc(var(--tabs--focus-height) + 3px) calc(var(--tabs--focus-height) + 3px) 0;
      border-radius: 0;
      &::after {
        position: absolute;
        bottom: 0;
        left: 0;
        display: block;
        width: 100%;
        content: "";
        border-bottom: 1px solid var(--color-gray-200);
      }
      & .tabs__tab {
        font-size: var(--font-size-s);
      }
      & .tabs__link {
        min-height: var(--tabs-secondary-link-height);
        padding-top: var(--space-xs);
        padding-bottom: var(--space-xs);
        &:focus {
          min-height: var(--tabs-secondary-link-height);
        }
      }
    }
    & .tabs__tab {
      display: block;
      border-top: none;
      border-bottom: none;
      background: none;
      font-size: var(--font-size-base);
      &.is-active {
        order: 0;
        background: none;
        box-shadow: none;
        &::before {
          content: none;
        }
      }
      & .tabs__link {
        &.is-active::before {
          border-radius: 0;
        }
      }
    }
    & .tabs__link {
      padding-right: 2rem;
      padding-left: 2rem;
      border-radius: var(--tabs-border-radius-size) var(--tabs-border-radius-size) 0 0;
      &:focus {
        min-height: var(--tabs-link-height);
        margin: 0;
        padding-right: 2rem;
        padding-left: 2rem;
        color: var(--color-text);
        border: none;
        border-radius: var(--tabs-border-radius-size) var(--tabs-border-radius-size) 0 0;
        outline: 2px dotted transparent;
        box-shadow:
          0 0 0 2px var(--color-white),
          0 0 0 calc(var(--tabs--focus-height) + 2px) var(--color-focus);
      }
      &:hover {
        color: var(--color-absolutezero-hover);
        background: var(--tabs--hover-bg-color);
      }
      &.is-active {
        &::before {
          top: auto;
          right: 0;
          bottom: 0;
          left: 0;
          width: 100%;
          height: var(--tabs--active-height);
          border-right: none;
          border-bottom: var(--tabs--active-height) solid var(--color-absolutezero);
          border-left: none;
        }
      }
    }
    & .tabs__trigger {
      display: none;
    }
    & .tabs--primary {
      & .tabs__link {
        &:focus {
          box-shadow:
            0 0 0 2px var(--color-gray-050),
            0 0 0 calc(var(--tabs--focus-height) + 2px) var(--color-focus);
        }
      }
    }
  }
}

File

core/themes/claro/css/components/tabs.pcss.css

View source
  1. /**
  2. * Tabs.
  3. */
  4. :root {
  5. /**
  6. * Tabs.
  7. */
  8. --tabs-border-radius-size: var(--base-border-radius);
  9. --tabs--hover-height: 3px;
  10. --tabs--focus-height: 3px;
  11. --tabs--active-height: 3px;
  12. --tabs-link-height: 3rem; /* 48px */
  13. --tabs-secondary-link-height: 2.5rem; /* 40px */
  14. --tabs-base-border: 1px solid var(--color-gray-200);
  15. --tabs-base-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  16. --tabs-trigger-border: 1px solid rgba(216, 217, 224, 0.8);
  17. --tabs--hover-bg-color: var(--color-bgblue-active);
  18. }
  19. .tabs-wrapper {
  20. & > nav {
  21. width: 100%;
  22. }
  23. }
  24. .tabs {
  25. display: flex;
  26. flex-direction: column;
  27. width: 100%;
  28. margin: 0 0 var(--space-l) 0;
  29. border: var(--tabs-base-border);
  30. border-radius: var(--tabs-border-radius-size);
  31. box-shadow: var(--tabs-base-shadow);
  32. }
  33. .tabs__tab {
  34. position: relative;
  35. border-bottom: var(--tabs-base-border);
  36. background-color: var(--color-gray-025);
  37. font-size: var(--font-size-s);
  38. font-weight: bold;
  39. &:not(.is-active) {
  40. display: none;
  41. }
  42. &:last-child {
  43. border-bottom: 0;
  44. }
  45. &.is-active {
  46. display: flex;
  47. justify-content: space-between;
  48. background-color: var(--color-white);
  49. box-shadow: var(--tabs-base-shadow);
  50. &:focus::before {
  51. top: calc(var(--tabs--focus-height) * -1);
  52. height: calc(var(--tabs-link-height) + 2px);
  53. }
  54. &::before {
  55. z-index: 2;
  56. top: -1px;
  57. inset-inline-start: -1px;
  58. width: var(--tabs--active-height);
  59. height: calc(100% + 2px);
  60. border-inline-start: var(--tabs--active-height) solid var(--color-absolutezero);
  61. border-top-left-radius: var(--tabs-border-radius-size);
  62. }
  63. }
  64. }
  65. .tabs__link {
  66. position: relative;
  67. display: flex;
  68. overflow: hidden;
  69. flex-grow: 1;
  70. align-items: center;
  71. box-sizing: border-box;
  72. min-height: var(--tabs-link-height);
  73. padding: var(--space-s) var(--space-l);
  74. text-decoration: none;
  75. color: var(--color-gray-800);
  76. line-height: 1.2rem;
  77. &:focus {
  78. min-height: calc(var(--tabs-link-height) + var(--tabs--focus-height) - 1px);
  79. margin: -1px;
  80. padding-inline-start: calc(var(--space-l) - var(--tabs--focus-height) + 1px);
  81. text-decoration: none;
  82. color: var(--color-gray-800);
  83. border: var(--tabs--focus-height) solid var(--color-focus);
  84. border-radius: var(--tabs-border-radius-size);
  85. outline: none;
  86. box-shadow: none;
  87. }
  88. &:hover {
  89. text-decoration: none;
  90. color: var(--color-text);
  91. }
  92. &.is-active {
  93. z-index: 1;
  94. flex-grow: 1;
  95. color: var(--color-absolutezero);
  96. &:focus {
  97. margin: -1px 0;
  98. padding-right: var(--space-l);
  99. padding-left: var(--space-l);
  100. border-inline-start: none;
  101. border-radius: 0;
  102. }
  103. &:hover {
  104. color: var(--color-text);
  105. }
  106. }
  107. &:not(.is-active):focus {
  108. z-index: 3;
  109. }
  110. }
  111. /* Active and hover indicator. */
  112. .tabs__tab::before,
  113. .tabs__link::before {
  114. position: absolute;
  115. display: block;
  116. content: "";
  117. }
  118. .tabs {
  119. &.is-open {
  120. & .tabs__tab.is-active::before {
  121. border-bottom-left-radius: 0;
  122. }
  123. }
  124. }
  125. .tabs--secondary {
  126. & .tabs__tab:not(.is-active) {
  127. display: block;
  128. }
  129. }
  130. .tabs.is-open > .tabs__tab {
  131. display: flex;
  132. }
  133. .tabs__trigger {
  134. display: flex;
  135. flex-shrink: 0;
  136. align-items: center;
  137. justify-content: center;
  138. width: var(--tabs-link-height);
  139. padding-right: 1px;
  140. text-align: center;
  141. border-inline-start: var(--tabs-trigger-border);
  142. &:focus {
  143. padding-right: 0;
  144. border: var(--tabs--focus-height) solid var(--color-focus);
  145. border-radius: var(--tabs-border-radius-size);
  146. box-shadow: none;
  147. }
  148. }
  149. @media screen and (min-width: 48em) {
  150. .tabs-wrapper {
  151. display: flex;
  152. }
  153. .tabs-wrapper--secondary {
  154. position: relative;
  155. }
  156. .is-horizontal {
  157. & .tabs {
  158. flex-direction: row;
  159. align-items: flex-end;
  160. width: auto;
  161. margin: 0;
  162. border: 0;
  163. box-shadow: none;
  164. }
  165. & .tabs--secondary {
  166. overflow: hidden;
  167. margin: calc(calc(var(--tabs--focus-height) + 3px) * -1) calc(calc(var(--tabs--focus-height) + 3px) * -1) 0;
  168. padding: calc(var(--tabs--focus-height) + 3px) calc(var(--tabs--focus-height) + 3px) 0;
  169. border-radius: 0;
  170. &::after {
  171. position: absolute;
  172. bottom: 0;
  173. left: 0;
  174. display: block;
  175. width: 100%;
  176. content: "";
  177. border-bottom: 1px solid var(--color-gray-200);
  178. }
  179. & .tabs__tab {
  180. font-size: var(--font-size-s);
  181. }
  182. & .tabs__link {
  183. min-height: var(--tabs-secondary-link-height);
  184. padding-top: var(--space-xs);
  185. padding-bottom: var(--space-xs);
  186. &:focus {
  187. min-height: var(--tabs-secondary-link-height);
  188. }
  189. }
  190. }
  191. & .tabs__tab {
  192. display: block;
  193. border-top: none;
  194. border-bottom: none;
  195. background: none;
  196. font-size: var(--font-size-base);
  197. &.is-active {
  198. order: 0;
  199. background: none;
  200. box-shadow: none;
  201. &::before {
  202. content: none;
  203. }
  204. }
  205. & .tabs__link {
  206. &.is-active::before {
  207. border-radius: 0;
  208. }
  209. }
  210. }
  211. & .tabs__link {
  212. padding-right: 2rem;
  213. padding-left: 2rem;
  214. border-radius: var(--tabs-border-radius-size) var(--tabs-border-radius-size) 0 0;
  215. &:focus {
  216. min-height: var(--tabs-link-height);
  217. margin: 0;
  218. padding-right: 2rem;
  219. padding-left: 2rem;
  220. color: var(--color-text);
  221. border: none;
  222. border-radius: var(--tabs-border-radius-size) var(--tabs-border-radius-size) 0 0;
  223. outline: 2px dotted transparent;
  224. box-shadow:
  225. 0 0 0 2px var(--color-white),
  226. 0 0 0 calc(var(--tabs--focus-height) + 2px) var(--color-focus);
  227. }
  228. &:hover {
  229. color: var(--color-absolutezero-hover);
  230. background: var(--tabs--hover-bg-color);
  231. }
  232. &.is-active {
  233. &::before {
  234. top: auto;
  235. right: 0;
  236. bottom: 0;
  237. left: 0;
  238. width: 100%;
  239. height: var(--tabs--active-height);
  240. border-right: none;
  241. border-bottom: var(--tabs--active-height) solid var(--color-absolutezero);
  242. border-left: none;
  243. }
  244. }
  245. }
  246. & .tabs__trigger {
  247. display: none;
  248. }
  249. & .tabs--primary {
  250. & .tabs__link {
  251. &:focus {
  252. box-shadow:
  253. 0 0 0 2px var(--color-gray-050),
  254. 0 0 0 calc(var(--tabs--focus-height) + 2px) var(--color-focus);
  255. }
  256. }
  257. }
  258. }
  259. }
RSS feed
Powered by Drupal