feat(chip): support href attribute for link chips (#545)
Summary
Fixes #545 — The it-chip component now supports the href attribute for navigable chips.
Problem
The chip component always rendered as <div class="chip">, making it impossible to use the href attribute. Users had to manually construct the HTML structure as a workaround.
Solution
Added an @Input() href property. When set, the chip renders as <a class="chip" [href]="href"> instead of <div class="chip">, following Bootstrap Italia's a.chip CSS pattern.
Uses <ng-template> to share inner content (icon, avatar, label, close button) between both rendering branches, avoiding duplication.
Changes
| File | What changed |
|---|---|
chip.component.ts |
Added @Input() href, added NgTemplateOutlet import |
chip.component.html |
Conditional <a>/<div> rendering with shared #chipContent template |
Usage
<it-chip label="Argomento"></it-chip>
<it-chip label="Argomento" href="https://designers.italia.it"></it-chip>
Testing
- 3 new regression tests:
- Without href → renders
<div>wrapper - With href → renders
<a>wrapper with correct href - With href + size + color → preserves all CSS classes
- Without href → renders
- All 112 existing tests pass ✅
- 0 lint errors ✅
- Chip tests: 100% statement/line/function coverage
⚠️ This reopens #620 which was accidentally closed due to fork deletion.
@giulio-leone is attempting to deploy a commit to the dip-trasformazione-digitale Team on Vercel.
A member of the Team first needs to authorize it.
The latest updates on your projects. Learn more about Vercel for GitHub.
| Project | Deployment | Actions | Updated (UTC) |
|---|---|---|---|
| design-angular-kit | Preview | Mar 27, 2026 3:56pm |