Card

A surface that groups related content.

Installation

Import the class, and @use the entry point in your global styles: without it the component renders unstyled.

import { Component } from '@angular/core';
import { WrCard, WrCardFooter, WrCardHeader } from 'ngwr/card';

@Component({ imports: [WrCard, WrCardFooter, WrCardHeader] })
export class MyComponent {}

Basic usage

<wr-card-header> and <wr-card-footer> are optional.

Settings

Manage account preferences and notification rules.

<wr-card>
  <wr-card-header>
    <h3>Settings</h3>
  </wr-card-header>
  <p>Body content.</p>
  <wr-card-footer>
    <button wr-btn type="button" color="primary">Save</button>
  </wr-card-footer>
</wr-card>

Without header / footer

Just a surface around content.

<wr-card>
  <p>Just a surface around content.</p>
</wr-card>

Variants

hoverable for clickable cards, compact for tight layouts, loading covers the body with a spinner.

Hoverable

No border

Compact

Loading overlay

<wr-card hoverable>Click me</wr-card>

<wr-card [bordered]="false">No border</wr-card>

<wr-card compact>Tighter paddings</wr-card>

<wr-card [loading]="reloading()">
  <p>Spinner overlay while data loads.</p>
</wr-card>

API

NameDescriptionTypeDefault
bordered1px border around the surface.booleantrue
hoverableLift and shadow on hover, pointer cursor.booleanfalse
loadingSpinner over a dimmed body. Sets aria-busy.booleanfalse
compactHalf the padding.booleanfalse
<wr-card-header>Header slot (.wr-card__header).component—
<wr-card-footer>Footer slot (.wr-card__footer).component—

CSS variables

Set these on the component's selector or a wrapper, not on :root: the defaults are declared on ngwr/card's own element.

VariableDefaultDeclared on
--wr-card-bgvar(--wr-color-surface).wr-card
--wr-card-bordervar(--wr-border-base).wr-card
--wr-card-colorvar(--wr-color-on-surface).wr-card
--wr-card-font-familyvar(--wr-font-family-base).wr-card
--wr-card-gapvar(--wr-space-sm).wr-card
--wr-card-header-font-weightvar(--wr-font-weight-medium).wr-card
--wr-card-padding-xvar(--wr-space-xl).wr-card +1 variant override
--wr-card-padding-yvar(--wr-space-lg).wr-card +1 variant override
--wr-card-radiusvar(--wr-border-radius-base).wr-card
--wr-card-shadowvar(--wr-shadow-xs).wr-card
--wr-card-shadow-hovervar(--wr-shadow-overlay).wr-card

See also