Tables

Card Breakpoint

A table that unfolds at narrow widths into a grid of cards rather than a stack of rows: the first cell becomes the card heading and the rest turn into label and value pairs.

  • table
  • responsive
  • cards
  • container-query

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/table-017?lang=en

Customer subscriptions
КлиентГородТарифПродлениеСумма
Мария КимКазаньКоманда12 сентября1 200 ₽
Артём ВолковПермьБизнес3 октября3 900 ₽
Лиза НаумоваТверьСтарт0 ₽
Гоша РыбакОмскКоманда28 сентября1 200 ₽
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 "table-017" (Card Breakpoint) 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/table-017.json

Registry item: https://vibeui.ru/r/table-017.json
Installs to: components/vibeui/table-017.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 table that unfolds at narrow widths into a grid of cards rather than a stack of rows: the first cell becomes the card heading and the rest turn into label and value pairs.

A table that becomes a grid of cards at narrow widths. Zero dependencies, one file, no client JS.

## 3. How to use it
import { Table017 } from "@/components/vibeui/table-017"

<Table017
  caption="Customer subscriptions"
  cardWidth="16rem"
/>

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-table-017-* palette — do not swap it for your theme tokens
- container-type:inline-size on the root: without it the layout measures the window, not the block
- the narrow-layout rules on shell's descendants: @container does not apply to the container itself
- aria-hidden on the in-cell label: otherwise the column name is announced twice
- th scope="row" on the first cell: in card mode it becomes the card heading
- the component's own light surface: dark text disappears on the dark catalog card

## 6. You may change
- the table rows through rows
- the minimum card width through cardWidth
- the table caption through caption
- the switch threshold by editing the value in @container

## 7. Rules
- The 34rem threshold is the block width, not the screen: cards also appear in a narrow desktop column.
- More than five fields per card turns to mush: hide the extras behind a details link.
- display:contents is not used on cells here — the card is held by the row's own grid.
- 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/table-017.json
https://vibeui.ru/r/table-017.json

Компонент самодостаточен: один файл, без зависимостей, палитра в переменных --vibeui-table-017-*. Серверный: хуков нет. Ширину меряет контейнерный запрос, а не медиазапрос: таблица может стоять в узкой колонке на широком экране. Все правила узкой раскладки висят на потомках [data-part="shell"], потому что @container не действует на сам контейнер. Ниже 34rem tbody становится grid с auto-fill, поэтому на планшете помещаются две карточки в ряд, а на телефоне одна. Подписи колонок лежат в разметке рядом со значением и просто скрыты на широкой ширине — вторая вёрстка списком не нужна, разметка остаётся одной таблицей.

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 Table017Row = {
  name: string
  city: string
  plan: string
  renew: string
  sum: string
}

export type Table017Props = Omit<
  ComponentPropsWithoutRef<"div">,
  "children"
> & {
  rows?: Table017Row[]
  caption?: string
  /** Минимальная ширина карточки в узкой раскладке. */
  cardWidth?: string
  accent?: string
}

// Идея компонента: на узкой ширине тело таблицы превращается не в столбик
// строк, а в сетку карточек — при 24–34rem их помещается две в ряд. Первая
// ячейка становится шапкой карточки на всю ширину, остальные — парами
// «подпись / значение» в два столбца. Подписи лежат в разметке рядом со
// значением и просто прячутся на широкой ширине, поэтому это одна таблица
// и на телефоне, и на десктопе — без второй вёрстки списком.
const STYLES = `
:where([data-vibeui-block="table-017"]){
--vibeui-table-017-bg:oklch(1 0 0);
--vibeui-table-017-fg:oklch(0.24 0.014 265);
--vibeui-table-017-muted:oklch(0.56 0.014 265);
--vibeui-table-017-border:oklch(0.92 0.006 265);
--vibeui-table-017-head:oklch(0.975 0.003 265);
--vibeui-table-017-accent:oklch(0.55 0.2 262);
--vibeui-table-017-card:14rem;
--vibeui-table-017-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="table-017"]{
container-type:inline-size;width:100%;box-sizing:border-box;
font-family:var(--vibeui-table-017-font);color:var(--vibeui-table-017-fg);
}
[data-vibeui-block="table-017"] [data-part="shell"]{
background:var(--vibeui-table-017-bg);
border:1px solid var(--vibeui-table-017-border);border-radius:1rem;padding:0.25rem;
}
[data-vibeui-block="table-017"] table{width:100%;border-collapse:collapse;font-size:0.8125rem}
[data-vibeui-block="table-017"] caption{
padding:0.625rem 0.75rem 0.5rem;text-align:left;font-size:0.9375rem;font-weight:650;
}
[data-vibeui-block="table-017"] th,
[data-vibeui-block="table-017"] td{
padding:0.5rem 0.75rem;text-align:left;
border-top:1px solid var(--vibeui-table-017-border);
}
[data-vibeui-block="table-017"] thead th{
background:var(--vibeui-table-017-head);font-weight:600;white-space:nowrap;
}
[data-vibeui-block="table-017"] tbody th{font-weight:600}
[data-vibeui-block="table-017"] [data-align="end"]{text-align:right;font-variant-numeric:tabular-nums}
[data-vibeui-block="table-017"] [data-part="label"]{display:none}
/* Узкая ширина: tbody становится сеткой карточек. Правила висят на
   потомках, потому что контейнерный запрос не действует на сам контейнер. */
@container (max-width: 34rem){
[data-vibeui-block="table-017"] [data-part="shell"] thead{
position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);
}
[data-vibeui-block="table-017"] [data-part="shell"] tbody{
display:grid;gap:0.5rem;padding:0.5rem;
grid-template-columns:repeat(auto-fill,minmax(var(--vibeui-table-017-card),1fr));
}
[data-vibeui-block="table-017"] [data-part="shell"] tr{
display:grid;grid-template-columns:1fr 1fr;gap:0.5rem;
border:1px solid var(--vibeui-table-017-border);border-radius:0.75rem;
padding:0.625rem 0.75rem;background:var(--vibeui-table-017-bg);
box-shadow:0 1px 2px oklch(0.24 0.014 265 / 6%);
}
[data-vibeui-block="table-017"] [data-part="shell"] th,
[data-vibeui-block="table-017"] [data-part="shell"] td{
border:0;padding:0;text-align:left;
}
[data-vibeui-block="table-017"] [data-part="shell"] tbody th{
grid-column:1 / -1;font-size:0.9375rem;line-height:1.2;
padding-bottom:0.375rem;border-bottom:1px solid var(--vibeui-table-017-border);
}
[data-vibeui-block="table-017"] [data-part="shell"] [data-part="label"]{
display:block;font-size:0.6875rem;line-height:1.2;color:var(--vibeui-table-017-muted);
}
[data-vibeui-block="table-017"] [data-part="shell"] [data-part="value"]{
display:block;font-size:0.8125rem;
}
[data-vibeui-block="table-017"] [data-part="shell"] [data-align="end"]{text-align:left}
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="table-017"] *{animation:none!important;transition:none!important}}
`

const DEFAULT_ROWS: Table017Row[] = [
  {
    name: "Мария Ким",
    city: "Казань",
    plan: "Команда",
    renew: "12 сентября",
    sum: "1 200 ₽",
  },
  {
    name: "Артём Волков",
    city: "Пермь",
    plan: "Бизнес",
    renew: "3 октября",
    sum: "3 900 ₽",
  },
  {
    name: "Лиза Наумова",
    city: "Тверь",
    plan: "Старт",
    renew: "—",
    sum: "0 ₽",
  },
  {
    name: "Гоша Рыбак",
    city: "Омск",
    plan: "Команда",
    renew: "28 сентября",
    sum: "1 200 ₽",
  },
]

const COLUMNS = [
  { key: "city", title: "Город" },
  { key: "plan", title: "Тариф" },
  { key: "renew", title: "Продление" },
  { key: "sum", title: "Сумма", numeric: true },
] as const

/**
 * Таблица, которая на узкой ширине раскладывается сеткой карточек.
 * Один файл, ноль зависимостей, собственная палитра.
 */
export function Table017({
  rows = DEFAULT_ROWS,
  caption = "Подписки клиентов",
  cardWidth,
  accent,
  className,
  style,
  ...props
}: Table017Props) {
  const palette = {
    ...(accent ? { "--vibeui-table-017-accent": accent } : null),
    ...(cardWidth ? { "--vibeui-table-017-card": cardWidth } : null),
    ...style,
  } as CSSProperties

  return (
    <>
      <style href="vibeui-table-017" precedence="medium">
        {STYLES}
      </style>
      <div
        {...props}
        data-vibeui-block="table-017"
        className={className}
        style={palette}
      >
        <div data-part="shell">
          <table>
            <caption>{caption}</caption>
            <thead>
              <tr>
                <th scope="col">Клиент</th>
                {COLUMNS.map((column) => (
                  <th
                    key={column.key}
                    scope="col"
                    data-align={"numeric" in column ? "end" : undefined}
                  >
                    {column.title}
                  </th>
                ))}
              </tr>
            </thead>
            <tbody>
              {rows.map((row) => (
                <tr key={row.name}>
                  <th scope="row">{row.name}</th>
                  {COLUMNS.map((column) => (
                    <td
                      key={column.key}
                      data-align={"numeric" in column ? "end" : undefined}
                    >
                      <span data-part="label" aria-hidden="true">
                        {column.title}
                      </span>
                      <span data-part="value">{row[column.key]}</span>
                    </td>
                  ))}
                </tr>
              ))}
            </tbody>
          </table>
        </div>
      </div>
    </>
  )
}