> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.

# `<svg>`

Draws SVG from a markup string or a URL. Unlike HTML, you can't write SVG tags in the template: pass the markup as text, and give the element a width and height.


## Usage

```typescript title="src/app/dot.ts"
import { Component } from '@angular/core';
import { LYNX_ELEMENTS } from '@blotch/angular-lynx';

@Component({
  selector: 'app-dot',
  imports: [LYNX_ELEMENTS],
  template: `<svg [content]="icon" style="width: 24px; height: 24px;" />`,
})
export class Dot {
  readonly icon = `<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
    <circle cx="12" cy="12" r="10" fill="#dd0031" />
  </svg>`;
}
```

Import `LYNX_ELEMENTS` in your component (see [Elements](/api/angular-lynx/elements/index.md)).

:::warning
Needs [XElement](/guide/glossary.md#xelement) in custom native apps (see [Embedding](/guide/embedding/index.md)).
:::

## Attributes

| Attribute       | Type     | Default | Description                                                                                                                               |
| --------------- | -------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| `content`       | `string` | —       | SVG markup to draw. See [Writing the markup](#writing-the-markup).                                                                        |
| `src`           | `string` | —       | URL of an SVG file. Use `src` or `content`, not both.                                                                                     |
| `current-color` | `string` | —       | iOS (Lynx 4.1 and later) and Android. The color `currentColor` stands for in the SVG. It doesn't override an explicit `fill` or `stroke`. |

Plus the [common attributes](/api/elements/view.md#attributes), such as `id`, `class` and `style`.

### Writing the markup

- **No CSS variables or page styles.** The markup can't use them.
- **Draw lines with `<path>`.** `<line>` doesn't show on iOS and Android.
- **Give the root `<svg>` `xmlns="http://www.w3.org/2000/svg"`.** Without it, the web preview draws nothing.
- **AngularLynx removes `stroke-dasharray` values iOS can't parse**, such as `none`. They would blank every SVG in the app.

## Events

Read the payload from `$event.detail`. Angular types `$event` for each event: see [Element events](/api/angular-lynx/element-events.md#image-and-svg).

| Event      | `detail`                            | Description        |
| ---------- | ----------------------------------- | ------------------ |
| `bindload` | `{ width: number; height: number }` | The SVG was drawn. |

Plus the [common events](/api/elements/view.md#events), such as `bindtap`.

## Related

- [`<image>`](/api/elements/image.md): PNG, JPEG, WebP and GIF images
- [Icon](/dolan/icon.md): the UI component that draws icons with `<svg>`
- [Chart](/dolan/chart.md): charts drawn with `<svg>`
