content-card
A card: a picture, a heading, text and a footer, each optional. With href the heading is a link and the whole card is the target (one link for screen readers and the keyboard, not one per part), and buttons in the footer still work on their own.
A starter, a loaf and a schedule that fits around work. Six steps, two days, mostly waiting.
12 min readThis one has no events: it shows what it's given.
Source: content-card.zb, and its registry item.
Install
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/content-card.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/content-card.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/content-card.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/content-card.json
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/content-card.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/content-card.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/content-card.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/content-card.json
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/content-card.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/content-card.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/content-card.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/content-card.json
<link rel="stylesheet" href="https://zubra-js.github.io/zubra-ui/themes/default.css">
<script type="module" src="https://zubra-js.github.io/zubra-ui/cdn/content-card.js"></script>The compiled install writes src/components/zubra/content-card.js and the theme, and adds @zubra/runtime to your dependencies. The one-file install writes the same path as a plain custom element that needs nothing installed (or download it and load it with a <script type="module">); it's smaller on a page with one to three components, the shared runtime with more.
Usage
<content-card heading="Sourdough for beginners" href="#sourdough">
<p>A starter, a loaf and a schedule that fits around work. Six steps, two days, mostly waiting.</p>
<span slot="footer">12 min read</span>
</content-card>
<script type="module">
import './components/zubra/content-card.js';
</script>import './components/zubra/content-card.js';
export function ContentCardExample() {
return (
<content-card heading="Sourdough for beginners" href="#sourdough">
<p>A starter, a loaf and a schedule that fits around work. Six steps, two days, mostly waiting.</p>
<span slot="footer">12 min read</span>
</content-card>
);
}<script setup>
import './components/zubra/content-card.js';
</script>
<template>
<content-card heading="Sourdough for beginners" href="#sourdough">
<p>A starter, a loaf and a schedule that fits around work. Six steps, two days, mostly waiting.</p>
<span slot="footer">12 min read</span>
</content-card>
</template>
<!-- vite.config.js: vue({ template: { compilerOptions: { isCustomElement: (tag) => tag.includes('-') } } }) --><script>
import './components/zubra/content-card.js';
</script>
<content-card heading="Sourdough for beginners" href="#sourdough">
<p>A starter, a loaf and a schedule that fits around work. Six steps, two days, mostly waiting.</p>
<span slot="footer">12 min read</span>
</content-card>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import './components/zubra/content-card.js';
@Component({
selector: 'app-content-card-example',
schemas: [CUSTOM_ELEMENTS_SCHEMA],
template: `
<content-card heading="Sourdough for beginners" href="#sourdough">
<p>A starter, a loaf and a schedule that fits around work. Six steps, two days, mostly waiting.</p>
<span slot="footer">12 min read</span>
</content-card>
`,
})
export class ContentCardExample {
}API
| Property | Type | Default |
|---|---|---|
heading | string | "" |
href | string | "" |
| Slot | For |
|---|---|
(default) | The card's text. |
footer | Actions or details at the bottom. |
heading | The heading (defaults to heading). |
media | A picture or video at the top, edge to edge. |
Size
1.2 KB gzipped for the component, plus the runtime, which every Zubra component on a page shares (up to 22.1 KB, all of it). On its own, with the parts of the runtime it uses, it's 17.5 KB.