Preview card

preview-card — image + title + meta + optional footer

Generic card for grid/list outputs. One template, many uses: product boxes, article previews, reference items, category tiles, team members. Optional badges over the image, optional footer for a price/CTA row, the whole card becomes a link if href is provided.

Pure SCSS — no JS.

Install

npx czg-ui add preview-card

@import 'components/preview-card'; to app.scss. No JS.

Requires base.

Parameters

ParamTypeDefaultNotes
hrefstring\nullIf set, the entire card is wrapped in <a>
imagestring\nullImage URL; omitted = card with no image
altstring''Alt text for the image
titlestringCard heading (rendered as <h3>)
metastring\nullSub-line under the title (HTML allowed)
badgesarray[][['text' => 'Novinka', 'modifier' => 'new'], …] overlaid on the image
footerstring\nullHTML content for the footer slot (price + button, …)
classstring\nullExtra wrapper class

Usage — product box

{include /app/components/Card/preview-card.latte,
    href   => $product->url,
    image  => $product->thumbUrl,
    alt    => $product->title,
    title  => $product->title,
    meta   => $product->shortDescription,
    badges => [
        ['text' => 'Novinka', 'modifier' => 'new'],
        ['text' => '-20 %', 'modifier' => 'discount'],
    ],
    footer => $latte->render('partials/product-footer.latte', ['p' => $product])}

Usage — article teaser

{include /app/components/Card/preview-card.latte,
    href  => $article->url,
    image => $article->coverImage,
    title => $article->title,
    meta  => $article->publishedAt|date:'j. n. Y'}

Badge modifiers

The modifier key adds preview-card__badge--{$modifier} class. Common values defined in SCSS: new, discount, sold-out, top. Add more in your project's _preview-card.scss override.

When NOT to use

  • Single hero feature that should be visually distinct — design a

custom block, don't reuse the card pattern

  • Tabular data with comparable values across rows — use a real

<table>

Live preview

ui.czechgroup.cz/component/preview-card

Další kategorie