Tables

Data Table

A data table with a sticky header and scrolling inside its own frame. Numeric columns align right in tabular figures, so digits line up across rows.

  • table
  • data
  • sticky header
  • numbers

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-001?lang=en

Pages in March
СтраницаИзмененаПросмотрыДоля
Главная12 марта18 40246,1 %
Услуги9 марта7 11817,8 %
Портфолио2 марта6 94017,4 %
О студии27 февраля4 23310,6 %
Контакты27 февраля3 2108,1 %
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-001" (Data Table) 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-001.json

Registry item: https://vibeui.ru/r/table-001.json
Installs to: components/vibeui/table-001.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 data table with a sticky header and scrolling inside its own frame. Numeric columns align right in tabular figures, so digits line up across rows.

A data table: sticky header, scrolling inside the frame, row hover and a dense mode. Numeric columns are declared by a flag and align right in tabular figures. Cells accept ReactNode, so a status badge or a link fits inside. Zero dependencies, one file, its own palette.

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

<Table001
  caption="Pages in March"
  columns={[
    { key: "page", label: "Page" },
    { key: "views", label: "Views", numeric: true },
  ]}
  rows={rows}
/>

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-001-* palette — do not swap it for your theme tokens (bg-muted, border-border and the like)
- scrolling inside the wrapper rather than the page: without it a wide table stretches the layout on a phone
- the sticky header through position:sticky on th — scrolling a long list otherwise loses the columns
- right alignment together with font-variant-numeric:tabular-nums: otherwise digits do not line up between rows
- the table semantics: thead, tbody, th with scope="col" and a caption — this is data, not a grid of divs
- border-collapse:separate together with per-cell borders: with collapse the sticky header loses its rule
- the <style> block inside the component — it holds the palette, the spacing and the sticky header

## 6. You may change
- the columns and rows arrays; a cell takes a ReactNode, so a badge or link fits
- caption — the label above the table, and the heading a screen reader announces
- dense — the compact mode for long lists
- the accent through the accent prop — it colours links inside the table
- max height and width through className

## 7. Rules
- There is no sorting or filtering here: this is a table, not a data grid. Sort outside and pass reordered rows.
- Do not turn the table into cards on mobile: horizontal scrolling is more honest and keeps rows comparable.
- Cell keys come from column.key. A key missing from a row leaves the cell empty — that is not a bug.
- 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-001.json
https://vibeui.ru/r/table-001.json

Компонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-table-001-*. Прокрутка живёт в обёртке, а не на странице: таблица не ломает раскладку на узком экране. Шапка липнет к верху обёртки через position:sticky. Числовые колонки помечаются флагом numeric в описании колонок и получают выравнивание вправо и tabular-nums. Плотный режим меняет одну переменную отступа.

Component source

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

import type { ComponentPropsWithoutRef, CSSProperties, ReactNode } from "react"

export type Table001Column = {
  key: string
  label: string
  /** Числовая колонка: выравнивается вправо и получает моноширинные цифры. */
  numeric?: boolean
}

export type Table001Row = Record<string, ReactNode>

export type Table001Props = Omit<
  ComponentPropsWithoutRef<"div">,
  "children"
> & {
  columns?: Table001Column[]
  rows?: Table001Row[]
  caption?: string
  /** Плотный режим: строки ниже, шрифт мельче. */
  dense?: boolean
  accent?: string
}

// Идея компонента: таблица, которая не разваливается на телефоне и не врёт
// про числа. Прокрутка живёт в обёртке, шапка липнет к верху при вертикальной
// прокрутке, а числовые колонки идут вправо с моноширинными цифрами, чтобы
// разряды стояли под разрядами.
const STYLES = `
:where([data-vibeui-block="table-001"]){
--vibeui-table-001-fg:oklch(0.24 0.016 265);
--vibeui-table-001-muted:oklch(0.54 0.014 265);
--vibeui-table-001-bg:oklch(1 0 0);
--vibeui-table-001-head:oklch(0.975 0.003 265);
--vibeui-table-001-border:oklch(0.91 0.006 265);
--vibeui-table-001-hover:oklch(0.55 0.02 265 / 5%);
--vibeui-table-001-accent:oklch(0.55 0.2 262);
--vibeui-table-001-radius:0.75rem;
--vibeui-table-001-pad:0.6875rem;
--vibeui-table-001-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="table-001"]{
width:100%;box-sizing:border-box;overflow:auto;
max-height:22rem;
border:1px solid var(--vibeui-table-001-border);
border-radius:var(--vibeui-table-001-radius);
background:var(--vibeui-table-001-bg);color:var(--vibeui-table-001-fg);
font-family:var(--vibeui-table-001-font);
}
[data-vibeui-block="table-001"][data-dense="true"]{--vibeui-table-001-pad:0.4375rem}
[data-vibeui-block="table-001"] table{width:100%;border-collapse:separate;border-spacing:0;font-size:0.875rem}
[data-vibeui-block="table-001"][data-dense="true"] table{font-size:0.8125rem}
[data-vibeui-block="table-001"] caption{
padding:var(--vibeui-table-001-pad) 0.875rem;text-align:left;
font-size:0.8125rem;color:var(--vibeui-table-001-muted);
border-bottom:1px solid var(--vibeui-table-001-border);
}
/* Шапка липнет к верху обёртки: при прокрутке длинного списка она нужна. */
[data-vibeui-block="table-001"] th{
position:sticky;top:0;z-index:1;
padding:var(--vibeui-table-001-pad) 0.875rem;text-align:left;
background:var(--vibeui-table-001-head);
border-bottom:1px solid var(--vibeui-table-001-border);
font-size:0.75rem;font-weight:600;letter-spacing:0.02em;
color:var(--vibeui-table-001-muted);white-space:nowrap;
}
[data-vibeui-block="table-001"] td{
padding:var(--vibeui-table-001-pad) 0.875rem;
border-bottom:1px solid var(--vibeui-table-001-border);
vertical-align:middle;
}
[data-vibeui-block="table-001"] tr:last-child td{border-bottom:0}
[data-vibeui-block="table-001"] tbody tr:hover td{background:var(--vibeui-table-001-hover)}
/* Числа вправо и моноширинными: разряды должны стоять под разрядами. */
[data-vibeui-block="table-001"] [data-numeric="true"]{
text-align:right;font-variant-numeric:tabular-nums;
}
[data-vibeui-block="table-001"] a{color:var(--vibeui-table-001-accent);text-decoration:none}
[data-vibeui-block="table-001"] a:hover{text-decoration:underline}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="table-001"] *{animation:none!important;transition:none!important}}
`

const DEFAULT_COLUMNS: Table001Column[] = [
  { key: "page", label: "Страница" },
  { key: "updated", label: "Изменена" },
  { key: "views", label: "Просмотры", numeric: true },
  { key: "share", label: "Доля", numeric: true },
]

const DEFAULT_ROWS: Table001Row[] = [
  {
    page: "Главная",
    updated: "12 марта",
    views: "18 402",
    share: "46,1 %",
  },
  { page: "Услуги", updated: "9 марта", views: "7 118", share: "17,8 %" },
  { page: "Портфолио", updated: "2 марта", views: "6 940", share: "17,4 %" },
  { page: "О студии", updated: "27 февраля", views: "4 233", share: "10,6 %" },
  { page: "Контакты", updated: "27 февраля", views: "3 210", share: "8,1 %" },
]

/**
 * Таблица данных: липкая шапка, прокрутка в обёртке, числа по разрядам.
 * Один файл, ноль зависимостей, собственная палитра.
 */
export function Table001({
  columns = DEFAULT_COLUMNS,
  rows = DEFAULT_ROWS,
  caption = "Страницы сайта за март",
  dense = false,
  accent,
  className,
  style,
  ...props
}: Table001Props) {
  const palette = {
    ...(accent ? { "--vibeui-table-001-accent": accent } : null),
    ...style,
  } as CSSProperties

  return (
    <>
      <style href="vibeui-table-001" precedence="medium">
        {STYLES}
      </style>
      <div
        {...props}
        data-vibeui-block="table-001"
        data-dense={dense || undefined}
        className={className}
        style={palette}
      >
        <table>
          {caption ? <caption>{caption}</caption> : null}
          <thead>
            <tr>
              {columns.map((column) => (
                <th
                  key={column.key}
                  scope="col"
                  data-numeric={column.numeric || undefined}
                >
                  {column.label}
                </th>
              ))}
            </tr>
          </thead>
          <tbody>
            {rows.map((row, index) => (
              <tr key={index}>
                {columns.map((column) => (
                  <td
                    key={column.key}
                    data-numeric={column.numeric || undefined}
                  >
                    {row[column.key]}
                  </td>
                ))}
              </tr>
            ))}
          </tbody>
        </table>
      </div>
    </>
  )
}