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.
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.
This component is still in development and cannot be imported at this time.
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/Attribute | Reflects | Type | Default |
|---|---|---|---|
name | string | undefined | ||
src | string | undefined | ||
label | string | '' | |
library | string | 'default' |
| React Event | Description | Event Detail |
|---|---|---|
| ods-load | Emitted when the icon has loaded. When using `spriteSheet: true` this will not emit. | -- |
| ods-error | Emitted when the icon fails to load due to an error. When using `spriteSheet: true` this will not emit. | -- |
| Name | Description |
|---|---|
| svg | The internal SVG element. |
| use | The <use> element generated when using `spriteSheet: true` |