svg-builder icon indicating copy to clipboard operation
svg-builder copied to clipboard

Is it possible to add style element?

Open elliotsoomro opened this issue 3 years ago • 2 comments

Is there any way to add a style element to the svg?

Like this

<style type="text/css">
.st0{fill:#020203;}
.st1{fill:#F1F2F2;}
.st2{fill:#FFFFFF;}
</style>

Thanks for a great simple library!

elliotsoomro avatar Dec 17 '21 14:12 elliotsoomro

Hi @elliotsoomro I think that should be possible

JoeChapman avatar Mar 09 '22 11:03 JoeChapman

Using version 2.0.0 and the syntax;

svg.style(
  {},
  `
    text {
      background: #000000AA;
      border-radius: 5px;
      padding: 5px;
    }
  `
);

I receive the following error:

Error: Content cannot be a string.
    at constructor.checkContent (C:\Projects\***REDACTED***\node_modules\svg-builder\elements\element.js:58:27)
    at constructor (C:\Projects\***REDACTED***\node_modules\svg-builder\elements\element.js:20:18)
    at new constructor (C:\Projects\***REDACTED***\node_modules\svg-builder\elements\style.js:27:29)
    at SvgBuilder.line [as style] (C:\Projects\***REDACTED***\node_modules\svg-builder\index.js:112:21)

It doesn't seem possible currently.

mrfigg avatar Mar 08 '23 06:03 mrfigg