Skip to content

Conversation

@shubham-padia
Copy link
Contributor

@shubham-padia shubham-padia commented Nov 3, 2025

Description

We were setting margin-bottom as -2px when at the same time we had a bottom border of 2px. Using this indirect margin was causing the tab container to be greater in height than it's wrapper when we zoomed out from the default zoom level. This introduced an unnecessary scroll bar.

Zoom Level Before After
90% Screenshot 2025-11-03 at 4 01 35 PM Screenshot 2025-11-03 at 4 01 43 PM
100% Screenshot 2025-11-03 at 3 53 30 PM Screenshot 2025-11-03 at 3 53 57 PM

I'm not sure if this PR warrants a minor version bump or not, let me know if it does.

@changeset-bot
Copy link

changeset-bot bot commented Nov 3, 2025

🦋 Changeset detected

Latest commit: 665b8aa

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@astrojs/starlight Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the 🌟 core Changes to Starlight’s main package label Nov 3, 2025
@netlify
Copy link

netlify bot commented Nov 3, 2025

Deploy Preview for astro-starlight ready!

Name Link
🔨 Latest commit 665b8aa
🔍 Latest deploy log https://app.netlify.com/projects/astro-starlight/deploys/69130d35b03e330008b761c3
😎 Deploy Preview https://deploy-preview-3521--astro-starlight.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 100 (no change from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Member

@delucis delucis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good catch and fix @shubham-padia! Nice one.

I agree this probably should be in a minor release, just in case someone customized border width in their theme and the switch to box-shadow could cause issues. Normally for changes like this we also try to include a snippet in the changeset explaining how to “revert” the new style if wanted for whatever reason, so maybe something like:

starlight-tabs .tab {
  margin-bottom: -2px;
}

starlight-tabs .tab > [role='tab'] {
  border-bottom: 2px solid var(--sl-color-gray-5);
}

starlight-tabs .tab [role='tab'][aria-selected='true'] {
  border-color: var(--sl-color-text-accent);
  box-shadow: none;
}

There’s a recent example of something like that in the changelog entry for v0.36 in case it’s helpful to see.

@delucis delucis added the 🌟 minor Change that triggers a minor release label Nov 3, 2025
@delucis delucis added this to the v0.37 milestone Nov 3, 2025
@shubham-padia shubham-padia force-pushed the fix-tab-overflow-on-zoom-out branch 2 times, most recently from 63c49b6 to 7033a9c Compare November 3, 2025 13:18
@shubham-padia
Copy link
Contributor Author

Updated the PR @delucis ! Let me know if we want this to be part of a patch release instead of minor.

Copy link
Member

@HiDeoo HiDeoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the border on .tab > [role='tab'] would end up with a different behavior when the tab list is scrollable.

Before After
SCR-20251104-joog SCR-20251104-jotp

I guess this may be fixable with a box-shadow instead of removing the border, but didn't investigate further yet.

@delucis
Copy link
Member

delucis commented Nov 4, 2025

I guess this may be fixable with a box-shadow instead of removing the border, but didn't investigate further yet.

Ah, good catch. We probably need the box-shadow on [role=tab] as well to avoid this.

Copy link
Member

@delucis delucis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably this set of changes is how I’d approach it:

  • Control the colour via a custom property
  • Set the box-shadow on the [role="tab"] element
  • Update the custom property when the tab is selected.

.tab [role='tab'][aria-selected='true'] {
color: var(--sl-color-white);
border-color: var(--sl-color-text-accent);
box-shadow: 0 2px 0 var(--sl-color-text-accent);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
box-shadow: 0 2px 0 var(--sl-color-text-accent);

@shubham-padia shubham-padia force-pushed the fix-tab-overflow-on-zoom-out branch 2 times, most recently from 760836b to c594d2f Compare November 11, 2025 10:07
@shubham-padia shubham-padia marked this pull request as draft November 11, 2025 10:13
@shubham-padia shubham-padia force-pushed the fix-tab-overflow-on-zoom-out branch from c594d2f to 3a32779 Compare November 11, 2025 10:16
@shubham-padia shubham-padia marked this pull request as ready for review November 11, 2025 10:16
We were setting margin-bottom as -2px when at the same time we had a
bottom border of 2px. Using this indirect margin was causing the tab
container to be greater in height than it's wrapper when we zoomed out
from the default zoom level. This introduced an unnecessary scroll bar.

We use a border-bottom of 2px on `.tab` mainly to mark the active tab
with `--sl-color-text-accent`, the additional margin-bottom: -2px hides
the grey border from the tablist so it doesn't feel like we have a blue
bottom border for the active tab sitting on top of a grey border.

Using box shadow instead to paint over the bottom border of the tablist
is a cleaner idea than doing these margin-bottom shenanigans.

Co-authored-by: Chris Swithinbank <[email protected]>
@shubham-padia shubham-padia force-pushed the fix-tab-overflow-on-zoom-out branch from 3a32779 to 665b8aa Compare November 11, 2025 10:17
@shubham-padia
Copy link
Contributor Author

Sorry for the delay, made the requested changes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🌟 core Changes to Starlight’s main package 🌟 minor Change that triggers a minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants