UNPKG

@vaadin/icon

Version:

Web component for creating SVG icons

59 lines (55 loc) 1.76 kB
/** * @license * Copyright (c) 2021 - 2025 Vaadin Ltd. * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ */ import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js'; import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js'; import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js'; import { IconMixin } from './vaadin-icon-mixin.js'; /** * `<vaadin-icon>` is a Web Component for displaying SVG icons. * * ### Icon property * * The `<vaadin-icon>` component is designed to be used as a drop-in replacement for `<iron-icon>`. * For example, you can use it with `vaadin-icons` like this: * * ```html * <vaadin-icon icon="vaadin:angle-down"></vaadin-icon> * ``` * * Alternatively, you can also pick one of the Lumo icons: * * ```html * <vaadin-icon icon="lumo:user"></vaadin-icon> * ``` * * ### Custom SVG icon * * Alternatively, instead of selecting an icon from an iconset by name, you can pass any custom `svg` * literal using the [`svg`](#/elements/vaadin-icon#property-svg) property. In this case you can also * define the size of the SVG `viewBox` using the [`size`](#/elements/vaadin-icon#property-size) property: * * ```js * import { html, svg } from 'lit'; * * // in your component * render() { * const svgIcon = svg`<path d="M13 4v2l-5 5-5-5v-2l5 5z"></path>`; * return html` * <vaadin-icon * .svg="${svgIcon}" * size="16" * ></vaadin-icon> * `; * } * ``` */ declare class Icon extends ThemableMixin(ElementMixin(ControllerMixin(IconMixin(HTMLElement)))) {} declare global { interface HTMLElementTagNameMap { 'vaadin-icon': Icon; } } export { Icon };