> ## Documentation Index
> Fetch the complete documentation index at: https://www.beeq.design/llms.txt
> Use this file to discover all available pages before exploring further.

# Table

> Tables organize structured data in rows and columns so people can scan records, compare values, sort, and identify patterns across a dataset.

![BEEQ Table component overview](https://mintcdn.com/beeq/nN2FF5Iq6pY7AHlL/components/images/table/table-overview-light.svg?fit=max\&auto=format\&n=nN2FF5Iq6pY7AHlL\&q=85\&s=a174c2f8ffe9ff2d1ce7d1e7b8fc6e63)

Table component overview

Tables organize information into rows and columns so people can compare values, find records, and take action on individual items. BEEQ styles the native HTML `<table>` element with CSS utility classes instead of shipping a custom web component.

> [!NOTE]
>
> Because the table is a CSS-only pattern, you own the correct HTML structure: `<table>`, `<thead>`, `<tbody>`, `<tr>`, `<th>`, and `<td>`. BEEQ styles apply only when the `bq-table` class is present on the `<table>` element.

## When to use

> [card]
>
> Use tables when
>
> * You need to display multiple attributes of multiple items simultaneously
> * Users need to scan, compare, or sort across rows
> * Data has a natural row-and-column structure, such as transactions, records, or reports
> * Inline actions such as editing or deleting a row belong next to each record

> [card]
>
> Do not use tables when
>
> * You only need to display a single attribute per item — a list is simpler
> * The data is non-comparative prose or narrative content
> * You need a layout grid — use CSS Grid or Flexbox instead
> * The number of columns is very large and the content would be better served by a detail page

## Patterns

> [card] Data grid with actions
>
> Add a trailing actions column containing a dropdown or icon buttons to let users edit, delete, or navigate to a detail view for each row.

> [card] Selected row highlight
>
> Apply `.selected` to a `<tr>` to visually indicate the active or focused record, for example when a row drives a side panel or detail pane.

> [card] Compact density
>
> Use the `.compact` modifier in dense dashboards or administrative interfaces where vertical space matters more than breathing room.

> [card] Bordered layout
>
> Add the `bordered` modifier to a table that already has the `bq-table` class when each cell needs an explicit boundary, such as in financial or spreadsheet-style tables.

> [card] Large datasets
>
> BEEQ does not ship a pagination, sorting, filtering, or virtualization component. Render only the current page of rows yourself, then compose page controls from `bq-button`, `bq-select`, or `bq-input` to let users move between pages.

## Anatomy

A table is built from standard HTML sectioning and cell elements. Each part has a defined role and styling responsibility.

| Part | Element | Description |
| - | - | - |
| **1** | `<table class="bq-table">` | Root element that activates BEEQ table styles |
| **2** | `<thead>` | Header section containing column labels |
| **3** | `<th>` | Header cell for a single column |
| **4** | `<tbody>` | Body section containing data rows |
| **5** | `<tr>` | A single data row; add `.selected` for the active state |
| **6** | `<td>` | A single data cell |
| **7** | `.bq-table--container` | Optional responsive wrapper that enables horizontal scrolling |

## Design guidelines

## Default density

The default table uses generous cell padding to give content room to breathe. Use it in most contexts where the dataset fits comfortably on screen.

## Compact density

The `.compact` modifier reduces padding significantly. Reserve it for dashboards or administrative screens where showing more rows at once outweighs the reduced spacing.

## Default (divider) borders

The default style separates rows with a single bottom border and uses subtle column dividers in the header only. This keeps the table light and easy to scan.

## Bordered

A table with `class="bq-table bordered"` uses separate cell borders and an outer border. Use it when column delineation is critical for data clarity, such as financial or spreadsheet-style tables.

> [!NOTE]
>
> Wrap the table in `.bq-table--container` to enable horizontal scrolling on smaller screens. Without this wrapper, wide tables may overflow their parent container.

## Usage

### Default

The default table applies base typography, header and cell padding, and row separators. Add the `bq-table` class to any standard `<table>` element to activate the styles.

```html HTML icon="html5" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
<table class="bq-table">
  <caption>Account balances</caption>
  <thead>
    <tr>
      <th scope="col">Name</th>
      <th scope="col">Status</th>
      <th scope="col">Amount</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>John Doe</td>
      <td>Active</td>
      <td>−2,343 €</td>
    </tr>
    <tr>
      <td>Alice Smith</td>
      <td>Pending</td>
      <td>+95,453 €</td>
    </tr>
    <tr>
      <td>Robert Johnson</td>
      <td>Inactive</td>
      <td>−2,343 €</td>
    </tr>
  </tbody>
</table>
```

```jsx React icon="react" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
<table className="bq-table">
  <caption>Account balances</caption>
  <thead>
    <tr>
      <th scope="col">Name</th>
      <th scope="col">Status</th>
      <th scope="col">Amount</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>John Doe</td>
      <td>Active</td>
      <td>−2,343 €</td>
    </tr>
    <tr>
      <td>Alice Smith</td>
      <td>Pending</td>
      <td>+95,453 €</td>
    </tr>
    <tr>
      <td>Robert Johnson</td>
      <td>Inactive</td>
      <td>−2,343 €</td>
    </tr>
  </tbody>
</table>
```

```ts Angular icon="angular" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
import { Component } from "@angular/core";

@Component({
  selector: "app-root",
  standalone: true,
  imports: [],
  template: `
    <table class="bq-table">
      <caption>Account balances</caption>
      <thead>
        <tr>
          <th scope="col">Name</th>
          <th scope="col">Status</th>
          <th scope="col">Amount</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>John Doe</td>
          <td>Active</td>
          <td>−2,343 €</td>
        </tr>
        <tr>
          <td>Alice Smith</td>
          <td>Pending</td>
          <td>+95,453 €</td>
        </tr>
        <tr>
          <td>Robert Johnson</td>
          <td>Inactive</td>
          <td>−2,343 €</td>
        </tr>
      </tbody>
    </table>
  `,
})
export class AppComponent {}
```

```vue Vue icon="vuejs" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
<template>
  <table class="bq-table">
    <caption>Account balances</caption>
    <thead>
      <tr>
        <th scope="col">Name</th>
        <th scope="col">Status</th>
        <th scope="col">Amount</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>John Doe</td>
        <td>Active</td>
        <td>−2,343 €</td>
      </tr>
      <tr>
        <td>Alice Smith</td>
        <td>Pending</td>
        <td>+95,453 €</td>
      </tr>
      <tr>
        <td>Robert Johnson</td>
        <td>Inactive</td>
        <td>−2,343 €</td>
      </tr>
    </tbody>
  </table>
</template>
```

## Options

**Allowed modifier classes:** `compact` and `bordered` on `<table class="bq-table">` (neither is on by default), and `selected` on `<tr>`. Density is `default` unless `compact` is set. Each modifier works only together with the `bq-table` class.

### Selected row

Add the `selected` class to a `<tr>` to highlight the active record. Use it when a row selection drives a side panel, detail view, or other contextual UI.

```html HTML icon="html5" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
<table class="bq-table">
  <caption>Account balances</caption>
  <thead>
    <tr>
      <th scope="col">Name</th>
      <th scope="col">Status</th>
      <th scope="col">Amount</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>John Doe</td>
      <td>Active</td>
      <td>−2,343 €</td>
    </tr>
    <tr class="selected">
      <td>Alice Smith</td>
      <td>Pending</td>
      <td>+95,453 €</td>
    </tr>
    <tr>
      <td>Robert Johnson</td>
      <td>Inactive</td>
      <td>−2,343 €</td>
    </tr>
  </tbody>
</table>
```

```jsx React icon="react" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
<table className="bq-table">
  <caption>Account balances</caption>
  <thead>
    <tr>
      <th scope="col">Name</th>
      <th scope="col">Status</th>
      <th scope="col">Amount</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>John Doe</td>
      <td>Active</td>
      <td>−2,343 €</td>
    </tr>
    <tr className="selected">
      <td>Alice Smith</td>
      <td>Pending</td>
      <td>+95,453 €</td>
    </tr>
    <tr>
      <td>Robert Johnson</td>
      <td>Inactive</td>
      <td>−2,343 €</td>
    </tr>
  </tbody>
</table>
```

```ts Angular icon="angular" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
import { Component } from "@angular/core";

@Component({
  selector: "app-root",
  standalone: true,
  imports: [],
  template: `
    <table class="bq-table">
      <caption>Account balances</caption>
      <thead>
        <tr>
          <th scope="col">Name</th>
          <th scope="col">Status</th>
          <th scope="col">Amount</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>John Doe</td>
          <td>Active</td>
          <td>−2,343 €</td>
        </tr>
        <tr class="selected">
          <td>Alice Smith</td>
          <td>Pending</td>
          <td>+95,453 €</td>
        </tr>
        <tr>
          <td>Robert Johnson</td>
          <td>Inactive</td>
          <td>−2,343 €</td>
        </tr>
      </tbody>
    </table>
  `,
})
export class AppComponent {}
```

```vue Vue icon="vuejs" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
<template>
  <table class="bq-table">
    <caption>Account balances</caption>
    <thead>
      <tr>
        <th scope="col">Name</th>
        <th scope="col">Status</th>
        <th scope="col">Amount</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>John Doe</td>
        <td>Active</td>
        <td>−2,343 €</td>
      </tr>
      <tr class="selected">
        <td>Alice Smith</td>
        <td>Pending</td>
        <td>+95,453 €</td>
      </tr>
      <tr>
        <td>Robert Johnson</td>
        <td>Inactive</td>
        <td>−2,343 €</td>
      </tr>
    </tbody>
  </table>
</template>
```

### Compact

Add the `compact` class to the `<table>` to reduce cell and header padding. This is useful in dense, data-heavy interfaces where vertical space is at a premium.

```html HTML icon="html5" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
<table class="bq-table compact">
  <caption>Account balances</caption>
  <thead>
    <tr>
      <th scope="col">Name</th>
      <th scope="col">Status</th>
      <th scope="col">Amount</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>John Doe</td>
      <td>Active</td>
      <td>−2,343 €</td>
    </tr>
    <tr class="selected">
      <td>Alice Smith</td>
      <td>Pending</td>
      <td>+95,453 €</td>
    </tr>
    <tr>
      <td>Robert Johnson</td>
      <td>Inactive</td>
      <td>−2,343 €</td>
    </tr>
  </tbody>
</table>
```

```jsx React icon="react" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
<table className="bq-table compact">
  <caption>Account balances</caption>
  <thead>
    <tr>
      <th scope="col">Name</th>
      <th scope="col">Status</th>
      <th scope="col">Amount</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>John Doe</td>
      <td>Active</td>
      <td>−2,343 €</td>
    </tr>
    <tr className="selected">
      <td>Alice Smith</td>
      <td>Pending</td>
      <td>+95,453 €</td>
    </tr>
    <tr>
      <td>Robert Johnson</td>
      <td>Inactive</td>
      <td>−2,343 €</td>
    </tr>
  </tbody>
</table>
```

```ts Angular icon="angular" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
import { Component } from "@angular/core";

@Component({
  selector: "app-root",
  standalone: true,
  imports: [],
  template: `
    <table class="bq-table compact">
      <caption>Account balances</caption>
      <thead>
        <tr>
          <th scope="col">Name</th>
          <th scope="col">Status</th>
          <th scope="col">Amount</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>John Doe</td>
          <td>Active</td>
          <td>−2,343 €</td>
        </tr>
        <tr class="selected">
          <td>Alice Smith</td>
          <td>Pending</td>
          <td>+95,453 €</td>
        </tr>
        <tr>
          <td>Robert Johnson</td>
          <td>Inactive</td>
          <td>−2,343 €</td>
        </tr>
      </tbody>
    </table>
  `,
})
export class AppComponent {}
```

```vue Vue icon="vuejs" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
<template>
  <table class="bq-table compact">
    <caption>Account balances</caption>
    <thead>
      <tr>
        <th scope="col">Name</th>
        <th scope="col">Status</th>
        <th scope="col">Amount</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>John Doe</td>
        <td>Active</td>
        <td>−2,343 €</td>
      </tr>
      <tr class="selected">
        <td>Alice Smith</td>
        <td>Pending</td>
        <td>+95,453 €</td>
      </tr>
      <tr>
        <td>Robert Johnson</td>
        <td>Inactive</td>
        <td>−2,343 €</td>
      </tr>
    </tbody>
  </table>
</template>
```

### Bordered

Add `bordered` alongside `bq-table` to draw borders around each cell and the table itself. This modifier switches to separate cell borders with zero spacing; `bordered` alone does not enable BEEQ table styles.

```html HTML icon="html5" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
<table class="bq-table bordered">
  <caption>Account balances</caption>
  <thead>
    <tr>
      <th scope="col">Name</th>
      <th scope="col">Status</th>
      <th scope="col">Amount</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>John Doe</td>
      <td>Active</td>
      <td>−2,343 €</td>
    </tr>
    <tr class="selected">
      <td>Alice Smith</td>
      <td>Pending</td>
      <td>+95,453 €</td>
    </tr>
    <tr>
      <td>Robert Johnson</td>
      <td>Inactive</td>
      <td>−2,343 €</td>
    </tr>
  </tbody>
</table>
```

```jsx React icon="react" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
<table className="bq-table bordered">
  <caption>Account balances</caption>
  <thead>
    <tr>
      <th scope="col">Name</th>
      <th scope="col">Status</th>
      <th scope="col">Amount</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>John Doe</td>
      <td>Active</td>
      <td>−2,343 €</td>
    </tr>
    <tr className="selected">
      <td>Alice Smith</td>
      <td>Pending</td>
      <td>+95,453 €</td>
    </tr>
    <tr>
      <td>Robert Johnson</td>
      <td>Inactive</td>
      <td>−2,343 €</td>
    </tr>
  </tbody>
</table>
```

```ts Angular icon="angular" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
import { Component } from "@angular/core";

@Component({
  selector: "app-root",
  standalone: true,
  imports: [],
  template: `
    <table class="bq-table bordered">
      <caption>Account balances</caption>
      <thead>
        <tr>
          <th scope="col">Name</th>
          <th scope="col">Status</th>
          <th scope="col">Amount</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>John Doe</td>
          <td>Active</td>
          <td>−2,343 €</td>
        </tr>
        <tr class="selected">
          <td>Alice Smith</td>
          <td>Pending</td>
          <td>+95,453 €</td>
        </tr>
        <tr>
          <td>Robert Johnson</td>
          <td>Inactive</td>
          <td>−2,343 €</td>
        </tr>
      </tbody>
    </table>
  `,
})
export class AppComponent {}
```

```vue Vue icon="vuejs" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
<template>
  <table class="bq-table bordered">
    <caption>Account balances</caption>
    <thead>
      <tr>
        <th scope="col">Name</th>
        <th scope="col">Status</th>
        <th scope="col">Amount</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>John Doe</td>
        <td>Active</td>
        <td>−2,343 €</td>
      </tr>
      <tr class="selected">
        <td>Alice Smith</td>
        <td>Pending</td>
        <td>+95,453 €</td>
      </tr>
      <tr>
        <td>Robert Johnson</td>
        <td>Inactive</td>
        <td>−2,343 €</td>
      </tr>
    </tbody>
  </table>
</template>
```

### Pagination and large datasets

BEEQ does not ship a pagination, sorting, filtering, or virtualization component, and the `bq-table` class does not read from a data source. You render the current page of rows yourself in your framework, then build the page controls from existing BEEQ components — typically `bq-button` for previous and next, and `bq-select` for the page size.

```css styles.css icon="css" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--bq-spacing-m);
  margin-block-start: var(--bq-spacing-m);
}

.pager__nav,
.pager__size,
.pages__container {
  display: flex;
  align-items: center;
  gap: var(--bq-spacing-xs);
}

.pager__status {
  color: var(--bq-text--secondary);
  font-size: var(--bq-font-size--s);
}

.pager__size bq-select {
  inline-size: 5rem;
}

.visually-hidden {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
```

```javascript script.js icon="js" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
(() => {
  const records = Array.from({ length: 23 }, (_, index) => ({
    id: index + 1,
    name: `Record ${index + 1}`,
    status: index % 2 ? "Active" : "Pending",
  }));
  let page = 1;
  let size = 5;
  const rows = document.querySelector("#rows");
  const prev = document.querySelector("#prev");
  const next = document.querySelector("#next");
  const select = document.querySelector("#size");
  const totalRecords = document.querySelector("#total_records");
  const pageStatus = document.querySelector("#page_status");
  const pagesContainer = document.querySelector("#pages_container");

  const render = () => {
    const pageCount = Math.max(1, Math.ceil(records.length / size));
    const start = (page - 1) * size;
    const pageRecords = records.slice(start, start + size);
    rows.innerHTML = pageRecords
      .map(
        (record) =>
          `<tr><td>${record.id}</td><td>${record.name}</td><td>${record.status}</td></tr>`,
      )
      .join("");
    prev.disabled = page <= 1;
    next.disabled = page >= pageCount;
    totalRecords.textContent = `from ${records.length}`;
    pageStatus.textContent = `Page ${page} of ${pageCount}`;
    pagesContainer.innerHTML = Array.from({ length: pageCount }, (_, index) => {
      const pageNumber = index + 1;
      const appearance = page === pageNumber ? "primary" : "text";
      const current = page === pageNumber ? "page" : "false";
      return `
        <bq-button
          appearance="${appearance}"
          size="small"
          border="s"
          label="Page ${pageNumber}"
          aria-current="${current}"
          data-page="${pageNumber}"
        >${pageNumber}</bq-button>
      `;
    }).join("");
  };

  const setPage = (nextPage) => {
    const pageCount = Math.max(1, Math.ceil(records.length / size));
    page = Math.max(1, Math.min(nextPage, pageCount));
    render();
  };

  pagesContainer.addEventListener("bqClick", (event) => {
    const button = event.target.closest("bq-button[data-page]");
    if (button) setPage(Number(button.dataset.page));
  });

  prev.addEventListener("bqClick", () => setPage(page - 1));
  next.addEventListener("bqClick", () => setPage(page + 1));
  select.addEventListener("bqSelect", (event) => {
    size = Number(event.detail.value);
    setPage(1);
  });

  render();
})();
```

```html HTML icon="html5" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
<table class="bq-table" id="tbl">
  <caption class="visually-hidden">Records</caption>
  <thead>
    <tr>
      <th scope="col">ID</th>
      <th scope="col">Name</th>
      <th scope="col">Status</th>
    </tr>
  </thead>
  <tbody id="rows"></tbody>
</table>

<div class="pager">
  <div class="pager__size">
    <span class="pager__status">Displaying</span>
    <bq-select id="size" value="5" disable-clear disable-search same-width>
      <bq-option value="5">5</bq-option>
      <bq-option value="10">10</bq-option>
      <bq-option value="25">25</bq-option>
    </bq-select>
    <span class="pager__status" id="total_records"></span>
  </div>
  <nav class="pager__nav" aria-label="Pagination">
    <bq-button id="prev" appearance="text" size="small" border="s" only-icon label="Previous page">
      <bq-icon name="caret-left"></bq-icon>
    </bq-button>
    <div class="pages__container" id="pages_container"></div>
    <bq-button id="next" appearance="text" size="small" border="s" only-icon label="Next page">
      <bq-icon name="caret-right"></bq-icon>
    </bq-button>
  </nav>
</div>
<span class="visually-hidden" id="page_status" aria-live="polite"></span>

<!-- Add the JavaScript from the JavaScript tab. -->
```

```jsx React icon="react" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
import { useState } from "react";
import { BqButton, BqIcon, BqOption, BqSelect } from "@beeq/react";
import "./styles.css";

const records = Array.from({ length: 23 }, (_, index) => ({
  id: index + 1,
  name: `Record ${index + 1}`,
  status: index % 2 ? "Active" : "Pending",
}));

export function PaginatedTable() {
  const [page, setPage] = useState(1);
  const [size, setSize] = useState(5);
  const pageCount = Math.max(1, Math.ceil(records.length / size));
  const pageNumbers = Array.from(
    { length: pageCount },
    (_, index) => index + 1,
  );
  const rows = records.slice((page - 1) * size, page * size);

  const setCurrentPage = (nextPage) => {
    setPage(Math.max(1, Math.min(nextPage, pageCount)));
  };

  const handleSizeChange = (event) => {
    setSize(Number(event.detail.value));
    setPage(1);
  };

  return (
    <>
      <table className="bq-table">
        <caption className="visually-hidden">Records</caption>
        <thead>
          <tr>
            <th scope="col">ID</th>
            <th scope="col">Name</th>
            <th scope="col">Status</th>
          </tr>
        </thead>
        <tbody>
          {rows.map((row) => (
            <tr key={row.id}>
              <td>{row.id}</td>
              <td>{row.name}</td>
              <td>{row.status}</td>
            </tr>
          ))}
        </tbody>
      </table>

      <div className="pager">
        <div className="pager__size">
          <span className="pager__status">Displaying</span>
          <BqSelect
            value={String(size)}
            disableClear
            disableSearch
            sameWidth
            onBqSelect={handleSizeChange}
          >
            <BqOption value="5">5</BqOption>
            <BqOption value="10">10</BqOption>
            <BqOption value="25">25</BqOption>
          </BqSelect>
          <span className="pager__status">from {records.length}</span>
        </div>
        <nav className="pager__nav" aria-label="Pagination">
          <BqButton
            appearance="text"
            size="small"
            border="s"
            onlyIcon
            label="Previous page"
            disabled={page <= 1}
            onBqClick={() => setCurrentPage(page - 1)}
          >
            <BqIcon name="caret-left" />
          </BqButton>
          <div className="pages__container">
            {pageNumbers.map((pageNumber) => (
              <BqButton
                key={pageNumber}
                appearance={page === pageNumber ? "primary" : "text"}
                size="small"
                border="s"
                label={`Page ${pageNumber}`}
                aria-current={page === pageNumber ? "page" : undefined}
                onBqClick={() => setCurrentPage(pageNumber)}
              >
                {pageNumber}
              </BqButton>
            ))}
          </div>
          <BqButton
            appearance="text"
            size="small"
            border="s"
            onlyIcon
            label="Next page"
            disabled={page >= pageCount}
            onBqClick={() => setCurrentPage(page + 1)}
          >
            <BqIcon name="caret-right" />
          </BqButton>
        </nav>
      </div>
      <span className="visually-hidden" aria-live="polite">
        Page {page} of {pageCount}
      </span>
    </>
  );
}
```

```ts Angular icon="angular" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
import { Component } from "@angular/core";
import { BqButton, BqIcon, BqOption, BqSelect } from "@beeq/angular/standalone";

@Component({
  selector: "app-root",
  standalone: true,
  imports: [BqButton, BqIcon, BqOption, BqSelect],
  styleUrl: "./styles.css",
  template: `
    <table class="bq-table">
      <caption class="visually-hidden">Records</caption>
      <thead>
        <tr>
          <th scope="col">ID</th>
          <th scope="col">Name</th>
          <th scope="col">Status</th>
        </tr>
      </thead>
      <tbody>
        @for (row of rows; track row.id) {
          <tr>
            <td>{{ row.id }}</td>
            <td>{{ row.name }}</td>
            <td>{{ row.status }}</td>
          </tr>
        }
      </tbody>
    </table>

    <div class="pager">
      <div class="pager__size">
        <span class="pager__status">Displaying</span>
        <bq-select
          [value]="size"
          [disableClear]="true"
          [disableSearch]="true"
          [sameWidth]="true"
          (bqSelect)="handleSizeChange($event)"
        >
          <bq-option value="5">5</bq-option>
          <bq-option value="10">10</bq-option>
          <bq-option value="25">25</bq-option>
        </bq-select>
        <span class="pager__status">from {{ records.length }}</span>
      </div>
      <nav class="pager__nav" aria-label="Pagination">
        <bq-button
          appearance="text"
          size="small"
          border="s"
          [onlyIcon]="true"
          label="Previous page"
          [disabled]="page <= 1"
          (bqClick)="setPage(page - 1)"
        >
          <bq-icon name="caret-left"></bq-icon>
        </bq-button>
        <div class="pages__container">
          @for (pageNumber of pageNumbers; track pageNumber) {
            <bq-button
              [appearance]="page === pageNumber ? 'primary' : 'text'"
              size="small"
              border="s"
              [label]="'Page ' + pageNumber"
              [attr.aria-current]="page === pageNumber ? 'page' : null"
              (bqClick)="setPage(pageNumber)"
            >
              {{ pageNumber }}
            </bq-button>
          }
        </div>
        <bq-button
          appearance="text"
          size="small"
          border="s"
          [onlyIcon]="true"
          label="Next page"
          [disabled]="page >= pageCount"
          (bqClick)="setPage(page + 1)"
        >
          <bq-icon name="caret-right"></bq-icon>
        </bq-button>
      </nav>
    </div>
    <span class="visually-hidden" aria-live="polite">Page {{ page }} of {{ pageCount }}</span>
  `,
})
export class PaginatedTableComponent {
  readonly records = Array.from({ length: 23 }, (_, index) => ({
    id: index + 1,
    name: `Record ${index + 1}`,
    status: index % 2 ? "Active" : "Pending",
  }));
  page = 1;
  size = 5;

  get pageCount() {
    return Math.max(1, Math.ceil(this.records.length / this.size));
  }

  get pageNumbers() {
    return Array.from({ length: this.pageCount }, (_, index) => index + 1);
  }

  get rows() {
    return this.records.slice((this.page - 1) * this.size, this.page * this.size);
  }

  setPage(nextPage: number) {
    this.page = Math.max(1, Math.min(nextPage, this.pageCount));
  }
  handleSizeChange(event: CustomEvent<{ value: string | number | string[] }>) {
    this.size = Number(event.detail.value);
    this.setPage(1);
  }
}
```

```vue Vue icon="vuejs" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
<script setup>
import { computed, ref } from "vue";
import { BqButton, BqIcon, BqOption, BqSelect } from "@beeq/vue";
import "./styles.css";

const records = Array.from({ length: 23 }, (_, index) => ({
  id: index + 1,
  name: `Record ${index + 1}`,
  status: index % 2 ? "Active" : "Pending",
}));
const page = ref(1);
const size = ref(5);
const pageCount = computed(() =>
  Math.max(1, Math.ceil(records.length / size.value)),
);
const rows = computed(() =>
  records.slice((page.value - 1) * size.value, page.value * size.value),
);
const pageNumbers = computed(() =>
  Array.from({ length: pageCount.value }, (_, index) => index + 1),
);

const setPage = (nextPage) => {
  page.value = Math.max(1, Math.min(nextPage, pageCount.value));
};
const handleSizeChange = (event) => {
  size.value = Number(event.detail.value);
  setPage(1);
};
</script>

<template>
  <table class="bq-table">
    <caption class="visually-hidden">Records</caption>
    <thead>
      <tr>
        <th scope="col">ID</th>
        <th scope="col">Name</th>
        <th scope="col">Status</th>
      </tr>
    </thead>
    <tbody>
      <tr v-for="row in rows" :key="row.id">
        <td>{{ row.id }}</td>
        <td>{{ row.name }}</td>
        <td>{{ row.status }}</td>
      </tr>
    </tbody>
  </table>

  <div class="pager">
    <div class="pager__size">
      <span class="pager__status">Displaying</span>
      <BqSelect
        :value="String(size)"
        disableClear
        disableSearch
        sameWidth
        @bqSelect="handleSizeChange"
      >
        <BqOption value="5">5</BqOption>
        <BqOption value="10">10</BqOption>
        <BqOption value="25">25</BqOption>
      </BqSelect>
      <span class="pager__status">from {{ records.length }}</span>
    </div>
    <nav class="pager__nav" aria-label="Pagination">
      <BqButton
        appearance="text"
        size="small"
        border="s"
        onlyIcon
        label="Previous page"
        :disabled="page <= 1"
        @bqClick="setPage(page - 1)"
      >
        <BqIcon name="caret-left" />
      </BqButton>
      <div class="pages__container">
        <BqButton
          v-for="pageNumber in pageNumbers"
          :key="pageNumber"
          :appearance="page === pageNumber ? 'primary' : 'text'"
          size="small"
          border="s"
          :label="`Page ${pageNumber}`"
          :aria-current="page === pageNumber ? 'page' : undefined"
          @bqClick="setPage(pageNumber)"
        >
          {{ pageNumber }}
        </BqButton>
      </div>
      <BqButton
        appearance="text"
        size="small"
        border="s"
        onlyIcon
        label="Next page"
        :disabled="page >= pageCount"
        @bqClick="setPage(page + 1)"
      >
        <BqIcon name="caret-right" />
      </BqButton>
    </nav>
  </div>
  <span class="visually-hidden" aria-live="polite">
    Page {{ page }} of {{ pageCount }}
  </span>
</template>
```

> [!NOTE]
>
> Announce page changes for screen reader users. This example updates a polite live region after each transition; move focus to the first cell when the new page must become the next task.

## Best practices

> [card]
>
> Do
>
> Always wrap the table in `.bq-table--container` so it scrolls horizontally on small screens instead of overflowing.

> [card]
>
> Don't
>
> Let a wide table overflow its parent without a scroll container — this breaks the page layout on narrow viewports.

> [card]
>
> Do
>
> Keep column headers short and descriptive so users understand each column without reading the data first.

> [card]
>
> Don't
>
> Use abbreviations or internal codes in headers without a tooltip or legend to explain them.

> [card]
>
> Do
>
> Align numeric values to the trailing edge of the cell so decimal points and magnitudes line up across rows.

> [card]
>
> Don't
>
> Mix left-aligned and center-aligned numeric columns in the same table — inconsistent alignment makes comparison harder.

> [card]
>
> Do
>
> Choose the density that matches the user's task — default for reading and reviewing, compact for monitoring and bulk operations.

> [card]
>
> Don't
>
> Apply the compact modifier to fit more rows when it makes the content harder to read or interact with.

## Accessibility

* You must provide a `<caption>` or `aria-label` on the `<table>` element so screen readers announce the table's purpose before reading the data.
* You must use `<th>` elements with the correct `scope` attribute (`scope="col"` for column headers, `scope="row"` for row headers) so assistive technologies can map each cell to its headers.
* You must keep the table structure semantic. You must not use a `<table>` for layout purposes.
* You must give inline action elements inside cells (buttons, dropdowns) accessible labels, especially icon-only controls.
* When a row selection changes UI state (such as opening a side panel), you must communicate that change programmatically, for example by managing focus or using a live region.
* Built in: the `.selected` row styling uses `outline` rather than `border` so the selection indicator does not affect layout. There is no automatic ARIA state applied; you should add `aria-selected="true"` to the `<tr>` when the row is interactively selectable.

### Keyboard interaction

No keyboard interaction: the component is not focusable. The table styles add no focusable elements; buttons, links, and dropdowns you place in cells follow their own keyboard behavior.

### Rules

| Rule | Strength | Verified by |
| - | - | - |
| Provide a `<caption>` or `aria-label` on the `<table>` | MUST | manual: inspect the table accessible name |
| Use `<th>` with `scope="col"` or `scope="row"` | MUST | manual: inspect header cells and their scope values |
| Do not use a `<table>` for layout | MUST NOT | manual: inspect whether the markup presents data or page layout |
| Give inline actions inside cells accessible labels, especially icon-only controls | MUST | manual: tab through inline actions and inspect their names |
| Communicate selection-driven UI changes programmatically, for example with focus management or a live region | MUST | manual: select a row and inspect focus or live-region feedback |
| Add `aria-selected="true"` to the `<tr>` of a selectable row, since none is applied automatically | SHOULD | manual: inspect selectable rows for aria-selected |

## API reference

### CSS classes

The table pattern is CSS-only. There is no custom element. Apply these classes to standard HTML elements:

| Class | Element | Description |
| - | - | - |
| `bq-table` | `<table>` | **Required.** Activates all BEEQ table styles |
| `compact` | `<table>` | Reduces cell and header padding for dense layouts |
| `bordered` | `<table class="bq-table">` | Modifier that uses separate cell borders with zero spacing and an outer table border |
| `selected` | `<tr>` | Highlights the row as the active or selected record |
| `bq-table--container` | `<div>` | Responsive wrapper that enables horizontal scrolling |

### CSS custom properties

**CSS variables**

| Variable | Description | Default |
| - | - | - |
| `--bq-table--border-color` | Border color for dividers and cell borders | `var(--bq-stroke--primary)` |
| `--bq-table--border-style` | Border style for dividers and cell borders | `solid` |
| `--bq-table--border-width` | Border width for dividers and cell borders | `var(--bq-stroke-s)` |
| `--bq-table--border-radius` | Border radius for bordered table corners and selected row | `var(--bq-radius--m)` |
| `--bq-table--cell-padding-block` | Block (vertical) padding for data cells | `var(--bq-spacing-m)` |
| `--bq-table--cell-padding-inline` | Inline (horizontal) padding for data cells | `var(--bq-spacing-m)` |
| `--bq-table--header-divider-inset` | Vertical inset for the column divider line in `<th>` | `25%` |
| `--bq-table--header-height` | Height of the `<thead>` row | `3.25rem` |
| `--bq-table--header-padding-block` | Block (vertical) padding for header cells | `var(--bq-spacing-xs)` |
| `--bq-table--header-padding-inline` | Inline (horizontal) padding for header cells | `var(--bq-spacing-m)` |
| `--bq-table--row-selected-bg` | Background color of a selected row | `var(--bq-ui--brand-alt)` |
| `--bq-table--row-selected-border` | Outline color of a selected row | `var(--bq-stroke--brand)` |
| `--bq-table--text-color` | Text color for header and data cells | `var(--bq-text--primary)` |

> [!TIP]
>
> Learn more about [styling with shadow parts](https://www.beeq.design/guides/styles.md#component-shadow-dom-parts) and [CSS custom properties](https://www.beeq.design/guides/styles.md#global-css-custom-properties).

## Resources

> [card] [Interactive playground](https://storybook.beeq.design/?path=/story/components-table--default)
>
> Explore table variants and states in Storybook.

> [card] [Source code](https://github.com/Endava/BEEQ/blob/main/packages/beeq/src/global/styles/_table.scss)
>
> View the table styles source on GitHub.


## Related topics

- [Date Picker](https://www.beeq.design/components/date-picker.md)
- [Stroke](https://www.beeq.design/foundations/stroke.md)
- [Grid](https://www.beeq.design/foundations/grid.md)
- [Select](https://www.beeq.design/components/select.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.