Skip to main content
cngx-src documentation

CngxCheckboxIndicator

ComponentPrimaryOnPushNo encapsulationv0.1.0WCAG AA

projects/common/display/checkbox-indicator/checkbox-indicator.component.ts

Import#

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

Description#

Presentational checkbox / checkmark indicator.

Why this exists. Across the library, "is this row selected?" shows up as a bare <span class="cngx-select__check">&#10003;</span> in the forms/select panel, a future grid/tree cell will want a checkbox with indeterminate state, and ng decompose cngx-* schematics should emit a consistent indicator shape regardless of which list-like component they originated from. This atom unifies all three surfaces behind a single presentational molecule - purely decorative (aria-hidden="true"), zero outputs, two variants, full --cngx-checkbox-* theming.

Responsibilities (intentionally narrow).

  • Render a boxed checkbox or a bare checkmark glyph (variant).
  • Express checked / indeterminate / disabled visual state via host classes the consumer (or upstream CSS) can theme.
  • Apply size presets (sm / md / lg) as CSS-custom-property modifiers.

Non-responsibilities.

  • Selection state - controlled entirely by the parent via checked / indeterminate inputs.
  • Interaction - no click output, no keyboard handling. The parent (option row, tree cell, grid row) owns the hit area and toggle semantics.
  • Accessibility announcements - aria-hidden="true" unconditionally. The truth about "selected" is communicated by the row's own aria-selected / role="option" ARIA, not by this decoration.

https://cngxjs.github.io/cngx/examples/#/common/display/checkbox-indicator/states https://cngxjs.github.io/cngx/examples/#/common/display/checkbox-indicator/variant-matrix https://cngxjs.github.io/cngx/examples/#/common/display/checkbox-indicator/sizes https://cngxjs.github.io/cngx/examples/#/common/display/checkbox-indicator/custom-glyph

Metadata#

Host#

Relationships

Index#

Inputs#

checked#boolean
input()

Whether the current value is selected.

default false
checkGlyph#TemplateRef | null

Consumer-supplied template for the check glyph. When null (default), the built-in <span class="cngx-checkbox-indicator__check">&#10003;</span> is rendered. When set, the consumer template replaces the glyph span entirely - the __check class is NOT applied to the custom content (consumers own the styling of their replacement).

Convention-compatible with *cngxSelectCheck / *cngxSelectOptionLabel: pass a TemplateRef<void> obtained via #myGlyphTpl. Useful for CngxTreeCheckboxHeader or other consumers that need a custom glyph without forking the atom.

default null
dashGlyph#TemplateRef | null

Consumer-supplied template for the indeterminate dash glyph. Mirrors checkGlyph - defaults to the built-in <span class="cngx-checkbox-indicator__dash">&minus;</span>.

default null
disabled#boolean
input()

Disabled visual state. Purely cosmetic (opacity dim) - the indicator never intercepts events, so this is a hint, not a block.

default false
indeterminate#boolean
input()

Partial-selection state. Takes precedence over checked - when both are true, the dash glyph is rendered. Intended for tree / group rows where some-but-not-all descendants are selected.

default false
size#"sm" | "md" | "lg"
input()

Size preset. Maps to a --cngx-checkbox-size custom property.

default 'md'
variant#"checkbox" | "checkmark"
input()

Visual form. 'checkbox' renders a bordered box containing the glyph; 'checkmark' renders the bare glyph only (no box). Consumers pick the mode-appropriate form themselves - @cngx/forms/select resolves it from its selectionIndicatorVariant config.

default 'checkbox'

HostBindings#

BindingExpression
[class.cngx-checkbox-indicator--checkbox]variant() === 'checkbox'
[class.cngx-checkbox-indicator--checkmark]variant() === 'checkmark'
[class.cngx-checkbox-indicator--checked]checked()
[class.cngx-checkbox-indicator--indeterminate]indeterminate()
[class.cngx-checkbox-indicator--disabled]disabled()
[class.cngx-checkbox-indicator--sm]size() === 'sm'
[class.cngx-checkbox-indicator--md]size() === 'md'
[class.cngx-checkbox-indicator--lg]size() === 'lg'

Default visuals for CngxCheckboxIndicator. The host carries .cngx-checkbox-indicator and reserves a constant box even when the inner glyph is not rendered (the checkmark variant has empty content while unchecked), so adjacent labels stay put across state toggles. The inner __box is a child of the host - several tokens carry inherits: true so size-variant overrides on the host cascade through.

State modifiers

  • --checked - box fills with the checked-bg, glyph paints in the checked-color
  • --indeterminate - same surface as checked, dash glyph
  • --disabled - opacity dim via --cngx-checkbox-disabled-opacity

Variants

  • --checkmark - bare glyph, no box; the checked color is honored on the inner __check / __dash directly

Size variants

Each size pins --cngx-checkbox-size:

  • --sm - 0.875em
  • --md - 1em (default)
  • --lg - 1.25em

Slots

  • .cngx-checkbox-indicator__box - the bordered square
  • .cngx-checkbox-indicator__check - checkmark glyph
  • .cngx-checkbox-indicator__dash - indeterminate-state glyph

Inheritance

  • --cngx-checkbox-checked-bg -> --cngx-color-primary (also pinned via :root delegation so dark-mode primary cascades without the @property initial-value shadowing the chain)
  • --cngx-checkbox-radius -> --cngx-radius-sm
  • --cngx-checkbox-color -> --cngx-color-primary (checkmark variant only)
  • --cngx-checkbox-bg, --cngx-checkbox-border, --cngx-checkbox-checked-color - leaf tokens

Index#

Layout

--cngx-checkbox-size#*
Default value 1em

Active size of the indicator box. inherits: true is load-bearing - the inner __box is a child of the host, and the size-variant classes (--sm / --md / --lg) set this token on the host. With inherits: false the child would only see the registered initial value and the size variants would render with a constant-sized box inside a variable-sized host frame.

--cngx-checkbox-radius#<length>
Default value 2px

Corner radius of the box. Defaults to --cngx-radius-sm. Inherited so a host-level override reaches the __box child that consumes it.

Surface

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

Text color of the inner glyph in the bare checkmark variant. Defaults to currentColor.

--cngx-checkbox-bg#*
Default value transparent

Background of the unchecked box. Inherited so a host-level override reaches the __box child that consumes it.

--cngx-checkbox-border#*
Default value 1.5px solid currentColor

Border shorthand of the unchecked box. Width + style + color in one declaration so a consumer can re-skin the stroke with a single override. Inherited so a host-level override reaches the __box child that consumes it.

State / Checked

--cngx-checkbox-checked-bg#<color>
Default value oklch(0.66 0.19 50)

Background of the box when checked or indeterminate. Falls back to --cngx-color-primary.

See: [[--cngx-color-primary]]

--cngx-checkbox-checked-color#<color>
Default value oklch(1 0 0)

Glyph color inside the checked/indeterminate box.

State / Disabled

--cngx-checkbox-disabled-opacity#<number>
Default value 0.5

Opacity multiplier applied by .cngx-checkbox-indicator--disabled.

Variant / Size

--cngx-checkbox-size-sm#*
Default value 0.875em

Size token for the .cngx-checkbox-indicator--sm variant.

--cngx-checkbox-size-md#*
Default value 1em

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

--cngx-checkbox-size-lg#*
Default value 1.25em

Size token for the .cngx-checkbox-indicator--lg variant.