angular / angular/components

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

Offen
#31,628 3 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen
area: material/chips docs P2
Vorherrschende Sprache
TypeScript
Sterne
25k
Forks
6.8k
Ø Merge
1 T. 8 Std.
Gemergte PRs (30 T.)
91

Beschreibung

### Documentation Feedback

The [documentation for MatChip](https://material.angular.dev/components/chips/overview#adding-up-to-two-icons-with-content-projection) 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 \, \, and \.

This suggests two possible slots for a `` (leading or trailing the chip text). However, this doesn't work in practice, and looking at the [template code](https://github.com/angular/components/blob/main/src/material/chips/chip.html) 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](https://m3.material.io/components/chips/overview)). 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

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne mit dem betroffenen Dokumentationsabschnitt zu MatChip und vergleiche dessen Aussagen mit src/material/chips/chip.html. Reproduziere das gemeldete Verhalten anhand des verlinkten StackBlitz-Beispiels, einschließlich des Falls matChipAvatar. Die Aufgabe ist erledigt, wenn die Dokumentation das unterstützte Verhalten des führenden Slots korrekt wiedergibt und ihre Beispiele die Nutzer nicht mehr in die Irre führen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
angular, typescript
Bereich
documentation, frontend
Issue-Typ
Dokumentation
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.