Icon
Displays SVG icons with unified styling and accessibility support.
The icon component allows you to inject inline SVGs efficiently. It automatically cleans up the SVG source to ensure Tailwind classes take precedence, handles accessibility attributes, and visual warning for missing files.
Go/HTML template
Reference
The icon partial accepts a dictionary with the following terms:
- name
"name" "pizza"— (string, required)- The filename of the svg icon inside
assets/icons/ - (excluding the
.svgextension). - class
"class" "size-7 text-red-400"— (string, optional)- Tailwind/CSS classes to override the global defaults.
- These are appended to the base
.ks-iconclass. - ariaHidden
"ariaHidden" "false"— (string, optional)- Whether to hide the icon from screen readers.
- If the icon provides semantic meaning, set to
"false". - Default:
"true". - role
"role" "presentation"— (string, optional)- Defines the semantic role of the SVG.
- Default:
"img". - focusable
"focusable" "true"— (string, optional)- Defines if the SVG can receive focus
- Default:
"false". - attributes
"attributes" `id="logo"`— (string, optional)- Any custom HTML attributes to inject directly into the
<svg> - (e.g. IDs or data attributes).
Usage
- Place your
.svgfiles inside theassets/icons/directory. - Define your global base styles in the file
assets/css/components/_icon.css
Tailwind CSS
assets/css/components/_icon.css
Tips & tricks
You can use the icon partial inside Markdown by creating a wrapper shortcode.
Go/HTML template
/layouts/_shortcodes/icon.html
and use it in your content:
Markdown
Manual Installation
Create the partial:
Go/HTML template
layouts/_partials/ui/icon.html
Add into your Tailwind/CSS file add:
Tailwind CSS