Skip to main content
cngx-src documentation

CngxCardSkeleton

ComponentOnPushNo encapsulationv0.1.0WCAG AA

projects/common/card/card-skeleton.component.ts

Import#

import { CngxCardSkeleton } from '@cngx/common/card'

Description#

Skeleton placeholder for card content during loading.

Renders shimmer rectangles that match typical card layout patterns. Use alongside @if (loading()) to swap real content with the skeleton.

<cngx-card [loading]="loading()">
  @if (loading()) {
    <cngx-card-skeleton [lines]="3" [showMedia]="true" />
  } @else {
    <header cngxCardHeader>...</header>
    <div cngxCardBody>...</div>
  }
</cngx-card>

https://cngxjs.github.io/cngx/examples/#/common/card/loading-state

Metadata#

Host#

Index#

Inputs#

lines#number
input()

Number of body text lines to show.

default 3
showMedia#boolean
input()

Whether to show a media placeholder block.

default false

Default visuals for CngxCardSkeleton. The host carries .cngx-card-skeleton and stacks three placeholder bars vertically. All three share the same shimmer gradient so the placeholder reads as a single moving element rather than three separate animations.

Slots

  • .cngx-card-skeleton__media - hero image placeholder block
  • .cngx-card-skeleton__title - title bar (55% width)
  • .cngx-card-skeleton__line - body text-line bar (repeats)

Reduced motion

Under prefers-reduced-motion: reduce the animated gradient is dropped and all three bars fall back to a flat opacity: 0.7 dim.

Inheritance

Leaf tokens with no fallback chain - geometry and shimmer colors are component-local. The dark-mode swap rewrites the two surface tokens at :root.

Dark mode

Three hooks lift the shimmer band one step above the dark surface so the moving stripe stays visible against a dark page:

  • prefers-color-scheme: dark
  • [data-color-scheme="dark"]
  • [data-color-scheme="light"] (explicit light pin)

Both surface tokens carry inherits: true so the :root swap reaches the gradient fill on each slot.

Index#

Layout

--cngx-skeleton-gap#<length>
Default value 10px

Vertical gap between the skeleton's child blocks.

--cngx-skeleton-media-height#<length>
Default value 120px

Height of the media placeholder block.

--cngx-skeleton-title-height#*
Default value 1.25rem

Height of the title placeholder bar.

--cngx-skeleton-line-height#*
Default value 0.875rem

Height of each text-line placeholder bar.

Surface

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

Base color of the shimmer gradient.

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

Highlight color of the shimmer gradient.