SVG icons #113
Replies: 2 comments 4 replies
-
@janilcgarcia Hi! I'm doing something like this normally for svg: And using this to get the scala code out of svg(html): (just noticed that Laminar is now explicitly supported :); before that, scalatags option worked fine as well, except some minor issues with more complicated cases) |
Beta Was this translation helpful? Give feedback.
-
People have been asking for this a few times already, I think I'll implement some kind of helper to do this in one step. If you don't want to use html-to-scala-converter, the process is two steps:
Or val mySvgElement = new ChildNode[HTMLElement] {
val ref: dom.svg.Element = yourJsSvgElement
}
div(..., mySvgElement) |
Beta Was this translation helpful? Give feedback.
-
Has anyone tried using pre-made SVG icons directly in laminar? Like bootstrap icons or font-awesome? What are you doing?
I ended up doing something like this first:
But now moving back to using CSS classes + icon font, because transforming SVG code into Scala DOM Types code for every icon I want to use is particularly not intuitive.
Quite honestly I would love to have something like this:
https://fontawesome.com/v5.15/how-to-use/on-the-web/using-with/react#using
But I don't know how that works in React and I have no idea how to implement that in Laminar. Honestly, It would be enough to have a way I could just paste the SVG string in my code and transform it an icon, so I could just store the icons in an object like this:
How could I implement
stringToReactiveElement
up there? It doesn't even need to be a ReactiveElement, it'd be happy with anything I could just pass as modifier to other elements.Beta Was this translation helpful? Give feedback.
All reactions