UNPKG

@vaadin/icon

Version:

Web component for creating SVG icons

111 lines 6.36 kB
{ "$schema": "https://json.schemastore.org/web-types", "name": "@vaadin/icon", "version": "25.1.3", "description-markup": "markdown", "framework": "lit", "framework-config": { "enable-when": { "node-packages": [ "lit" ] } }, "contributions": { "html": { "elements": [ { "name": "vaadin-iconset", "description": "`<vaadin-iconset>` is a Web Component for creating SVG icon collections.", "extension": true, "attributes": [ { "name": ".name", "description": "The name of the iconset. Every iconset is required to have its own unique name.\nAll the SVG icons in the iconset must have IDs conforming to its name.\n\nSee also [`name`](https://cdn.vaadin.com/vaadin-web-components/25.1.3/#/elements/vaadin-icon#property-name) property of `vaadin-icon`.", "value": { "kind": "expression" } }, { "name": ".size", "description": "The size of an individual icon. Note that icons must be square.\n\nWhen using `vaadin-icon`, the size of the iconset will take precedence\nover the size defined by the user to ensure correct appearance.", "value": { "kind": "expression" } } ] }, { "name": "vaadin-icon", "description": "`<vaadin-icon>` is a Web Component for displaying SVG icons.\n\n### Icon property\n\nThe `<vaadin-icon>` component is designed to be used as a drop-in replacement for `<iron-icon>`.\nFor example, you can use it with `vaadin-icons` like this:\n\n```html\n<vaadin-icon icon=\"vaadin:angle-down\"></vaadin-icon>\n```\n\nAlternatively, you can also pick one of the Lumo icons:\n\n```html\n<vaadin-icon icon=\"lumo:user\"></vaadin-icon>\n```\n\n### Custom SVG icon\n\nAlternatively, instead of selecting an icon from an iconset by name, you can pass any custom `svg`\nliteral using the [`svg`](https://cdn.vaadin.com/vaadin-web-components/25.1.3/#/elements/vaadin-icon#property-svg) property. In this case you can also\ndefine the size of the SVG `viewBox` using the [`size`](https://cdn.vaadin.com/vaadin-web-components/25.1.3/#/elements/vaadin-icon#property-size) property:\n\n```js\nimport { html, svg } from 'lit';\n\n// in your component\nrender() {\n const svgIcon = svg`<path d=\"M13 4v2l-5 5-5-5v-2l5 5z\"></path>`;\n return html`\n <vaadin-icon\n .svg=\"${svgIcon}\"\n size=\"16\"\n ></vaadin-icon>\n `;\n}\n```\n\n### Styling\n\nThe following custom CSS properties are available for styling:\n\nCustom CSS property | Description\n-----------------------------|-------------\n`--vaadin-icon-size` | Size (width and height) of the icon\n`--vaadin-icon-stroke-width` | Stroke width of the SVG icon\n`--vaadin-icon-visual-size` | Visual size of the icon\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n---------------|-------------\n`has-tooltip` | Set when the icon has a slotted tooltip\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.", "extension": true, "attributes": [ { "name": ".char", "description": "A hexadecimal code point that specifies a glyph from an icon font.\n\nExample: \"e001\"", "value": { "kind": "expression" } }, { "name": ".fontFamily", "description": "The font family to use for the font icon.", "value": { "kind": "expression" } }, { "name": ".icon", "description": "The name of the icon to use. The name should be of the form:\n`iconset_name:icon_name`. When using `vaadin-icons` it is possible\nto omit the first part and only use `icon_name` as a value.\n\nSetting the `icon` property updates the `svg` and `size` based on the\nvalues provided by the corresponding `vaadin-iconset` element.\n\nSee also [`name`](https://cdn.vaadin.com/vaadin-web-components/25.1.3/#/elements/vaadin-iconset#property-name) property of `vaadin-iconset`.", "value": { "kind": "expression" } }, { "name": ".iconClass", "description": "Class names defining an icon font and/or a specific glyph inside an icon font.\n\nExample: \"fa-solid fa-user\"", "value": { "kind": "expression" } }, { "name": ".ligature", "description": "A ligature name that specifies an icon from an icon font with support for ligatures.\n\nExample: \"home\".", "value": { "kind": "expression" } }, { "name": ".size", "description": "The size of an icon, used to set the `viewBox` attribute.", "value": { "kind": "expression" } }, { "name": ".src", "description": "The SVG source to be loaded as the icon. It can be:\n- an URL to a file containing the icon\n- an URL in the format `/path/to/file.svg#objectID`, where the `objectID` refers to an ID attribute contained\n inside the SVG referenced by the path. Note that the file needs to follow the same-origin policy.\n- a string in the format `data:image/svg+xml,<svg>...</svg>`. You may need to use the `encodeURIComponent`\n function for the SVG content passed", "value": { "kind": "expression" } }, { "name": ".svg", "description": "The SVG icon wrapped in a Lit template literal.", "value": { "kind": "expression" } }, { "name": ".symbol", "description": "The symbol identifier that references an ID of an element contained in the SVG element assigned to the\n`src` property", "value": { "kind": "expression" } } ] } ] } } }