diff --git a/core/src/components/badge/badge.scss b/core/src/components/badge/badge.scss index dbaed8b043e..aeffe43fdd7 100644 --- a/core/src/components/badge/badge.scss +++ b/core/src/components/badge/badge.scss @@ -4,18 +4,31 @@ // -------------------------------------------------- :host { - --ion-color-base: #{ion-color(primary, base)}; - --ion-color-contrast: #{ion-color(primary, contrast)}; + /** + * @prop --background: Background of the badge + * @prop --color: Text color of the badge + * + * @prop --padding-top: Padding top of the badge + * @prop --padding-end: Padding end of the badge + * @prop --padding-bottom: Padding bottom of the badge + * @prop --padding-start: Padding start of the badge + */ + --background: #{ion-color(primary, base)}; + --color: #{ion-color(primary, contrast)}; + --padding-top: #{$badge-padding-top}; + --padding-end: #{$badge-padding-end}; + --padding-bottom: #{$badge-padding-bottom}; + --padding-start: #{$badge-padding-start}; @include font-smoothing(); - @include padding($badge-padding-top, $badge-padding-end, $badge-padding-bottom, $badge-padding-start); + @include padding(var(--padding-top), var(--padding-end), var(--padding-bottom), var(--padding-start)); display: inline-block; min-width: $badge-min-width; - background-color: #{current-color(base)}; - color: #{current-color(contrast)}; + background: var(--background); + color: var(--color); font-size: $badge-font-size; font-weight: $badge-font-weight; @@ -30,6 +43,11 @@ vertical-align: baseline; } +:host(.ion-color) { + background: #{current-color(base)}; + color: #{current-color(contrast)}; +} + :host(:empty) { display: none; } diff --git a/core/src/components/badge/readme.md b/core/src/components/badge/readme.md index 6575d10b14d..ec767baec73 100644 --- a/core/src/components/badge/readme.md +++ b/core/src/components/badge/readme.md @@ -44,6 +44,17 @@ The mode determines which platform styles to use. Possible values are: `"ios"` or `"md"`. +## CSS Custom Properties + +| Name | Description | +| ------------------ | --------------------------- | +| `--background` | Background of the badge | +| `--color` | Text color of the badge | +| `--padding-bottom` | Padding bottom of the badge | +| `--padding-end` | Padding end of the badge | +| `--padding-start` | Padding start of the badge | +| `--padding-top` | Padding top of the badge | + ---------------------------------------------- diff --git a/core/src/components/badge/test/standalone/index.html b/core/src/components/badge/test/standalone/index.html index f60f449d911..06f92da8c1d 100644 --- a/core/src/components/badge/test/standalone/index.html +++ b/core/src/components/badge/test/standalone/index.html @@ -9,10 +9,14 @@ - + +

Default

+ 99 +
+ 11 22 @@ -23,5 +27,44 @@ 77 88 99 + +

Custom

+ + + wide + large + round + + + custom + custom w/ secondary + +