API REFERENCE · DATA DISPLAY
<dj-icon>
A presentational icon.
Supply a glyph in one of two ways: set type to the name of an icon registered with registerIcon or registerIcons, or slot an inline <svg>.
npm install @dojo-ng/icon
import "@dojo-ng/icon";
Accessibility
- Set
alt-textwhen the icon carries meaning. It becomes the accessible name. - Without
alt-text, the icon is hidden from assistive technology (aria-hidden).
SVG requirements
- A registered SVG must have a
viewBox. dj-icon sizes a glyph by stretching it to fill the icon box, and an<svg>scales its artwork only when it has aviewBox. - An SVG without a
viewBoxgets a box of the right size, but its artwork is clipped or not scaled.registerIconandregisterIconslog one console warning for each such icon, and they do not change the SVG. - dj-icon's own sizing overrides any
widthorheightattributes on a registered SVG. - A slotted inline
<svg>follows the same rules.
Properties
| Property | Attribute | Type | Default |
|---|---|---|---|
typeRegistered icon name; resolved to an inline SVG from the icon registry. |
type |
string |
"" |
sizeSize modifier. |
size reflected |
"small""medium""large" |
None |
altTextVisually-hidden label; when set, the icon is exposed to assistive tech. |
alt-text |
string |
None |
Slots
Default slot
CSS parts
Style these with dj-icon::part(name).
base
CSS custom properties
| Property | Default | Description |
|---|---|---|
--dj-icon-color | currentColor | Icon color. |