Back to Tuist

Icon

noora/docs/components/icon.md

4.204.02.1 KB
Original Source
<!-- Generated by scripts/generate-web-components.js. Do not edit directly. -->

Icon

Renders an icon from Noora's shared icon catalog.

html
<noora-icon name="settings" label="Settings"></noora-icon>

Attributes

AttributeType or allowed valuesDefaultDescription
namestring""Selects the icon by its underscore or hyphen-separated name.
labelstringNoneProvides an accessible label. Omit for decorative icons.
sizenumber24Sets the width and height in pixels.
active-namestringNoneSelects the icon shown while the parent element has an open data state.
transitionmorph, crossfade_rotate, auto"auto"Controls the animated transition between the default and active icons.

Styling parts

PartDescription
iconThe rendered scalable vector graphic.

Unknown icon names render no graphic.

When active-name is set, the icon observes its parent element's data-state attribute and switches when that state is open.

Animated transitions

Click each button to toggle its state and transition between paired icons.

html
<button data-state="closed" onclick="this.dataset.state = this.dataset.state === 'open' ? 'closed' : 'open'" aria-label="Toggle selector"><noora-icon name="selector" active-name="selector_2" transition="morph"></noora-icon></button>
<button data-state="closed" onclick="this.dataset.state = this.dataset.state === 'open' ? 'closed' : 'open'" aria-label="Toggle menu"><noora-icon name="menu" active-name="close" transition="crossfade_rotate"></noora-icon></button>
<button data-state="closed" onclick="this.dataset.state = this.dataset.state === 'open' ? 'closed' : 'open'" aria-label="Toggle theme"><noora-icon name="sun_high" active-name="moon" transition="crossfade_rotate"></noora-icon></button>
<button data-state="closed" onclick="this.dataset.state = this.dataset.state === 'open' ? 'closed' : 'open'" aria-label="Toggle playback"><noora-icon name="player_play" active-name="player_pause" transition="auto"></noora-icon></button>