Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sidebar badge outline style with Tailwind CSS #1765

Closed
wants to merge 1 commit into from

Conversation

HiDeoo
Copy link
Member

@HiDeoo HiDeoo commented Apr 18, 2024

What kind of changes does this PR include?

  • Changes to Starlight code

Description

Outlined sidebar badges looks like this by default in Starlight:

SCR-20240418-kksc

When using Tailwind CSS, the outline style is thicker:

SCR-20240418-kfwo

This is due to the variant (outline) being used as a CSS class name which collides with Tailwind CSS outline utility adding outline-style: solid;.

This PR renames the class name to sl-outline to avoid the collision and get the following result matching the default Starlight style:

SCR-20240418-kgbg

Alternative approach

Edit: a potential alternative solution suggested by @martrapp could be to remove entirely the need of a CSS class for this and rely on a selector like [aria-current='page'] :global(.sl-badge). This would mean not exposing the outline variant in #1530 (which is the current approach) but we would need to confirm that first.

How to test

  1. Edit examples/tailwind/astro.config.mjs to add a badge to the "Example Guide" sidebar link.
  2. Run pnpm dev in the examples/tailwind/ directory.
  3. Navigate to http://localhost:4321/guides/example/

Copy link

changeset-bot bot commented Apr 18, 2024

🦋 Changeset detected

Latest commit: 7a44ca7

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

Copy link

vercel bot commented Apr 18, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
starlight ✅ Ready (Inspect) Visit Preview Apr 18, 2024 9:40am

@HiDeoo
Copy link
Member Author

HiDeoo commented Apr 18, 2024

Closing as I found a thread mentioning that the outline variant is meant to be internal and not exposed even with the <Badges> component. This means that #1530 removing it will close the issue.

@HiDeoo HiDeoo closed this Apr 18, 2024
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Badge styles break when refreshing with sidebar entry active
1 participant