angular / angular/components

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

Aperta
#31,628 3 commenti 1 reazione 0 assegnatari Vedi su GitHub
area: material/chips docs P2
Lingua principale
TypeScript
Stelle
25k
Fork
6.8k
Merge medio
1g 8h
PR unite (30g)
91

Descrizione

### 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

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia con la sezione interessata della documentazione di MatChip e confronta le sue affermazioni con src/material/chips/chip.html. Riproduci il comportamento segnalato usando l'esempio StackBlitz collegato, incluso il caso matChipAvatar. Il lavoro è completato quando la documentazione riflette accuratamente il comportamento supportato dello slot iniziale e i suoi esempi non inducono più in errore gli utenti.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
angular, typescript
Ambito
documentation, frontend
Tipo di issue
Documentazione
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.