Card

Product Card

A product card for a grid: the add-to-cart button is its own target above the link, or adding would open the page instead.

  • card
  • product
  • commerce
  • grid

Preview

1440pxHost theme

Use it with AI

  1. 1. Copy the link.
  2. 2. Write to your agent in your own words and drop the link into the sentence.
  3. 3. The agent opens the link and installs the component from the registry.

put this in the header: https://vibeui.ru/c/card-004?lang=en

Show the full instructions

What the link says, spelled out. Use it when your agent cannot open links — paste this text instead.

# Install and place "card-004" (Product Card) from VibeUI

## 1. Install first — do not skip, do not recreate
Run this exact command before writing any code:
npx shadcn@latest add https://vibeui.ru/r/card-004.json

Registry item: https://vibeui.ru/r/card-004.json
Installs to: components/vibeui/card-004.tsx (the exact path follows this project's components.json aliases).
npm dependencies: none.
Registry dependencies: none.

Install it from the registry. Do not recreate it from the description,
do not substitute a similar component from another library, and do not
rewrite it to match the project's existing style.

## 2. What it is
A product card for a grid: the add-to-cart button is its own target above the link, or adding would open the page instead.

A product card: a square frame, a discount badge, a two-line title, a numeric rating, price with a struck-through old price and an add-to-cart button. Zero dependencies, one file, no client JS.

## 3. How to use it
import { Card004 } from "@/components/vibeui/card-004"

<Card004 title="Polyot desk lamp" price="$59" rating={4.7} reviews={128} />

Read the installed file for the full prop list.

## 4. Where to place it
This is a small inline component. Put it exactly where the user asked,
inside the existing markup. Do not create a new page, section or
wrapper for it. If a similar control already sits in that spot,
replace it instead of adding a second one.

Placement: ___
(The user fills this line in. If it is still blank, ask where to put it
instead of guessing.)

## 5. Keep exactly as installed
- the local --vibeui-card-004-* palette — do not swap it for your theme tokens
- keeping the targets apart: the button sits above the stretched link, or the cart opens the page
- the numeric rating beside the star — filled shapes are less precise
- the square frame: cards in a grid must share one height
- clamping the title to two lines
- the focus ring on the whole card via :has(a:focus-visible)

## 6. You may change
- title, price, oldPrice and badge
- rating and reviews
- actionLabel — the button's text
- the accent through the accent prop

## 7. Rules
- Prices are strings: format them upstream, the component computes nothing.
- An old price with no real discount is a lie: show it only when the price truly was higher.
- The frame is empty: drop an <img> inside, the CSS is ready.
- Do not lift the CSS variables into globals.css: the component has to stay a single file.

## 8. Verify
- it renders with no console errors;
- it looks like the preview on the VibeUI page you copied this from;
- if it does not, you changed something listed in section 5 — put it back.

For developers

npx shadcn@latest add https://vibeui.ru/r/card-004.json
https://vibeui.ru/r/card-004.json

Компонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-card-004-*. Серверный: хуков нет. Ссылка растянута на карточку псевдоэлементом ::after, а кнопка поднята z-index, поэтому обе цели не конфликтуют. Обводка фокуса ставится на карточку через :has(). Звезда нарисована clip-path, рейтинг продублирован текстом в aria-label.

Component source

The same file your agent installs. Here in case you would rather copy it by hand.

import type { ComponentPropsWithoutRef, CSSProperties } from "react"

export type Card004Props = Omit<
  ComponentPropsWithoutRef<"article">,
  "children" | "title"
> & {
  title?: string
  price?: string
  oldPrice?: string
  rating?: number
  reviews?: number
  badge?: string
  href?: string
  actionLabel?: string
  accent?: string
}

// Идея компонента: карточка товара для сетки магазина. Кнопка «в корзину» —
// отдельная цель поверх ссылки на товар: если сделать кликабельной всю
// карточку, добавление в корзину начнёт открывать страницу. Рейтинг подписан
// числом, а не только звёздами: «4,7 из 5» точнее, чем закрашенные фигуры.
const STYLES = `
:where([data-vibeui-block="card-004"]){
--vibeui-card-004-bg:oklch(1 0 0);
--vibeui-card-004-fg:oklch(0.22 0.014 265);
--vibeui-card-004-muted:oklch(0.55 0.014 265);
--vibeui-card-004-border:oklch(0.91 0.006 265);
--vibeui-card-004-frame:oklch(0.96 0.004 265);
--vibeui-card-004-accent:oklch(0.55 0.17 265);
--vibeui-card-004-sale:oklch(0.56 0.19 25);
--vibeui-card-004-star:oklch(0.72 0.15 80);
--vibeui-card-004-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="card-004"]{
position:relative;display:flex;flex-direction:column;gap:0.5rem;
width:100%;max-width:15rem;box-sizing:border-box;padding:0.75rem;
background:var(--vibeui-card-004-bg);
border:1px solid var(--vibeui-card-004-border);border-radius:0.875rem;
color:var(--vibeui-card-004-fg);font-family:var(--vibeui-card-004-font);
}
[data-vibeui-block="card-004"] [data-part="frame"]{
position:relative;aspect-ratio:1 / 1;overflow:hidden;
border-radius:0.625rem;
background:
radial-gradient(90% 80% at 30% 20%,oklch(1 0 0),transparent 70%),
var(--vibeui-card-004-frame);
}
[data-vibeui-block="card-004"] img{width:100%;height:100%;object-fit:cover;display:block}
[data-vibeui-block="card-004"] [data-part="badge"]{
position:absolute;left:0.5rem;top:0.5rem;
padding:0.1875rem 0.4375rem;border-radius:0.375rem;
background:var(--vibeui-card-004-sale);color:oklch(0.99 0.01 25);
font-size:0.6875rem;font-weight:700;
}
[data-vibeui-block="card-004"] [data-part="title"]{
margin:0;font-size:0.875rem;font-weight:600;line-height:1.35;
display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;
}
[data-vibeui-block="card-004"] a{color:inherit;text-decoration:none}
/* Ссылка растянута на карточку, но кнопка лежит выше по z-index: иначе
   «в корзину» начнёт открывать страницу товара. */
[data-vibeui-block="card-004"] a::after{content:"";position:absolute;inset:0;border-radius:inherit}
[data-vibeui-block="card-004"]:has(a:focus-visible){outline:2px solid var(--vibeui-card-004-accent);outline-offset:2px}
[data-vibeui-block="card-004"] [data-part="rating"]{
display:flex;align-items:center;gap:0.25rem;
font-size:0.75rem;color:var(--vibeui-card-004-muted);
}
[data-vibeui-block="card-004"] [data-part="star"]{
width:0.6875rem;height:0.6875rem;flex:none;background:var(--vibeui-card-004-star);
clip-path:polygon(50% 0,61% 35%,98% 35%,68% 57%,79% 91%,50% 70%,21% 91%,32% 57%,2% 35%,39% 35%);
}
[data-vibeui-block="card-004"] [data-part="prices"]{display:flex;align-items:baseline;gap:0.4375rem}
[data-vibeui-block="card-004"] [data-part="price"]{font-size:1rem;font-weight:680;font-variant-numeric:tabular-nums}
[data-vibeui-block="card-004"] [data-part="old"]{
font-size:0.8125rem;color:var(--vibeui-card-004-muted);
text-decoration:line-through;font-variant-numeric:tabular-nums;
}
[data-vibeui-block="card-004"] button{
position:relative;z-index:1;appearance:none;cursor:pointer;
height:2.125rem;border:0;border-radius:0.5rem;
background:var(--vibeui-card-004-accent);color:oklch(0.99 0.01 265);
font:inherit;font-size:0.8125rem;font-weight:650;
}
[data-vibeui-block="card-004"] button:hover{filter:brightness(0.96)}
[data-vibeui-block="card-004"] button:focus-visible{outline:2px solid var(--vibeui-card-004-accent);outline-offset:2px}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="card-004"] *{animation:none!important;transition:none!important}}
`

/**
 * Карточка товара: кнопка в корзину — отдельная цель поверх ссылки.
 * Один файл, ноль зависимостей, собственная палитра.
 */
export function Card004({
  title = "Настольная лампа «Полёт», тёплый свет",
  price = "4 900 ₽",
  oldPrice = "6 900 ₽",
  rating = 4.7,
  reviews = 128,
  badge = "−30 %",
  href = "#",
  actionLabel = "В корзину",
  accent,
  className,
  style,
  ...props
}: Card004Props) {
  const palette = {
    ...(accent ? { "--vibeui-card-004-accent": accent } : null),
    ...style,
  } as CSSProperties

  return (
    <>
      <style href="vibeui-card-004" precedence="medium">
        {STYLES}
      </style>
      <article
        {...props}
        data-vibeui-block="card-004"
        className={className}
        style={palette}
      >
        <div data-part="frame">
          {badge ? <span data-part="badge">{badge}</span> : null}
        </div>
        <h3 data-part="title">
          <a href={href}>{title}</a>
        </h3>
        <p
          data-part="rating"
          aria-label={`Рейтинг ${rating} из 5, отзывов: ${reviews}`}
        >
          <span data-part="star" aria-hidden="true" />
          <span aria-hidden="true">
            {rating} · {reviews}
          </span>
        </p>
        <p data-part="prices">
          <span data-part="price">{price}</span>
          {oldPrice ? <span data-part="old">{oldPrice}</span> : null}
        </p>
        <button type="button">{actionLabel}</button>
      </article>
    </>
  )
}