Skip to content

Commit ca7b771

Browse files
Tabs: Remove margin-bottom being used to hide border. (#3521)
Co-authored-by: Chris Swithinbank <swithinbank@gmail.com>
1 parent 740cefb commit ca7b771

2 files changed

Lines changed: 27 additions & 3 deletions

File tree

.changeset/fresh-horses-burn.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
'@astrojs/starlight': minor
3+
---
4+
5+
Fixes an issue where a vertical scrollbar could be displayed on the Starlight `<Tabs>` component when zooming the page
6+
7+
⚠️ **Potentially breaking change:** The `<Tabs>` component no longer uses `margin-bottom` and `border-bottom` to highlight the current tab. This is now done with a `box-shadow`. If you have custom styling for your tabs, you may need to update it.
8+
9+
If you want to preserve the previous styling, you can add the following custom CSS to your site:
10+
11+
```css
12+
starlight-tabs .tab {
13+
margin-bottom: -2px;
14+
}
15+
16+
starlight-tabs .tab > [role='tab'] {
17+
border-bottom: 2px solid var(--sl-color-gray-5);
18+
box-shadow: none;
19+
}
20+
21+
starlight-tabs .tab [role='tab'][aria-selected='true'] {
22+
border-color: var(--sl-color-text-accent);
23+
}
24+
```

packages/starlight/user-components/Tabs.astro

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,23 +116,23 @@ if (isSynced) {
116116

117117
.tab {
118118
display: flex;
119-
margin-bottom: -2px;
120119
}
121120
.tab > [role='tab'] {
121+
--sl-tab-color-border: var(--sl-color-gray-5);
122122
display: flex;
123123
align-items: center;
124124
gap: 0.5rem;
125125
line-height: var(--sl-line-height-headings);
126126
padding: 0.275rem 1.25rem;
127127
text-decoration: none;
128-
border-bottom: 2px solid var(--sl-color-gray-5);
128+
box-shadow: 0 2px 0 var(--sl-tab-color-border);
129129
color: var(--sl-color-gray-3);
130130
outline-offset: var(--sl-outline-offset-inside);
131131
overflow-wrap: initial;
132132
}
133133
.tab [role='tab'][aria-selected='true'] {
134+
--sl-tab-color-border: var(--sl-color-text-accent);
134135
color: var(--sl-color-white);
135-
border-color: var(--sl-color-text-accent);
136136
font-weight: 600;
137137
}
138138

0 commit comments

Comments
 (0)