Skip to main content
cngx-src documentation

CngxIcon

cngx-icon

ComponentPrimaryOnPushNo encapsulationv0.1.0WCAG AA

projects/common/display/icon/icon.component.ts

Import#

import { CngxIcon } from '@cngx/common/display'

Description#

Metadata#

Host#

Relationships

Index#

Inputs#

label#string | undefined
input()

Accessible label. When set, the icon is treated as informative content.

size#"xs" | "sm" | "md" | "lg" | "xl"
input()

Size preset. Maps to CSS custom properties on the host.

default 'md'

HostBindings#

BindingExpression
[attr.role]label() ? "img" : null
[attr.aria-label]label() ?? null
[attr.aria-hidden]label() ? null : "true"
[class.cngx-icon--xs]size() === "xs"
[class.cngx-icon--sm]size() === "sm"
[class.cngx-icon--md]size() === "md"
[class.cngx-icon--lg]size() === "lg"
[class.cngx-icon--xl]size() === "xl"

Default visuals for CngxIcon. The host carries .cngx-icon and sizes itself in em so an icon next to running text matches the surrounding font scale automatically. Color follows currentColor, so the glyph inherits the container's text color without any per-instance override.

Size variants

Each size pins --cngx-icon-size. Consumers can swap a variant value globally (override --cngx-icon-size-xs) or pin a specific instance via inline --cngx-icon-size:

  • --xs - 0.75em
  • --sm - 1em
  • --md - 1.25em (default)
  • --lg - 1.5em
  • --xl - 2em

Slots

  • :scope > svg - projected SVG fills the host box, fill: currentColor so brand color flows through

Inheritance

Leaf tokens - the active size and color are component-local. --cngx-icon-color defaults to currentColor so no fallback chain is needed for the color cascade.

Index#

Layout

--cngx-icon-size#*
Default value 1.25em

Active size of the icon - consumed by the :scope rule. Driven by the size-variant classes or set inline for one-off overrides.

Surface

--cngx-icon-color#*
Default value currentColor

Text color of the icon glyph. Defaults to currentColor so the icon inherits its container's text color.

Variant / Size

--cngx-icon-size-xs#*
Default value 0.75em

Size token for the .cngx-icon--xs variant.

--cngx-icon-size-sm#*
Default value 1em

Size token for the .cngx-icon--sm variant.

--cngx-icon-size-md#*
Default value 1.25em

Size token for the .cngx-icon--md variant (default).

--cngx-icon-size-lg#*
Default value 1.5em

Size token for the .cngx-icon--lg variant.

--cngx-icon-size-xl#*
Default value 2em

Size token for the .cngx-icon--xl variant.