Skip to content

refactor: aura badge colors inside containers with accent color#11282

Merged
web-padawan merged 1 commit intomainfrom
refactor/aura-badge-colors
Mar 9, 2026
Merged

refactor: aura badge colors inside containers with accent color#11282
web-padawan merged 1 commit intomainfrom
refactor/aura-badge-colors

Conversation

@jouni
Copy link
Member

@jouni jouni commented Mar 9, 2026

By default, allow badges to inherit the accent color from the container they are in:

<vaadin-button class="aura-accent-yellow">
  Button <!-- Yellow -->
  <vaadin-badge slot="suffix">Accent</vaadin-badge> <!-- Yellow -->
</vaadin-button>
<vaadin-button class="aura-accent-green">
  Button <!-- Green -->
  <vaadin-badge slot="suffix">Accent</vaadin-badge> <!-- Green -->
</vaadin-button>
Screenshot 2026-03-09 at 10 22 22

This applies to filled badges as well:

<vaadin-button class="aura-accent-yellow">
  Button <!-- Yellow -->
  <vaadin-badge slot="suffix" theme="filled">Accent</vaadin-badge> <!-- Black on yellow -->
</vaadin-button>
<vaadin-button class="aura-accent-green">
  Button <!-- Green -->
  <vaadin-badge slot="suffix" theme="filled">Accent</vaadin-badge> <!-- White on green -->
</vaadin-button>
Screenshot 2026-03-09 at 10 23 22

Default badges within filled component variants are overridden to use the current accent contrast color of the parent container:

<vaadin-button class="aura-accent-yellow" theme="primary">
  Button <!-- Black on yellow -->
  <vaadin-badge slot="suffix">Accent</vaadin-badge> <!-- Black -->
</vaadin-button>
<vaadin-button class="aura-accent-green" theme="primary">
  Button <!-- White on green -->
  <vaadin-badge slot="suffix">Accent</vaadin-badge> <!-- White -->
</vaadin-button>
Screenshot 2026-03-09 at 10 29 12

Default filled badges within filled component variants invert their colors, using the current accent contrast color as the background color and the current accent color as the text color:

<vaadin-button class="aura-accent-yellow" theme="primary">
  Button <!-- Black on yellow -->
  <vaadin-badge slot="suffix" theme="filled">Accent</vaadin-badge> <!-- Yellow on black -->
</vaadin-button>
<vaadin-button class="aura-accent-green" theme="primary">
  Button <!-- White on green -->
  <vaadin-badge slot="suffix" theme="filled">Accent</vaadin-badge> <!-- Green on white -->
</vaadin-button>
Screenshot 2026-03-09 at 11 01 01

When an explicit accent color variant is applied to a badge, then that color is respected, regardless of the parent container accent color:

<vaadin-button class="aura-accent-yellow">
  Button <!-- Yellow -->
  <vaadin-badge slot="suffix" class="aura-accent-green">Green</vaadin-badge> <!-- Green -->
</vaadin-button>
<vaadin-button class="aura-accent-green">
  Button <!-- Green -->
  <vaadin-badge slot="suffix" class="aura-accent-blue">Blue</vaadin-badge> <!-- Blue -->
</vaadin-button>
Screenshot 2026-03-09 at 10 22 55 Screenshot 2026-03-09 at 10 23 50

The same applies to colored badges within filled component variants (except for the "neutral" badge variant, which continues to inherit the color from the parent container):

<vaadin-button class="aura-accent-blue" theme="primary">
  Button <!-- White on blue -->
  <vaadin-badge slot="suffix" class="aura-accent-neutral">Blue</vaadin-badge> <!-- White (not gray) -->
</vaadin-button>
<vaadin-button class="aura-accent-yellow" theme="primary">
  Button <!-- Black on yellow -->
  <vaadin-badge slot="suffix" class="aura-accent-green">Accent</vaadin-badge> <!-- Green -->
</vaadin-button>
<vaadin-button class="aura-accent-green" theme="primary">
  Button <!-- White on green -->
  <vaadin-badge slot="suffix" class="aura-accent-blue">Blue</vaadin-badge> <!-- Blue -->
</vaadin-button>
Screenshot 2026-03-09 at 10 53 11

Lastly, explicitly colored filled badges within filled component containers always keep their original appearance:

<vaadin-button class="aura-accent-yellow" theme="primary">
  Button <!-- Black on yellow -->
  <vaadin-badge slot="suffix" class="aura-accent-green" theme="filled">Accent</vaadin-badge> <!-- White on green -->
</vaadin-button>
<vaadin-button class="aura-accent-green" theme="primary">
  Button <!-- White on green -->
  <vaadin-badge slot="suffix" class="aura-accent-blue" theme="filled">Blue</vaadin-badge> <!-- White on blue -->
</vaadin-button>
Screenshot 2026-03-09 at 11 10 25

@jouni jouni requested a review from web-padawan March 9, 2026 09:14
@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 9, 2026

@web-padawan web-padawan merged commit 4f20d2c into main Mar 9, 2026
10 checks passed
@web-padawan web-padawan deleted the refactor/aura-badge-colors branch March 9, 2026 09:47
@vaadin-bot
Copy link
Collaborator

This ticket/PR has been released with Vaadin 25.1.0-beta3.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants