diff --git a/demo/e2e/screenshot.spec.ts b/demo/e2e/screenshot.spec.ts index f308baf..5e71be1 100644 --- a/demo/e2e/screenshot.spec.ts +++ b/demo/e2e/screenshot.spec.ts @@ -33,6 +33,7 @@ const routes = [ ...typesPath({ path: '/main/index/action-sheet', name: 'action-sheet' }, actionSheetTypes), ...typesPath({ path: '/main/index/alert', name: 'alert' }, alertTypes), { path: '/main/index/button', name: 'button' }, + { path: '/main/index/toolbar-badge', name: 'toolbar-badge' }, { path: '/main/index/checkbox', name: 'checkbox' }, { path: '/main/index/range', name: 'range' }, ...typesPath({ path: '/main/index/toast', name: 'toast' }, toastTypes), @@ -74,6 +75,11 @@ const prepareScreenShot = async (page: Page, routeName: string) => { await expect(focused).toBeFocused(); await expect(focused).toHaveClass(/ion-focused/); } + if (routeName === 'toolbar-badge') { + // Keep both directions and the unaffected-control examples in one image. + await page.setViewportSize({ width: 1200, height: 1000 }); + return; + } if (!routeName.includes(':')) { const scrollHeight = await page.locator('ion-content[role="main"]:visible').evaluate(async (el: any) => { const scrollEl = await el.getScrollElement(); diff --git a/demo/e2e/screenshot.spec.ts-snapshots/device-toolbar-badge-dark.png b/demo/e2e/screenshot.spec.ts-snapshots/device-toolbar-badge-dark.png new file mode 100644 index 0000000..681b66f Binary files /dev/null and b/demo/e2e/screenshot.spec.ts-snapshots/device-toolbar-badge-dark.png differ diff --git a/demo/e2e/screenshot.spec.ts-snapshots/device-toolbar-badge-light.png b/demo/e2e/screenshot.spec.ts-snapshots/device-toolbar-badge-light.png new file mode 100644 index 0000000..b23d4d2 Binary files /dev/null and b/demo/e2e/screenshot.spec.ts-snapshots/device-toolbar-badge-light.png differ diff --git a/demo/e2e/screenshot.spec.ts-snapshots/toolbar-badge-dark.png b/demo/e2e/screenshot.spec.ts-snapshots/toolbar-badge-dark.png new file mode 100644 index 0000000..04d0f57 Binary files /dev/null and b/demo/e2e/screenshot.spec.ts-snapshots/toolbar-badge-dark.png differ diff --git a/demo/e2e/screenshot.spec.ts-snapshots/toolbar-badge.png b/demo/e2e/screenshot.spec.ts-snapshots/toolbar-badge.png new file mode 100644 index 0000000..6ae4922 Binary files /dev/null and b/demo/e2e/screenshot.spec.ts-snapshots/toolbar-badge.png differ diff --git a/demo/src/app/docs/docs-content.generated.ts b/demo/src/app/docs/docs-content.generated.ts index 951ab4f..fa53064 100644 --- a/demo/src/app/docs/docs-content.generated.ts +++ b/demo/src/app/docs/docs-content.generated.ts @@ -1,3 +1,3 @@ // Generated from docs/special-markup.md. Do not edit directly. export const docsContentHtml = - '

Special markup

\n

Most Ionic markup works without changes. Shared markup carries the same meaning in\n@rdlabo/ionic-theme-ios27 and this theme; its appearance follows the active platform.\nAndroid Settings is the MD3 visual reference. Shared markup does not request an iOS\nGlass appearance on Android.

\n

Submit buttons

\n

Use type="submit" for a real form submission. If submitting through a form is not\npossible, type="button" class="button-submit" identifies the equivalent action;\nthe class only describes appearance and does not submit, validate, or install a handler.\nFor a filled primary action, use Ionic's public fill="solid". MD3 already renders\nsolid buttons using the palette's base/contrast pair, so these two forms share the\nsame Android appearance without an additional effect or JavaScript helper.

\n
<ion-button type="submit" fill="solid" color="primary">Submit</ion-button>\n<ion-button type="button" class="button-submit" fill="solid" color="primary">Continue</ion-button>
\n\n
\n
Preview
\nSubmit\nContinue\n
\n\n

Explicit Ionic colors, disabled state, and fill="clear" / fill="outline" keep their\nnormal meaning. The class does not force a different fill.

\n

Preferred overlay actions

\n

For alerts and action sheets, use role: 'preferred' for the recommended action,\nmatching the iOS 27 theme's convention. Appearance follows the overlay's purpose:\nan Alert uses a filled primary/on-primary action, while an Action Sheet keeps the\nsame full-width row geometry as its other choices and emphasizes its text/icon\nwith primary color and medium weight. The Action Sheet's Cancel group is separated\nfrom the choices by spacing and a divider. Colors derive from the Ionic palette\nunless optional Material roles are supplied. Ordinary/default actions remain text\nactions; confirm alone does not request emphasis. Cancellation, selection, and\ndestructive roles remain separate from recommendation.

\n
buttons: [\n  { text: \'Cancel\', role: \'cancel\' },\n  { text: \'Continue\', role: \'preferred\' },\n];
\n\n

This custom Ionic role does not select or invoke an action automatically. The\nbutton's handler runs normally and dismissal reports preferred; handle that\nrole explicitly if the application inspects dismissal results. cancel retains\nIonic cancellation behavior. Do not replace cancel, selected, or destructive\nwith preferred just to change their color.

\n

Two-line inset list items

\n

Place an unslotted ion-label immediately alongside an unslotted ion-note to render a two-line item. Wrap inset items in ion-item-group and keep ion-list-header outside the group. Use slot="end" on ion-note when you want the standard trailing-note layout instead.

\n
<ion-list inset="true">\n  <ion-item-group>\n    <ion-item>\n      <ion-label>Network &amp; internet</ion-label>\n      <ion-note>Mobile, Wi-Fi, hotspot</ion-note>\n    </ion-item>\n  </ion-item-group>\n</ion-list>
\n\n
\n
Preview
\n\n \n \n Network & internet\n Mobile, Wi-Fi, hotspot\n \n \n\n
\n\n

Square buttons

\n

Add .button-square when a button should use more squared corners. It works with text buttons and icon-only buttons.

\n
<ion-button class="button-square" fill="solid">Continue</ion-button>\n<ion-button class="button-square" fill="solid">\n  <ion-icon name="add" slot="icon-only"></ion-icon>\n</ion-button>
\n\n
\n
Preview
\nContinue\n\n \n\n
\n\n

Inset-list section headers

\n

Add .item-group-header to an ion-item-group to create the centered icon, title, and description used at the top of the component demo pages.

\n

This is an introductory group. Place regular list items in a separate ion-item-group that follows it.

\n
<ion-list inset="true">\n  <ion-item-group class="item-group-header">\n    <ion-item>\n      <ion-label>\n        <ion-icon name="list" style="background: var(--ion-color-primary)"></ion-icon>\n        <h2>Lists</h2>\n        <ion-text>Inset-list examples</ion-text>\n      </ion-label>\n    </ion-item>\n  </ion-item-group>\n  <ion-item-group>\n    <ion-item><ion-label>First item</ion-label></ion-item>\n  </ion-item-group>\n</ion-list>
\n\n
\n
Preview
\n\n \n \n \n \n

Lists

\n Inset-list examples\n
\n
\n
\n \n First item\n \n
\n
\n\n

Android Settings controls

\n

The standard toggle is icon-free. Ionic's enableOnOffLabels remains available\nwhen the application explicitly requests labels:

\n
<ion-list inset="true">\n  <ion-item-group>\n    <ion-item><ion-toggle justify="space-between">Notifications</ion-toggle></ion-item>\n    <ion-item>\n      <ion-toggle justify="space-between" enable-on-off-labels="true">Notifications with on/off labels</ion-toggle>\n    </ion-item>\n  </ion-item-group>\n</ion-list>
\n\n
\n
Preview
\n\n \n Notifications\n \n Notifications with on/off labels\n \n \n\n
\n\n

The theme uses a 52×28px track and 20px thumb. Grouped rows have a 56px minimum\nheight, or 72px for radio rows; long content can grow. Use Ionic's public CSS\nvariables for application sizing, and keep the shared list structure.

\n

The main theme supplies a CSS-only MD font default using local Google Sans Flex\nwhen available and standard fallbacks otherwise. An application's\n--ion-font-family takes priority. Back icons are managed by Ionic; the theme does\nnot bundle a replacement. See Android Settings appearance\nfor font defaults, fallbacks and application overrides.\nReview the migration guide\nwhen updating applications with custom dimensions. These options preserve Ionic's\npalette intent and explicit component properties.

\n

Platform-specific extensions

\n

The shared structure above works without platform-specific templates. iOS-only\nsegment-style-glass, searchbar-classic, floating iPad sheets, and iOS tab-bar\npositioning are not Android appearance requirements. MD3 retains Ionic's segment,\nsearchbar, modal, and tab-bar behavior. .button-square is an optional MD3 shape\nextension, not a required shared markup convention.

\n

Opting out

\n

Add .md3-disabled to an individual Ionic component when it must retain Ionic's standard Material styling.

\n
<ion-button fill="solid">MD3 theme</ion-button> <ion-button class="md3-disabled" fill="solid">Standard Ionic</ion-button>
\n\n
\n
Preview
\nMD3 theme Standard Ionic\n
\n'; + '

Special markup

\n

Most Ionic markup works without changes. Shared markup carries the same meaning in\n@rdlabo/ionic-theme-ios27 and this theme; its appearance follows the active platform.\nAndroid Settings is the MD3 visual reference. Shared markup does not request an iOS\nGlass appearance on Android.

\n

Submit buttons

\n

Use type="submit" for a real form submission. If submitting through a form is not\npossible, type="button" class="button-submit" identifies the equivalent action;\nthe class only describes appearance and does not submit, validate, or install a handler.\nFor a filled primary action, use Ionic's public fill="solid". MD3 already renders\nsolid buttons using the palette's base/contrast pair, so these two forms share the\nsame Android appearance without an additional effect or JavaScript helper.

\n
<ion-button type="submit" fill="solid" color="primary">Submit</ion-button>\n<ion-button type="button" class="button-submit" fill="solid" color="primary">Continue</ion-button>
\n\n
\n
Preview
\nSubmit\nContinue\n
\n\n

Explicit Ionic colors, disabled state, and fill="clear" / fill="outline" keep their\nnormal meaning. The class does not force a different fill.

\n

Toolbar button badges

\n

Place ion-badge directly inside an ion-button in an ion-toolbar. Both\nstandalone buttons and buttons inside ion-buttons support this markup.\nAn empty badge shows an unread indicator; text such as 3 or 99+ shows a count.\nFor an indicator, keep the contents completely empty (<ion-badge></ion-badge>),\nwithout spaces or line breaks between the tags.

\n

Standalone toolbar button:

\n
<ion-toolbar>\n  <ion-button slot="end" aria-label="Notifications">\n    <ion-icon name="ellipsis-horizontal" slot="icon-only"></ion-icon>\n    <ion-badge>3</ion-badge>\n  </ion-button>\n</ion-toolbar>
\n\n
\n
Preview
\n\n \n \n 3\n \n\n
\n\n

Grouped toolbar buttons, with empty, numeric and wide badges:

\n
<ion-toolbar>\n  <ion-buttons slot="end">\n    <ion-button aria-label="Unread notifications">\n      <ion-icon name="ellipsis-horizontal" slot="icon-only"></ion-icon>\n      <ion-badge></ion-badge>\n    </ion-button>\n    <ion-button aria-label="3 notifications">\n      <ion-icon name="ellipsis-horizontal" slot="icon-only"></ion-icon>\n      <ion-badge>3</ion-badge>\n    </ion-button>\n    <ion-button aria-label="99 or more notifications">\n      <ion-icon name="ellipsis-horizontal" slot="icon-only"></ion-icon>\n      <ion-badge>99+</ion-badge>\n    </ion-button>\n  </ion-buttons>\n</ion-toolbar>
\n\n
\n
Preview
\n\n \n \n \n \n \n \n \n 3\n \n \n \n 99+\n \n \n\n
\n\n

Use the badge's color property to choose an Ionic color. Setting hidden or\ndisplay: none, or removing the badge, hides it without changing the action's\nlayout. Include the notification state in the action's accessible label.

\n

The treatment is limited to direct-child badges in toolbar buttons. Badges in\ntabs, outside toolbars, or nested in another child keep their existing styling.\nTheme opt-outs on the toolbar, group, button or badge remain supported.

\n

Preferred overlay actions

\n

For alerts and action sheets, use role: 'preferred' for the recommended action,\nmatching the iOS 27 theme's convention. Appearance follows the overlay's purpose:\nan Alert uses a filled primary/on-primary action, while an Action Sheet keeps the\nsame full-width row geometry as its other choices and emphasizes its text/icon\nwith primary color and medium weight. The Action Sheet's Cancel group is separated\nfrom the choices by spacing and a divider. Colors derive from the Ionic palette\nunless optional Material roles are supplied. Ordinary/default actions remain text\nactions; confirm alone does not request emphasis. Cancellation, selection, and\ndestructive roles remain separate from recommendation.

\n
buttons: [\n  { text: \'Cancel\', role: \'cancel\' },\n  { text: \'Continue\', role: \'preferred\' },\n];
\n\n

This custom Ionic role does not select or invoke an action automatically. The\nbutton's handler runs normally and dismissal reports preferred; handle that\nrole explicitly if the application inspects dismissal results. cancel retains\nIonic cancellation behavior. Do not replace cancel, selected, or destructive\nwith preferred just to change their color.

\n

Two-line inset list items

\n

Place an unslotted ion-label immediately alongside an unslotted ion-note to render a two-line item. Wrap inset items in ion-item-group and keep ion-list-header outside the group. Use slot="end" on ion-note when you want the standard trailing-note layout instead.

\n
<ion-list inset="true">\n  <ion-item-group>\n    <ion-item>\n      <ion-label>Network &amp; internet</ion-label>\n      <ion-note>Mobile, Wi-Fi, hotspot</ion-note>\n    </ion-item>\n  </ion-item-group>\n</ion-list>
\n\n
\n
Preview
\n\n \n \n Network & internet\n Mobile, Wi-Fi, hotspot\n \n \n\n
\n\n

Square buttons

\n

Add .button-square when a button should use more squared corners. It works with text buttons and icon-only buttons.

\n
<ion-button class="button-square" fill="solid">Continue</ion-button>\n<ion-button class="button-square" fill="solid">\n  <ion-icon name="add" slot="icon-only"></ion-icon>\n</ion-button>
\n\n
\n
Preview
\nContinue\n\n \n\n
\n\n

Inset-list section headers

\n

Add .item-group-header to an ion-item-group to create the centered icon, title, and description used at the top of the component demo pages.

\n

This is an introductory group. Place regular list items in a separate ion-item-group that follows it.

\n
<ion-list inset="true">\n  <ion-item-group class="item-group-header">\n    <ion-item>\n      <ion-label>\n        <ion-icon name="list" style="background: var(--ion-color-primary)"></ion-icon>\n        <h2>Lists</h2>\n        <ion-text>Inset-list examples</ion-text>\n      </ion-label>\n    </ion-item>\n  </ion-item-group>\n  <ion-item-group>\n    <ion-item><ion-label>First item</ion-label></ion-item>\n  </ion-item-group>\n</ion-list>
\n\n
\n
Preview
\n\n \n \n \n \n

Lists

\n Inset-list examples\n
\n
\n
\n \n First item\n \n
\n
\n\n

Android Settings controls

\n

The standard toggle is icon-free. Ionic's enableOnOffLabels remains available\nwhen the application explicitly requests labels:

\n
<ion-list inset="true">\n  <ion-item-group>\n    <ion-item><ion-toggle justify="space-between">Notifications</ion-toggle></ion-item>\n    <ion-item>\n      <ion-toggle justify="space-between" enable-on-off-labels="true">Notifications with on/off labels</ion-toggle>\n    </ion-item>\n  </ion-item-group>\n</ion-list>
\n\n
\n
Preview
\n\n \n Notifications\n \n Notifications with on/off labels\n \n \n\n
\n\n

The theme uses a 52×28px track and 20px thumb. Grouped rows have a 56px minimum\nheight, or 72px for radio rows; long content can grow. Use Ionic's public CSS\nvariables for application sizing, and keep the shared list structure.

\n

The main theme supplies a CSS-only MD font default using local Google Sans Flex\nwhen available and standard fallbacks otherwise. An application's\n--ion-font-family takes priority. Back icons are managed by Ionic; the theme does\nnot bundle a replacement. See Android Settings appearance\nfor font defaults, fallbacks and application overrides.\nReview the migration guide\nwhen updating applications with custom dimensions. These options preserve Ionic's\npalette intent and explicit component properties.

\n

Platform-specific extensions

\n

The shared structure above works without platform-specific templates. iOS-only\nsegment-style-glass, searchbar-classic, floating iPad sheets, and iOS tab-bar\npositioning are not Android appearance requirements. MD3 retains Ionic's segment,\nsearchbar, modal, and tab-bar behavior. .button-square is an optional MD3 shape\nextension, not a required shared markup convention.

\n

Opting out

\n

Add .md3-disabled to an individual Ionic component when it must retain Ionic's standard Material styling.

\n
<ion-button fill="solid">MD3 theme</ion-button> <ion-button class="md3-disabled" fill="solid">Standard Ionic</ion-button>
\n\n
\n
Preview
\nMD3 theme Standard Ionic\n
\n'; diff --git a/demo/src/app/docs/docs-page.component.spec.ts b/demo/src/app/docs/docs-page.component.spec.ts index e4fa1ef..bb6af23 100644 --- a/demo/src/app/docs/docs-page.component.spec.ts +++ b/demo/src/app/docs/docs-page.component.spec.ts @@ -25,6 +25,6 @@ describe('DocsPage', () => { expect(element.querySelector('article.docs-content h1')?.textContent).toContain('Special markup'); expect(element.querySelectorAll('.code-block-container pre.shiki code').length).toBeGreaterThan(0); expect(element.querySelector('.code-block-container code span[style*="color"]')).not.toBeNull(); - expect(element.querySelectorAll('figure.docs-example').length).toBe(6); + expect(element.querySelectorAll('figure.docs-example').length).toBe(8); }); }); diff --git a/demo/src/app/index/index-page.component.ts b/demo/src/app/index/index-page.component.ts index 0c030f6..911ed4d 100644 --- a/demo/src/app/index/index-page.component.ts +++ b/demo/src/app/index/index-page.component.ts @@ -74,6 +74,7 @@ export class IndexPageComponent { { name: 'toast', enable: true }, { name: 'toggle', enable: true }, { name: 'toolbar', enable: true }, + { name: 'toolbar-badge', enable: true }, ]); readonly enableComponents = computed(() => this.components().filter((c) => c.enable)); readonly disableComponents = computed(() => this.components().filter((c) => !c.enable)); diff --git a/demo/src/app/index/index.routes.ts b/demo/src/app/index/index.routes.ts index 4acea66..223b6b5 100644 --- a/demo/src/app/index/index.routes.ts +++ b/demo/src/app/index/index.routes.ts @@ -18,6 +18,10 @@ export const routes: Routes = [ path: 'color-palette', loadComponent: () => import('./pages/color-palette/color-palette.page').then((m) => m.ColorPalettePage), }, + { + path: 'toolbar-badge', + loadComponent: () => import('./pages/toolbar-badge/toolbar-badge.page').then((m) => m.ToolbarBadgePage), + }, { path: 'button', loadComponent: () => import('./pages/button/button.page').then((m) => m.ButtonPage), diff --git a/demo/src/app/index/pages/toolbar-badge/toolbar-badge.page.html b/demo/src/app/index/pages/toolbar-badge/toolbar-badge.page.html new file mode 100644 index 0000000..6595bbe --- /dev/null +++ b/demo/src/app/index/pages/toolbar-badge/toolbar-badge.page.html @@ -0,0 +1,78 @@ + + Toolbar badges + + +
+ @for (direction of directions; track direction) { +
+

{{ direction.toUpperCase() }}

+

Empty / 3 / 99+ / no badge

+

Standalone buttons

+ + @for (value of badges; track value) { + {{ value }} + } + + +

Grouped buttons

+ + + @for (value of badges; track value) { + {{ value }} + } + + + +

Single group / menu group

+ + 3 + 3 + +

Custom color / hidden / CSS class / opt-out

+ + 3 + 3 + + + 3 + +

Outside toolbar / nested badge

+ 3 + Nested 3 +
+ } +
+
diff --git a/demo/src/app/index/pages/toolbar-badge/toolbar-badge.page.scss b/demo/src/app/index/pages/toolbar-badge/toolbar-badge.page.scss new file mode 100644 index 0000000..987e4b4 --- /dev/null +++ b/demo/src/app/index/pages/toolbar-badge/toolbar-badge.page.scss @@ -0,0 +1,26 @@ +.badge-examples { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: 24px; + padding: 24px; +} + +h2 { + margin: 0 0 12px; + font-size: 20px; +} + +h3 { + margin: 20px 0 8px; + font-size: 14px; +} + +@media (max-width: 700px) { + .badge-examples { + grid-template-columns: 1fr; + } +} + +.badge-off { + display: none; +} diff --git a/demo/src/app/index/pages/toolbar-badge/toolbar-badge.page.ts b/demo/src/app/index/pages/toolbar-badge/toolbar-badge.page.ts new file mode 100644 index 0000000..54f9208 --- /dev/null +++ b/demo/src/app/index/pages/toolbar-badge/toolbar-badge.page.ts @@ -0,0 +1,28 @@ +import { ChangeDetectionStrategy, Component } from '@angular/core'; +import { + IonBadge, + IonBackButton, + IonButton, + IonButtons, + IonContent, + IonHeader, + IonIcon, + IonMenuButton, + IonTitle, + IonToolbar, +} from '@demo/ionic'; +import { ellipsisHorizontal } from 'ionicons/icons'; + +@Component({ + selector: 'app-toolbar-badge', + standalone: true, + imports: [IonBadge, IonBackButton, IonButton, IonButtons, IonContent, IonHeader, IonIcon, IonMenuButton, IonTitle, IonToolbar], + templateUrl: './toolbar-badge.page.html', + styleUrls: ['./toolbar-badge.page.scss'], + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class ToolbarBadgePage { + readonly more = ellipsisHorizontal; + readonly directions = ['ltr', 'rtl'] as const; + readonly badges = ['', '3', '99+']; +} diff --git a/docs/special-markup.md b/docs/special-markup.md index e881443..aed8deb 100644 --- a/docs/special-markup.md +++ b/docs/special-markup.md @@ -26,6 +26,54 @@ same Android appearance without an additional effect or JavaScript helper. Explicit Ionic colors, disabled state, and `fill="clear"` / `fill="outline"` keep their normal meaning. The class does not force a different fill. +## Toolbar button badges + +Place `ion-badge` directly inside an `ion-button` in an `ion-toolbar`. Both +standalone buttons and buttons inside `ion-buttons` support this markup. +An empty badge shows an unread indicator; text such as `3` or `99+` shows a count. +For an indicator, keep the contents completely empty (``), +without spaces or line breaks between the tags. + +Standalone toolbar button: + +```html preview + + + + 3 + + +``` + +Grouped toolbar buttons, with empty, numeric and wide badges: + +```html preview + + + + + + + + + 3 + + + + 99+ + + + +``` + +Use the badge's `color` property to choose an Ionic color. Setting `hidden` or +`display: none`, or removing the badge, hides it without changing the action's +layout. Include the notification state in the action's accessible label. + +The treatment is limited to direct-child badges in toolbar buttons. Badges in +tabs, outside toolbars, or nested in another child keep their existing styling. +Theme opt-outs on the toolbar, group, button or badge remain supported. + ## Preferred overlay actions For alerts and action sheets, use `role: 'preferred'` for the recommended action, diff --git a/src/styles/components/ion-button.scss b/src/styles/components/ion-button.scss index 1cfedfb..1ae4caa 100644 --- a/src/styles/components/ion-button.scss +++ b/src/styles/components/ion-button.scss @@ -1,3 +1,5 @@ +@use '../utils/colors' as md3; + @mixin theme-button() { // Default is be round button --box-shadow: none; @@ -113,3 +115,62 @@ ion-back-button.md:not(.md3-disabled) { --padding-start: 16px; --padding-end: 16px; } + +// Badge layout belongs only to toolbar buttons with a direct badge child. +ion-toolbar.md:not(.md3-disabled) { + ion-button.md:has(> ion-badge:not(.md3-disabled)):not(.md3-disabled):not(:where(ion-buttons:is(.md3-disabled) *)) { + // Keep the action's layout and hit area; only the badge paints outside it. + overflow: visible; + + &::part(native) { + overflow: visible; + contain: none; + } + + > ion-badge:not(.md3-disabled) { + --background: #{md3.color(error)}; + --color: #{md3.color(on-error)}; + position: absolute; + box-sizing: border-box; + margin: 0; + pointer-events: none; + z-index: 1; + --padding-top: 0px; + --padding-bottom: 0px; + --padding-start: 4px; + --padding-end: 4px; + min-width: 16px; + height: 16px; + border-radius: 8px; + font-size: 11px; + font-weight: 500; + line-height: 16px; + letter-spacing: 0; + text-transform: none; + unicode-bidi: plaintext; + // Material's text badge grows from the icon center toward the trailing edge. + inset-block-start: calc(50% - 16px); + inset-inline-start: 50%; + + &[hidden] { + display: none; + } + + // Override Ionic's empty-badge default without outranking application classes. + :where(&:empty) { + display: inline-block; + } + + &:empty { + --padding-start: 0px; + --padding-end: 0px; + min-width: 6px; + width: 6px; + height: 6px; + border-radius: 3px; + inset-block-start: calc(50% - 12px); + inset-inline-start: calc(50% + 6px); + } + } + } +}