angular / angular/components

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

Ouverte
#31,628 3 commentaires 1 réaction 0 personnes assignées Voir sur GitHub
area: material/chips docs P2
Langage dominant
TypeScript
Étoiles
25k
Forks
6.8k
Merge moyen
1 j 8 h
PR mergées (30 j)
91

Description

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

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Commencez par la section de documentation concernée de MatChip et comparez ses affirmations avec src/material/chips/chip.html. Reproduisez le comportement signalé à l’aide de l’exemple StackBlitz lié, y compris le cas matChipAvatar. Le travail est terminé lorsque la documentation décrit correctement le comportement pris en charge du slot principal et que ses exemples n’induisent plus les utilisateurs en erreur.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
angular, typescript
Domaine
documentation, frontend
Type d'issue
Documentation
Difficulté
3/5
Temps estimé
1-2 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.