Skip to content

Icon

Renders an SVG graphic, either from a link or a set of built-in icons, that can represent an action, status, or decorative element. By default, it applies the fill-current class, allowing the icon to inherit the current text color.

Usage

Icons work best when paired with clear labels or context, and should not be the sole method of conveying information. They can be used as small interface symbols or full SVG illustrations, depending on the design needs.

API Reference

Component attribute(s)

x-h-icon

Attributes

AttributeTypeRequiredDescription
data-iconstringfalseName of a built-in icon to render (see the list below). Reactive, can be binded with :data-icon and the rendered icon updates whenever the value changes. Ignored when data-link is set.
data-linkurlfalseURL to the svg icon. Reactive, can be binded with :data-link and the icon is fetched again and replaced whenever the value changes.
roleimg
presentation
trueThe role of the icon. This is required as it affects the accessibility.
The presentation role excludes the icon from being visible to assistive technologies.
When using the img role, either aria-label or aria-labelledby attribute must also be provided. If not, assistive technologies will have trouble conveying to the user what the icon represents.

INFO

Icons do not have a size by default. When placed directly inside components, like button, menu and sidebar, they will automatically have their size set. However, if placed directly inside components like cards, info pages, etc. or <div> and <span> elements, then it's recommended to use a size class on them (size-4 being the default recommended one) as they will otherwise be randomly sized.

Built-in icons

Harmonia includes several built-in icons. Instead of using the data-link attribute, set data-icon to one of the names below to render it.

NameDescription
calendarCalendar icon
checkCheck icon
chevron-downChevron down icon
chevron-leftChevron left icon
chevron-rightChevron right icon
chevrons-leftChevrons left icon
chevrons-rightChevrons right icon
clockClock icon
searchSearch icon
eyeShow/Eye icon
eye-offHide/Eye off icon
ellipsisEllipsis icon
minusMinus icon
plusPlus icon
closeClose/Cancel icon
bellBell icon
trashDelete/Trash icon
mailMail icon
inboxInbox icon
sendSend icon
exportExport/Download icon
importImport/Upload icon
fileFile icon
linkLink icon
editEdit icon
menuMenu icon
replyReply icon
refreshRefresh icon
playPlay icon
pausePause icon
circle-infoInformation icon in a circle
circle-warningWarning icon in a circle
circle-errorError icon in a circle
circle-successSuccess icon in a circle
circle-unknownUnknown/Question mark icon in a circle
circle-userUser icon in a circle
homeHome icon
starFilled star icon
star-hollowHollow/outline star icon
star-halfHalf-filled star icon

Examples

SVG image

html
<svg x-h-icon data-link="/harmonia/logo/harmonia.svg" role="img" aria-label="Harmonia logo"></svg>

SVG icon

html
<svg x-h-icon class="size-8" data-link="/harmonia/logo/harmonia-symbolic.svg" role="presentation"></svg>

SVG icon with custom fill color

html
<svg x-h-icon class="size-8 fill-positive" data-link="/harmonia/logo/harmonia-symbolic.svg" role="presentation"></svg>
<svg x-h-icon class="size-8 fill-negative" data-link="/harmonia/logo/harmonia-symbolic.svg" role="presentation"></svg>
<svg x-h-icon class="size-8 fill-warning" data-link="/harmonia/logo/harmonia-symbolic.svg" role="presentation"></svg>
<svg x-h-icon class="size-8 fill-information" data-link="/harmonia/logo/harmonia-symbolic.svg" role="presentation"></svg>

Harmonia Icons

The icons below ship with Harmonia. Reference one by its name with data-icon, or click an icon in the preview to copy its markup.