Dojo NG is being built in the open, one section at a time — follow along on Heptapod.

API REFERENCE · LAYOUT

<dj-card>

Content container. Slots: header, default (content), actions. Optional title/subtitle/media-src. clickable makes the body a button. Parts: root, media, body, actions.

Try it in the playground

@dojo-ng/card · v0.2.0

npm install @dojo-ng/card

import "@dojo-ng/card";

Navigation

  • Set path to make the card a link to an app path. The body becomes a real <a href>, so Ctrl/Cmd-click, middle-click, and "open in new tab" work, and a screen reader announces a link. Keep buttons and other controls out of the default slot of such a card, because they would sit inside a link; put them in the actions slot, which is outside it.
  • A plain click is turned into dj-navigate (detail { path, label }, label being the title), which @dojo-ng/history turns into a navigation. A click with a modifier key, or one that is already prevented, is left to the browser. With no history installed, the link navigates normally, as a full page load.
  • The href is the path with the history base added, so it stays correct under a prefix.
  • path wins over clickable: with both set, the body is the link and not a button.
  • Set track to follow the location: the link gets aria-current="page" while the location is this card's path. The package is only read when history is installed.

Properties

PropertyAttributeTypeDefault
kind kind reflected "elevated""outlined" "elevated"
square square boolean false
title title string ""
subtitle subtitle string ""
mediaSrc media-src string None
mediaTitle media-title string None
clickable clickable boolean false
pathAn app path. Makes the body a link to it. Wins over clickable. path string None
trackMark the link aria-current="page" while the navigation location is path. Needs @dojo-ng/history installed. track boolean false

Events

EventDescription
dj-navigatedetail { path, label }

Slots

SlotDescription
header
Default slotcontent
actions

CSS parts

Style these with dj-card::part(name).

rootmediabodyactions