Skip to main content
cngx-src documentation

CngxCardMedia

Directivev0.1.0WCAG AA

projects/common/card/card-media.directive.ts

Import#

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

Description#

Structural slot directive for the card media region (images, videos, icons).

When decorative is true (default), the media is hidden from screen readers via aria-hidden. Set to false when the image carries meaningful information.

<cngx-card>
  <img cngxCardMedia [decorative]="false" alt="Photo of patient" />
</cngx-card>

https://cngxjs.github.io/cngx/examples/#/common/card/card-with-image

Metadata#

Host#

Index#

Inputs#

aspectRatio#'16/9' | '4/3' | '1/1' | 'auto'
input()

Aspect ratio applied via CSS aspect-ratio property.

default 'auto'
decorative#boolean
input()

Whether this media is purely decorative (hidden from SR).

default true

HostBindings#

BindingExpression
[style.aspect-ratio]aspectRatio() !== "auto" ? aspectRatio() : null
[attr.aria-hidden]decorative() || null
[attr.loading]"lazy"