Jhana UI uses a unified, customizable and variable icon syntax, that all components understand. There are four
ways to define an SVGIcon. Allowing for more and more features. Depending on how complex your requirements are.
No matter which option, you will never specify the SVG tag. Instead, all of thsese will require you to define
the SVGViewBox.
Reactivity
For hover, active and focus-visible states to work properly, you need to define the 'icon-root' class on the
parent element.
Filled Icons
You specify the SVG path ('d' Attribute). Which will be filled with the correct color, depending on the context.
Since SVG paths can contain multiple subpaths, any mono-color filled icon can be defined like this.
Stroked Icons
You specify the SVG path ('d' Attribute). Which will be stroked with the correct color, depending on the
context. You can optionally set the stroke-width. Since SVG paths can contain multiple subpaths, any mono-color
single-stroke-width icon can be defined like this.
Custom SVG Icons
In case you need to use different opacities for different icon elements, or you want to use SVG shapes like
circle, or some other advanced stuff, you are free to use this syntax. You have access to many CSS variables, so
you can use any custom logic, while still being variable and unaware of the context. You must not include the
SVG tag itself here, only its contents.
Custom Snippet Icons
If you require the features from the 'SVG Icon' syntax, but want to integrate Svelte reactivity or you simply
prefer having syntax highlighting, type checking and autocomplete, you might want to use Svelte snippets. In
addition to having access to the same CSS variables, you can also use the snippet's props and do JS calculations
or Svelte conditionals with them. The downside here, is that you will have to define the icon inside a Svelte
component.