Skip to content

fix(blocks): keep explicit badge colors above utility defaults - #10814

Merged
hanspagel merged 1 commit into
scalar:mainfrom
charan-rathore:fix/badge-color-specificity
Nov 2, 2026
Merged

hanspagel merged 1 commit into
scalar:mainfrom
charan-rathore:fix/badge-color-specificity

Conversation

@charan-rathore

Copy link
Copy Markdown
Contributor

Problem

A badge with color: '#ffcc00' can still render gray in the API reference. The color is present in --badge-color, but late-loading .scalar-app .bg-b-2 and .scalar-app .text-c-2 utilities have the same specificity as the scoped .badge-colored rule and win by source order. The text contrast rule loses too.

Small reproduction:

openapi: 3.1.0
info:
  title: Badge color example
  version: 1.0.0
paths:
  /hello-world:
    get:
      summary: Hello World
      x-badges:
        - name: Gamma
          color: '#ffcc00'
      responses:
        '200':
          description: OK

Solution

Use .badge.badge-colored for both explicit-color rules, matching the specificity already used by the badge's themed color variants. This keeps the selected background and derived text contrast above the default utilities, without changing plain badges or adding inline styles or !important.

The story covers plain, yellow and black badges. Its browser regression loads consumer utilities after the component styles, so it exercises the source-order collision rather than relying on Storybook's default stylesheet order.

Visual

Actual Vue Badge component with the Blocks stylesheet and light theme, before and after:

Before: explicit yellow and black badges are gray After: yellow and black badges retain their colors and readable text

Checklist

  • I explained why the change is needed.
  • I added a changeset.
  • I added tests.
  • I updated the documentation. No option or documented behavior changes.

AI-assisted.

Ticket

Fixes #10793

@changeset-bot

changeset-bot Bot commented Oct 31, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7ad42a5

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

This PR includes changesets to release 17 packages
Name Type
@scalar/blocks Patch
@scalar/api-client-react Patch
@scalar/api-client Patch
@scalar/api-reference Patch
scalar-app Patch
@scalar/nuxt Patch
@scalar/agent-chat Patch
@scalarapi/docker-api-reference Patch
@scalar/aspire Patch
@scalar/aspnetcore Patch
@scalar/aws-lambda Patch
@scalar/azure-functions Patch
@scalar/fastify-api-reference Patch
@scalar/java-integration Patch
scalar_api_reference Patch
@scalar/api-reference-react Patch
@scalar/server-side-rendering Patch

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-31T19:24:37.051385Z
We couldn’t complete this review. Comment @codex review to try again.
7ad42a5 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@hanspagel
hanspagel merged commit 63804da into scalar:main Nov 2, 2026
31 checks passed
@scalar-release-bot scalar-release-bot Bot mentioned this pull request Nov 2, 2026

This branch was previously deployed

1 inactive deployment
production-netlify — 7ad42a50 Deployed Oct 31, 2026 by charan-rathore via test-component-snapshots #4053
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Regression: x-badges color is ignored

2 participants