Icon

Icons are symbols that can be used to represent various options within an application. Icon component allows you to display an icon from the OLYSENSE Icon library.

Visit the OLYSENSE Icons docs to see view all icons we have avaiable. In addition, you will instructions on how to install and configure a custom path to your icons if that is required.

Icons inherit their color from the current text color. Thus, you can set the color property on the <ods-icon> element or an ancestor to change the color.

Icons are sized relative to the current font size or independently.

For non-decorative icons, use the label attribute to announce it to assistive devices.

Custom icons can be loaded individually with the src attribute. Only SVGs on a local or CORS-enabled endpoint are supported. If you’re using more than one custom icon, it might make sense to register a custom icon library.

import '@ods/components/web.icon';

Note: You only need to import a web component once in your code, as it registers itself globally when defined, allowing you to use it anywhere within your application without needing to re-import it each time you want to use the component.

Properties

Please note, both DOM properties and HTML attributes are shown in the table below. Unless otherwise specified, the property and attribute names are identical.

Property/AttributeReflectsTypeDefault
name
string | undefined
src
string | undefined
label
string''
library
string'default'

Events

React EventDescriptionEvent Detail
ods-loadEmitted when the icon has loaded. When using `spriteSheet: true` this will not emit.--
ods-errorEmitted when the icon fails to load due to an error. When using `spriteSheet: true` this will not emit.--

Parts

NameDescription
svgThe internal SVG element.
useThe <use> element generated when using `spriteSheet: true`

Search