The "source" path is relative to the resources folder.
{{ partial "inline-svg" "icons/bootstrap/envelope" }}To use the optional argument you must pass a dict as the partials context.
{{ partial "inline-svg" (dict "src" "icons/bootstrap/envelope" "fs" 2 "block" true "title" "Icon Title" "desc" "Icon Desc")}}src points to the SVG file relative to the assets folder. The .svg suffix is optional.
display can be set to the following:
inlinetodisplay:inline-blockand match the height of text (scale of 0.7em).blocktodisplay:blockand have a scale of 1em. (default)
By default the SVG's are set to font-size: inherit; which allows the svg to take on the font-size of its parent. Aternatively you can override this behaviour with EITHER following options:
-
fscan be set to 1-7. These sizes mirror bootstrap's font sizes with the addition of 7 which is 0.875 (.small or <small>) -
remcan be set to 1-5 which will set thefont-sizeto 1-5rem. More granular control is available withfs.
title adds a title tag which browsers pick up and display on hover. It also adds aria-labelledby to the SVG. (for assistive technology). The title is useful for desktop users, but does not add functionality for mobile users. (who aren't using assistive technology/screen readers)
description adds a description tag and adds aria-describedby to the SVG. (for assistive technology)
{{< inline-svg src="icons/bootstrap/envelope" block=true title="Icon Title" desc="Icon Desc" >}}
You need to wrap your partial or shortcode in a div or span and add CSS classes to change the size and color.
An example utilizing bootstrap 5's utility classes is as follows:
<span class="fs-2 text-primary">{{ partial "inline-svg" "icons/bootstrap/envelope" }}</span>fs-2 changes the font size for the svg and text-primary changes the line color to primary (blue by default).
# config.yaml
module:
imports:
- path: github.com/future-wd/hugo-inline-svgYou need to import required css from `/assets/scss/inline-svg.scss'
// /assets/scss/index.scss ! if your file is not located here, you must adjust your import path !
@import "inline-svg.scss";