2021-10-17 18:26:00 +02:00
|
|
|
---
|
2022-10-01 23:12:26 +02:00
|
|
|
title: Svg.defs
|
2021-10-17 18:26:00 +02:00
|
|
|
---
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-10-01 23:12:26 +02:00
|
|
|
The `Svg.defs` property holds a string that will be rendered as [the defs
|
|
|
|
section](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/defs) of the
|
|
|
|
SVG document.
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-10-01 23:12:26 +02:00
|
|
|
## Signature
|
2021-08-25 16:09:31 +02:00
|
|
|
|
|
|
|
```svg
|
|
|
|
<defs>
|
|
|
|
/* svg.defs will be inserted */
|
|
|
|
</defs>
|
|
|
|
```
|
2022-02-19 08:04:25 +01:00
|
|
|
|
2022-10-01 23:12:26 +02:00
|
|
|
## Notes
|
2021-08-25 16:09:31 +02:00
|
|
|
|
2022-10-01 23:12:26 +02:00
|
|
|
The defs attribute is where plugins will add additional snippets.
|
2022-02-19 08:04:25 +01:00
|
|
|
|
2021-08-25 16:09:31 +02:00
|
|
|
When adding your own defs, it's important not to
|
|
|
|
overwrite this property, but rather add your own.
|
|
|
|
|
|
|
|
In other words, do this:
|
|
|
|
|
|
|
|
```js
|
2022-10-01 23:12:26 +02:00
|
|
|
svg.defs += myDefs
|
2021-08-25 16:09:31 +02:00
|
|
|
```
|
2022-02-19 08:04:25 +01:00
|
|
|
|
2021-08-25 16:09:31 +02:00
|
|
|
and don't do this:
|
|
|
|
|
|
|
|
```js
|
2022-10-01 23:12:26 +02:00
|
|
|
svg.defs = myDefs
|
2021-08-25 16:09:31 +02:00
|
|
|
```
|