Core Concepts
The element
<ml-sigil-icon> attributes and styling.
<ml-sigil-icon name="heart"></ml-sigil-icon>
<ml-sigil-icon name="heart" library="fa"></ml-sigil-icon>
<ml-sigil-icon name="heart" variant="active"></ml-sigil-icon>
| Attribute / property | Description |
|---|---|
name | Icon name |
library | Ask this library instead of the default |
variant | State, e.g. active |
All three are reflected properties too: el.variant = 'active'.
Loading…
What renders
Light DOM, so your CSS applies and icon fonts work:
<ml-sigil-icon name="heart"
><span class="icon-svg" aria-hidden="true"><svg … /></span
></ml-sigil-icon>
<ml-sigil-icon name="heart" library="fa"><i class="fa fa-heart" aria-hidden="true"></i></ml-sigil-icon>
Styling
ml-sigil-icon {
display: inline-flex;
width: 1em;
height: 1em;
vertical-align: -0.125em;
}
ml-sigil-icon svg {
width: 100%;
height: 100%;
}
ml-sigil-icon:empty {
background: currentColor;
opacity: 0.1;
} /* optional loading box */
Colour comes from the SVG. Use a mutator to force fill="currentColor" once at resolve time.
Accessibility
Icons are aria-hidden. Label the control, not the icon: <button aria-label="Save"><ml-sigil-icon name="bookmark"></ml-sigil-icon></button>.