Tables

Invoice Table

An invoice table whose total is computed from the lines and sticks to the bottom, so the amount stays visible halfway down a long list.

  • invoice
  • table
  • total
  • money

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

Invoice
ПозицияКол-воСумма
Тариф «Команда»Годовая подписка, 12 месяцев128 800,00 €
Дополнительные участники3 человека сверх тарифа310 800,00 €
Домен .ruПродление на год1890,00 €
НДС 20 %8 098,00 €
Итого48 588,00 €
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-003" (Invoice 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-003.json

Registry item: https://vibeui.ru/r/table-003.json
Installs to: components/vibeui/table-003.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
An invoice table whose total is computed from the lines and sticks to the bottom, so the amount stays visible halfway down a long list.

An invoice table: line title with a note, quantity and amount. The subtotal, tax and total are computed from the lines, so the figures cannot drift from the items. The total sits in tfoot and sticks to the bottom of the frame. Amounts align right in tabular figures. Zero dependencies, one file, its own palette.

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

<Table003
  caption="Invoice"
  taxRate={20}
  lines={[{ title: "Team plan", quantity: 1, amount: 28800 }]}
/>

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-003-* palette — do not swap it for your theme tokens (bg-muted, border-border and the like)
- computing the total from the lines rather than taking it as a prop: the amount and the items must have one source
- the total row in <tfoot>: that is the semantics of a total, not merely the last row
- the sticky tfoot: in a long invoice the amount has to be visible without scrolling to the end
- right-aligned amounts with tabular-nums — money is read by digit columns
- the amount format: a space between thousands, a comma for the fraction, the currency symbol separate
- the <style> block inside the component — it holds the palette, the spacing and the sticky total

## 6. You may change
- the lines array: title, note, quantity and amount
- taxRate — the tax percentage; 0 removes the tax row
- currency — the currency symbol
- caption — the document heading
- width and max height through className
- the accent through the accent prop — it colours the total amount

## 7. Rules
- Amounts arrive as numbers in major units. If you store cents, divide before passing them — the component does not guess the arithmetic.
- The format is deliberately Russian and independent of the project locale. For another country change formatAmount in your copy.
- Discounts and prepayments are not built in: add them as lines with a negative amount.
- 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-003.json
https://vibeui.ru/r/table-003.json

Компонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-table-003-*. Итог и налог считаются из массива строк прямо в компоненте — отдельного пропа «сумма» нет, поэтому разойтись с позициями они не могут. Строка итога лежит в <tfoot> и липнет к низу обёртки. Суммы форматируются локальной функцией: пробел как разделитель тысяч, запятая в дробной части, символ валюты пропом — Intl не используется, чтобы не зависеть от локали проекта.

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 Table003Line = {
  title: string
  hint?: string
  quantity?: number
  amount: number
}

export type Table003Props = Omit<
  ComponentPropsWithoutRef<"div">,
  "children"
> & {
  lines?: Table003Line[]
  /** Ставка налога в процентах. 0 — строку налога не показывать. */
  taxRate?: number
  currency?: string
  caption?: string
  accent?: string
}

// Идея компонента: таблица с деньгами, где итог виден без прокрутки. Строка
// итога стоит в <tfoot> и липнет к низу обёртки, суммы идут моноширинными
// цифрами по правому краю, а сам итог считается из строк, а не задаётся
// отдельным пропом — разойтись они не могут.
const STYLES = `
:where([data-vibeui-block="table-003"]){
--vibeui-table-003-fg:oklch(0.24 0.016 265);
--vibeui-table-003-muted:oklch(0.54 0.014 265);
--vibeui-table-003-bg:oklch(1 0 0);
--vibeui-table-003-foot:oklch(0.975 0.003 265);
--vibeui-table-003-border:oklch(0.91 0.006 265);
--vibeui-table-003-accent:oklch(0.55 0.2 262);
--vibeui-table-003-radius:0.75rem;
--vibeui-table-003-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="table-003"]{
width:100%;max-width:34rem;box-sizing:border-box;overflow:auto;max-height:24rem;
border:1px solid var(--vibeui-table-003-border);
border-radius:var(--vibeui-table-003-radius);
background:var(--vibeui-table-003-bg);color:var(--vibeui-table-003-fg);
font-family:var(--vibeui-table-003-font);
}
[data-vibeui-block="table-003"] table{width:100%;border-collapse:separate;border-spacing:0;font-size:0.875rem}
[data-vibeui-block="table-003"] caption{
padding:0.75rem 0.9375rem;text-align:left;
font-size:0.8125rem;font-weight:600;
border-bottom:1px solid var(--vibeui-table-003-border);
}
[data-vibeui-block="table-003"] th{
padding:0.5rem 0.9375rem;text-align:left;
font-size:0.6875rem;font-weight:600;letter-spacing:0.05em;text-transform:uppercase;
color:var(--vibeui-table-003-muted);
border-bottom:1px solid var(--vibeui-table-003-border);
}
[data-vibeui-block="table-003"] td{
padding:0.625rem 0.9375rem;border-bottom:1px solid var(--vibeui-table-003-border);
}
[data-vibeui-block="table-003"] [data-part="hint"]{
display:block;font-size:0.75rem;color:var(--vibeui-table-003-muted);
}
[data-vibeui-block="table-003"] [data-numeric="true"]{
text-align:right;font-variant-numeric:tabular-nums;white-space:nowrap;
}
/* Итог липнет к низу: сумма видна и на середине длинного списка. */
[data-vibeui-block="table-003"] tfoot td{
position:sticky;bottom:0;
background:var(--vibeui-table-003-foot);
border-top:1px solid var(--vibeui-table-003-border);border-bottom:0;
}
[data-vibeui-block="table-003"] tfoot [data-part="total"]{font-size:1rem;font-weight:600}
/* Итоговая сумма — единственное акцентное пятно: на неё и смотрят. */
[data-vibeui-block="table-003"] tfoot [data-numeric="true"][data-part="total"]{color:var(--vibeui-table-003-accent)}
[data-vibeui-block="table-003"] tfoot [data-part="sub"]{color:var(--vibeui-table-003-muted)}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="table-003"] *{animation:none!important;transition:none!important}}
`

const DEFAULT_LINES: Table003Line[] = [
  {
    title: "Тариф «Команда»",
    hint: "Годовая подписка, 12 месяцев",
    quantity: 1,
    amount: 28800,
  },
  {
    title: "Дополнительные участники",
    hint: "3 человека сверх тарифа",
    quantity: 3,
    amount: 10800,
  },
  { title: "Домен .ru", hint: "Продление на год", quantity: 1, amount: 890 },
]

/** Пробел вместо разделителя тысяч и запятая в дробной части — как в рублях. */
function formatAmount(value: number, currency: string) {
  const rounded = Math.round(value * 100) / 100
  const [whole, fraction = "00"] = rounded.toFixed(2).split(".")
  const grouped = whole.replace(/\B(?=(\d{3})+(?!\d))/g, " ")

  return `${grouped},${fraction} ${currency}`
}

/**
 * Таблица позиций с итогом, который считается из строк и липнет к низу.
 * Один файл, ноль зависимостей, собственная палитра.
 */
export function Table003({
  lines = DEFAULT_LINES,
  taxRate = 20,
  currency = "₽",
  caption = "Счёт на оплату",
  accent,
  className,
  style,
  ...props
}: Table003Props) {
  const palette = {
    ...(accent ? { "--vibeui-table-003-accent": accent } : null),
    ...style,
  } as CSSProperties

  const subtotal = lines.reduce((sum, line) => sum + line.amount, 0)
  const tax = (subtotal * taxRate) / 100
  const total = subtotal + tax

  return (
    <>
      <style href="vibeui-table-003" precedence="medium">
        {STYLES}
      </style>
      <div
        {...props}
        data-vibeui-block="table-003"
        className={className}
        style={palette}
      >
        <table>
          {caption ? <caption>{caption}</caption> : null}
          <thead>
            <tr>
              <th scope="col">Позиция</th>
              <th scope="col" data-numeric="true">
                Кол-во
              </th>
              <th scope="col" data-numeric="true">
                Сумма
              </th>
            </tr>
          </thead>
          <tbody>
            {lines.map((line) => (
              <tr key={line.title}>
                <td>
                  {line.title}
                  {line.hint ? <span data-part="hint">{line.hint}</span> : null}
                </td>
                <td data-numeric="true">{line.quantity ?? 1}</td>
                <td data-numeric="true">
                  {formatAmount(line.amount, currency)}
                </td>
              </tr>
            ))}
          </tbody>
          <tfoot>
            {taxRate > 0 ? (
              <tr>
                <td colSpan={2} data-part="sub">
                  НДС {taxRate} %
                </td>
                <td data-numeric="true" data-part="sub">
                  {formatAmount(tax, currency)}
                </td>
              </tr>
            ) : null}
            <tr>
              <td colSpan={2} data-part="total">
                Итого
              </td>
              <td data-numeric="true" data-part="total">
                {formatAmount(total, currency)}
              </td>
            </tr>
          </tfoot>
        </table>
      </div>
    </>
  )
}