Skip to content

docs-bug(chips): MatChip does not natively support leading icon despite docs #31628

@benelliott

Description

@benelliott

Documentation Feedback

The documentation for MatChip states the following:

You can add two additional icons to an individual chip. A chip has two slots to display icons using content projection. All variants of chips support adding icons including <mat-chip>, <mat-chip-option>, and <mat-chip-row>.

This suggests two possible slots for a <mat-icon> (leading or trailing the chip text). However, this doesn't work in practice, and looking at the template code suggests that the chip only supports an avatar in the leading slot (despite the documentation stating "icon").

When you try to add an icon rather than an avatar, it's not aligned correctly. Adding the matChipAvatar directive doesn't help as the icon is clipped to a circle (and the alignment is still off).

In my opinion, a chip should support projecting an instance of MatIcon on the leading side (in fact, it's show in the MD spec). However, as it stands the documentation is misleading as to the current behaviour.

Image https://stackblitz.com/edit/gqzwx38r?file=src%2Fexample%2Fchips-avatar-example.html

Affected documentation page

https://material.angular.dev/components/chips/overview#adding-up-to-two-icons-with-content-projection

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2The issue is important to a large percentage of users, with a workaroundarea: material/chipsdocsThis issue is related to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions