Skip to content

feat(chip): sync the md theme with Material Design 2 - #31779

Merged
thetaPC merged 18 commits into
ionic-modularfrom
chip-md-sync
Nov 20, 2026
Merged

thetaPC merged 18 commits into
ionic-modularfrom
chip-md-sync

Conversation

@thetaPC

@thetaPC thetaPC commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Issue number: internal


What is the current behavior?

The md chip has 8px corners and inherits its letter spacing and line height. It has 8px between an icon and the label, a 32% outline border, and lighter focus backgrounds than Material Design 2. A pressed chip darkens under the ripple. Its rem and em values are rounded to two decimals, so it renders slightly larger than on next (14.08px instead of 14px).

What is the new behavior?

The md chip matches Material Design 2 (Material Components Web 14 and the MD2 kit):

  • Pill shape by default (round). soft stays 8px
  • 0.0179em (0.25px) letter spacing. The large chip has a 20px line height. The small chip has 4px 8px padding and a 16px line height, which keep it at 24px, since MD2 has no small chip
  • 4px between a slotted icon and the label
  • Outline chips without a color have a 12% border
  • Focus backgrounds are 21% (solid) and 10% (outline). A pressed chip keeps its resting background, and the ripple shows the press
  • Disabled opacity is 0.38
  • Font, icon and avatar sizes are no longer rounded, so they match next
  • padding, letterSpacing and line.height move under each size (for example IonChip.size.large.padding). The ionic theme looks the same

Does this introduce a breaking change?

  • Yes
  • No

The md chip changes its shape, typography, icon spacing, outline border, focus and pressed backgrounds, and disabled opacity. The chip section of BREAKING.md lists each one with the global token and CSS variable that revert it.

Other information

How to test

Check Before After What to look for
Shape Before After Chips are pills instead of rounded rectangles. Tap one: the ripple plays over the resting background, which no longer darkens
Typography and icons Before After Labels are slightly wider apart, icons sit closer to the label, and small chips are narrower at the same height
Outline border Before After Outline chips without a color have a lighter border
Focus and disabled Before After Focused chips without a color are darker, outline ones too. Disabled chips are a touch fainter

@vercel

vercel Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
ionic-framework Ready Ready Preview Nov 19, 2026 10:04pm UTC

Request Review

@thetaPC
thetaPC added this pull request to stack #31781 November 18, 2026 23:43
@thetaPC
thetaPC marked this pull request as ready for review November 19, 2026 01:44
@thetaPC
thetaPC requested a review from a team as a code owner November 19, 2026 01:44

@ShaneK ShaneK left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Just a couple of small things on the states.

state: {
disabled: {
opacity: '0.4',
opacity: '0.38',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think anything tests the new md focus and disabled values yet. The states test only runs ios and ionic-md, with a comment saying md doesn't differ from ios, which isn't true after this PR. The regenerated md screenshots are all resting chips, so if these went back to 0.16 and 0.4 CI would still pass.

Could you add 'md' to that test's configs and drop the comment? If you'd rather not add more screenshots, something like this works too. It passes on this branch and fails on ionic-modular:

/**
 * This behavior does not vary across directions.
 */
configs({ modes: ['md'], directions: ['ltr'] }).forEach(({ title, config }) => {
  test.describe(title('chip: md states'), () => {
    test('should use the MD2 focus backgrounds', async ({ page }) => {
      await page.setContent(
        `
          <ion-chip class="ion-focused" fill="solid">Solid</ion-chip>
          <ion-chip class="ion-focused" fill="outline">Outline</ion-chip>
        `,
        config
      );

      const chips = page.locator('ion-chip');

      await expect(chips.nth(0)).toHaveCSS('background-color', 'rgba(0, 0, 0, 0.21)');
      await expect(chips.nth(1)).toHaveCSS('background-color', 'rgba(0, 0, 0, 0.1)');
    });

    test('should use the MD2 disabled opacity', async ({ page }) => {
      await page.setContent(`<ion-chip disabled="true">Disabled</ion-chip>`, config);

      await expect(page.locator('ion-chip')).toHaveCSS('opacity', '0.38');
    });
  });
});

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

basic/chip.e2e.ts has the same "md doesn't differ from ios" comment (line 60), so it might be worth updating that one too while you're in there.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added md to the states test and removed the comment in 0e17e58, so the md focus and disabled screenshots now cover these values. I went with screenshots over the toHaveCSS checks to match the rest of the spec.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 0e17e58. The hue tests already screenshot the md outline and color chips, so the comment now points there instead of adding md to this test.


activated: {
background: rgba('var(--ion-text-color-rgb, 0, 0, 0)', 0.2),
background: rgba('var(--ion-text-color-rgb, 0, 0, 0)', 0.21),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the activated backgrounds removed, pressing a chip while hovering it with a mouse drops it back to its resting background, since the .ion-activated rule comes after :hover and falls back to the default. A bold solid chip goes from 0.16 on hover to 0.12 while pressed (it was 0.20 before), and an outline chip goes from 0.04 to transparent. The ripple still shows, but the chip gets lighter as you click it.

Was that intended for mouse too? Setting the activated backgrounds to the hover values would fix it on desktop, but I think it'd also tint touch presses, so I'm not sure which way is better here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more case: colored chips do the same. A bold solid chip with a color goes from 12% of its color on hover to 8% while pressed, and a bold outline one goes from 12% to transparent, since the semantic activated backgrounds are gone too.

One way to fix it without tinting touch presses: move the @media (any-hover: hover) hover blocks after the .ion-activated rules in chip.scss, so hover wins while the pointer is over the chip and pressing just adds the ripple. That matches MDC, which keeps the hover layer under the press ripple.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not intended on desktop. Fixed in 29e7fe5: a hovered chip that's pressed now keeps its hover background, so it shows the hover tint plus the ripple. Touch presses stay untinted, since the new rule only applies inside (any-hover: hover) while the chip is hovered. Themes that set an activated background, like ios, still use it.

I also added a test that covers every hue, fill and color.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 29e7fe5, colored chips included. I didn't move the hover blocks after the activated rules: ios keeps a pressed background that's darker than its hover one, and on desktop hover would hide it. Instead, an .ion-activated:hover rule inside (any-hover: hover) falls back from the activated background to the hover one. md keeps the hover layer under the ripple like MDC, and ios keeps its pressed value.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call!

@brandyscarney brandyscarney left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Requesting changes for three things: the md outline chips are 2px taller than MD2 (34px large, 26px small), a hovered chip gets lighter when pressed now that the activated backgrounds are gone, and BREAKING.md is missing the subtle outline border change and the activated values to revert to. The rest are smaller questions and nits.

Comment thread core/src/themes/md/default.tokens.ts Resolved

activated: {
background: rgba('var(--ion-text-color-rgb, 0, 0, 0)', 0.2),
background: rgba('var(--ion-text-color-rgb, 0, 0, 0)', 0.21),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more case: colored chips do the same. A bold solid chip with a color goes from 12% of its color on hover to 8% while pressed, and a bold outline one goes from 12% to transparent, since the semantic activated backgrounds are gone too.

One way to fix it without tinting touch presses: move the @media (any-hover: hover) hover blocks after the .ion-activated rules in chip.scss, so hover wins while the pointer is over the chip and pressing just adds the ripple. That matches MDC, which keeps the hover layer under the press ripple.

state: {
disabled: {
opacity: '0.4',
opacity: '0.38',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

basic/chip.e2e.ts has the same "md doesn't differ from ios" comment (line 60), so it might be worth updating that one too while you're in there.

Comment thread BREAKING.md Resolved
Comment thread BREAKING.md Resolved
Comment thread core/src/themes/md/default.tokens.ts Resolved
# Conflicts:
#	core/src/components/avatar/test/basic/avatar.e2e.ts-snapshots/avatar-chip-diff-md-ltr-Mobile-Firefox-linux.png
#	core/src/components/chip/test/a11y/chip.e2e.ts-snapshots/chip-large-contents-md-ltr-Mobile-Firefox-linux.png

@brandyscarney brandyscarney left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Great work.

@thetaPC
thetaPC merged commit e50c605 into ionic-modular Nov 20, 2026
54 checks passed
@thetaPC
thetaPC deleted the chip-md-sync branch November 20, 2026 18:09

This branch was successfully deployed

1 active deployment
Preview — 225401d1 Deployed Nov 19, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: core @ionic/core package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants