Skip to main content
cngx-src documentation

CngxSkeletonContainer

ComponentPrimaryOnPushNo encapsulationv0.1.0WCAG AA

projects/ui/skeleton/skeleton-container.ts

Import#

import { CngxSkeletonContainer } from '@cngx/ui/skeleton'

Description#

Skeleton loading container with built-in placeholder repetition.

Manages CSS classes, ARIA, and reduced-motion handling internally (same behavior as the CngxSkeleton atom directive). Adds template projection so the consumer doesn't need @if/@for boilerplate.

  • Project a <ng-template cngxSkeletonPlaceholder> for the loading state (repeated count times).
  • Project content directly for the loaded state.
  • Uses display: contents - no extra DOM wrapper.

Basic usage

<cngx-skeleton [loading]="loading()" [count]="3">
  <ng-template cngxSkeletonPlaceholder>
    <div class="skeleton-card"></div>
  </ng-template>
  <app-real-content />
</cngx-skeleton>

With template context (index, first, last)

<cngx-skeleton [loading]="loading()" [count]="5">
  <ng-template cngxSkeletonPlaceholder let-i let-last="last">
    <div class="skeleton-line" [style.width]="last ? '60%' : '100%'"></div>
  </ng-template>
  <p>Loaded content here</p>
</cngx-skeleton>

https://cngxjs.github.io/cngx/examples/#/common/layout/skeleton/basic-skeleton https://cngxjs.github.io/cngx/examples/#/common/layout/skeleton/skeleton-container https://cngxjs.github.io/cngx/examples/#/ui/skeleton/card-skeleton https://cngxjs.github.io/cngx/examples/#/ui/skeleton/template-context

Metadata#

Host#

Relationships

Index#

Inputs#

count#number
input()

Repeat count for the placeholder template.

default 1
loading#boolean
input()

Controls the loading state directly.

default false
shimmer#boolean
input()

Enables the .cngx-skeleton--shimmer class (respects prefers-reduced-motion).

default true

Bind an async state - shows skeleton during first load. Takes precedence over loading.

HostBindings#

BindingExpression
[class.cngx-skeleton--loading]isLoading()
[class.cngx-skeleton--shimmer]showShimmer()
[attr.aria-busy]isLoading() || null

Default visuals for CngxSkeleton - shimmer placeholder bones. The host carries .cngx-skeleton and renders one or more .cngx-skeleton-bone children. The keyframe (cngx-skeleton-shimmer) stays top-level outside @layer because it is already namespaced and keyframes resolve by name regardless of cascade layer.

State modifiers

  • --shimmer - paints the bone with a 200% gradient sweep via cngx-skeleton-shimmer at --cngx-skeleton-shimmer-duration (default 1.5s). The animation no-ops under prefers-reduced-motion

Dark mode

Three hooks flip both the base and shimmer-sweep tones to gray-on-near-black so the sweep reads as a subtle gradient rather than a bright streak. Component-local - bones are placeholder surfaces, not delegated:

  • prefers-color-scheme: dark
  • [data-color-scheme="dark"]
  • .dark class

Pair with

  • @cngx/themes/material/skeleton-theme - Material 3 surface treatment

Index#

Surface

--cngx-skeleton-bg#<color>
Default value oklch(0.88 0 0)

Base color of the shimmer gradient.

--cngx-skeleton-shimmer-color#<color>
Default value oklch(0.96 0 0)

Highlight color that sweeps across the bone during the shimmer animation.

Layout

--cngx-skeleton-radius#<length>
Default value 4px

Corner radius of the bone.

Motion

--cngx-skeleton-shimmer-duration#<time>
Default value 1.5s

Duration of one shimmer sweep.