# Source chips

The **source chip** allows users to inspect the origins of generated or referenced content.

## Usage

Use source chips to keep a response transparent about its references. Selecting a chip opens a popover with the source entry and a short excerpt.

- Use the **default source chip** when one source supports the whole response. It appears as a summary chip at the end.
- Use the **compact source chip** when a claim needs a source next to it. It appears inline with the text it supports. Use a `+n` counter when several sources support the same claim.

![Source chips](<../images/source-chip.png>)

### When to use

- In [AI answers](<https://element.siemens.io/components/chat-messages/ai-chat/>), research summaries, or any content grounded in documents or external data.

## Design

### Anatomy

![Source chips anatomy](<../images/source-chip-anatomy.png>)

1. **Source label:** Shows the source title for a single source, or `Sources` when the chip groups multiple sources.
2. **Icon (optional):** Marks the source as a web link. Include it when the source is external.
3. **Source entry title:** The title shown for each source in the popover list.
4. **Relevant excerpt:** Short snippet showing the exact passage the AI used.

### States

![Source chips states](<../images/source-chips-states.png>)

## Code

Provide the sources through the `sources` input and handle `sourceClicked` to open the selected source or show it in the application.

```
import { Component } from '@angular/core';
import { SiSourceChipComponent, type SourceReference } from '@siemens/element-ng/source-chip';

@Component({
  imports: [SiSourceChipComponent],
  template: `<si-source-chip compact [sources]="sources" (sourceClicked)="openSource($event)" />`
})
export class SourceChipExampleComponent {
  protected readonly sources: SourceReference[] = [
    {
      name: 'Annual Report 2025',
      url: 'https://example.com/annual-report',
      quote: 'Revenue increased by 12% in 2025.'
    }
  ];

  protected openSource(source: SourceReference): void {
    window.open(source.url, '_blank', 'noopener');
  }
}
```

Use `showLabel` to always display **Sources** instead of a source name, and `showIcon` to display the source icon. Set `disabled` when source details must not be available.

#### Example

Component:

```typescript
/**
 * Copyright (c) Siemens 2016 - 2026
 * SPDX-License-Identifier: MIT
 */
import { Component, inject } from '@angular/core';
import { SiSourceChipComponent, type SourceReference } from '@siemens/element-ng/source-chip';
import { LOG_EVENT } from '@siemens/live-preview';

@Component({
  selector: 'app-sample',
  imports: [SiSourceChipComponent],
  templateUrl: './si-source-chip.html'
})
export class SampleComponent {
  protected logEvent = inject(LOG_EVENT);

  protected readonly compactSources: SourceReference[] = [
    {
      name: 'Comprehensive annual operational performance and sustainability report',
      url: 'https://example.com/annual-report',
      description: 'Annual summary of operational and sustainability performance.'
    }
  ];

  protected readonly compactMultipleSources: SourceReference[] = [
    {
      name: 'Maintenance status',
      url: 'https://example.com/maintenance-status',
      description: 'Current status of scheduled maintenance work.'
    },
    {
      name: 'Service log',
      url: 'https://example.com/service-log',
      description: 'Completed service activities for this asset.'
    },
    {
      name: 'Inspection report',
      url: 'https://example.com/inspection-report',
      description: 'Latest inspection findings and recommended actions.'
    }
  ];

  protected readonly labelledSources: SourceReference[] = [
    {
      name: 'Operations dashboard',
      url: 'https://example.com/operations',
      description: 'Current production and service performance metrics.'
    },
    {
      name: 'Maintenance log',
      url: 'https://example.com/maintenance',
      description: 'Completed and scheduled maintenance activities.'
    },
    {
      name: 'Safety report',
      url: 'https://example.com/safety',
      description: 'Safety observations and corrective actions.'
    }
  ];
}
```

Template:

```html
<div class="p-5 d-flex flex-column gap-6">
  <section>
    <h3 class="h5">Compact source</h3>
    <si-source-chip compact [sources]="compactSources" (sourceClicked)="logEvent($event)" />
  </section>

  <section>
    <h3 class="h5">Compact multiple sources</h3>
    <si-source-chip compact [sources]="compactMultipleSources" (sourceClicked)="logEvent($event)" />
  </section>

  <section>
    <h3 class="h5">Sources with icon and label</h3>
    <si-source-chip
      showIcon
      showLabel
      [sources]="labelledSources"
      (sourceClicked)="logEvent($event)"
    />
  </section>
</div>
```

### [SiSourceChipComponent](<https://github.com/siemens/element/blob/main/projects/element-ng/source-chip/si-source-chip.component.ts#L33-L70>)

**Kind:** component

**Selector:** `si-source-chip`

```
import { SiSourceChipComponent } from '@siemens/element-ng/source-chip';
```

```
component SiSourceChipComponent
```

#### Input Properties

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [compact](<https://github.com/siemens/element/blob/main/projects/element-ng/source-chip/si-source-chip.component.ts#L50-L50>) | `boolean` | `false` | Compact mode for inline use. |
| [disabled](<https://github.com/siemens/element/blob/main/projects/element-ng/source-chip/si-source-chip.component.ts#L55-L55>) | `boolean` | `false` | Disabled state. |
| [showIcon](<https://github.com/siemens/element/blob/main/projects/element-ng/source-chip/si-source-chip.component.ts#L38-L38>) | `boolean` | `false` | Wether to show the glob icon. |
| [showLabel](<https://github.com/siemens/element/blob/main/projects/element-ng/source-chip/si-source-chip.component.ts#L43-L43>) | `boolean` | `false` | Wether to show a 'sources' label |
| [sources](<https://github.com/siemens/element/blob/main/projects/element-ng/source-chip/si-source-chip.component.ts#L45-L45>) (required) | `SourceReference[]` |  | The sources. |

#### Output Properties

| Name | Type | Description |
| --- | --- | --- |
| [sourceClicked](<https://github.com/siemens/element/blob/main/projects/element-ng/source-chip/si-source-chip.component.ts#L58-L58>) | `SourceReference` | Emitted when a source has been clicked. |

### Types Documentation

### [SourceReference](<https://github.com/siemens/element/blob/main/projects/element-ng/source-chip/si-source-chip.model.ts#L7-L16>)

**Kind:** interface

```
import type { SourceReference } from '@siemens/element-ng/source-chip';
```

Definition of a single source

```
interface SourceReference
```

#### Properties

| Name | Type | Description |
| --- | --- | --- |
| [description](<https://github.com/siemens/element/blob/main/projects/element-ng/source-chip/si-source-chip.model.ts#L13-L13>) (optional) | `string` | Optional source description. |
| [name](<https://github.com/siemens/element/blob/main/projects/element-ng/source-chip/si-source-chip.model.ts#L9-L9>) | `string` | Source name displayed to the user. |
| [quote](<https://github.com/siemens/element/blob/main/projects/element-ng/source-chip/si-source-chip.model.ts#L15-L15>) (optional) | `string` | Optional source quote. Takes precedence over [description](<index.html#t:SourceReference.description>). |
| [url](<https://github.com/siemens/element/blob/main/projects/element-ng/source-chip/si-source-chip.model.ts#L11-L11>) | `string` | Source URL. |
