Skip to content

Demos

Basic table

NB: In this example, the sort buttons do react on your input. But will not change the table data.

A Table Caption
Column
Help Button
Row 1Row 1Row 1Row 1
Row 2Row 2Row 2Row 2

Row 3 with paragraph

Row 3 with code

Row 3 with medium paragraph

Row 3 with medium text

Complex table

You can force a row to overwrite the automated odd/even counting by providing e.g. variant="even" to a <Tr />. You can use this in combination with rowSpan.

NB: The table header in the first column needs to have scope="row"!

A Table Caption
Column 2
newline
Column 3 that spans
Row 1+2 HeaderRow 1 that spansRow 1Row 1
Row 2Row 2
Row 3 Header
newline
Row 3noSpacing + align="right"
Row 4 HeaderRow 4Row 4

Row scope headers only

This table has only scope="row" and scope="rowgroup" headers – without the default scope="col".

A Table Caption
Header ARow 1Row 1
Header BRow 2Row 2

Fixed table

A Table Caption
Column 1Column 2Column 3Column 4Column 5Column 6Column 7Column 8
Row 1Row 1Row 1Row 1Row 1Row 1Row 1Row 1
Row 2Row 2Row 2Row 2Row 2Row 2Row 2Row 2
Row 3Row 3Row 3Row 3Row 3Row 3Row 3Row 3
Row 4Row 4Row 4Row 4Row 4Row 4Row 4Row 4

Medium and small sized

A Table Caption
ColumnColumn
Row 1Row 1Row 1

Row 2 with paragraph

Row 2 with medium paragraph

Row 2 with medium text

A small sized table is only for special circumstances, where a lot of data needs to be shown on the screen at the same time.

A Table Caption
ColumnColumn
Row 1Row 1Row 1

Row 2 with paragraph

Row 2 with medium paragraph

Row 2 with medium text

Table with accordion

Expand a single container

The second table uses both a border and an outline.

A Table Caption
Column AColumn BColumn CColumn D
Row 1Row 1
Row 2Row 2
Row 3Row 3
A Table Caption
Column AColumn BColumn CColumn D
Row 1Row 1Row 1
Row 2Row 2Row 2
Row 3Row 3Row 3

Expand additional rows

It's also possible to use accordion to expand the table with more rows.

Column AColumn BColumn CColumn D
Row 1Row 1Row 1Row 1
Row 2Row 2Row 2Row 2
Collapse all rows at once

You can collapse all expanded rows by sending a ref to the collapseAllHandleRef property and calling the .current() function on your ref.

const myTableCollapseAll = React.useRef<(() => void) | undefined>(undefined)
return (
<button onClick={() => myTableCollapseAll.current?.()}>
Close all rows
</button>
<Table mode="accordion" collapseAllHandleRef={myTableCollapseAll}>
{/* ... your table code */}
</Table>
)

Table with clickable rows (navigation mode)

Use mode="navigation" on the <Table> and onClick on individual <Tr> rows to make them clickable. A chevron icon is rendered in an additional cell at the end of each clickable row for screen reader and keyboard accessibility. Rows respond to click as well as keyboard interaction with Space and Enter. Hover and focus indicators are sufficient to indicate interactivity per WCAG 1.4.1.

Table with clickable cells

Use onClick on individual <Td> cells to make them clickable. A native <button> is rendered inside the cell for screen reader and keyboard accessibility. The chevron icon is included by default, but is only shown on hover, active, and keyboard focus. Use icon={false} to hide it entirely, or pass a custom icon. Hover and focus indicators are sufficient to indicate interactivity per WCAG 1.4.1.

When the selected prop is provided (either true or false) together with onClick, the cell button is announced as a toggle button by screen readers, conveying its pressed state. The selected prop requires onClick to take effect, since the selected styling targets the cell button.

A Table Caption
AccountBalanceDetails

Table with keyboard navigation

Use the useTableKeyboardNavigation hook to navigate between cells with arrow keys. Focusable elements inside cells (inputs, buttons) receive focus automatically.

import Table, {
useTableKeyboardNavigation,
} from '@dnb/eufemia/components/Table'
Keyboard navigable table
NameEmailAction
Karikari@example.no
const KeyboardNavigationTable = () => {
  const navRef = useTableKeyboardNavigation()
  return (
    <Table border outline ref={navRef}>
      <caption className="dnb-sr-only">Keyboard navigable table</caption>

      <thead>
        <tr>
          <Th>Name</Th>
          <Th>Email</Th>
          <Th>Action</Th>
        </tr>
      </thead>

      <tbody>
        <tr>
          <Td>
            <Field.String label="Name" labelSrOnly value="Ola" />
          </Td>
          <Td>
            <Field.Email labelSrOnly value="ola@example.no" />
          </Td>
          <Td verticalAlign="middle">
            <Button
              variant="tertiary"
              icon={trashIcon}
              tooltip="Delete row"
            />
          </Td>
        </tr>
        <tr>
          <Td>
            <Field.String
              label="Name"
              labelSrOnly
              value="Kari"
              multiline
            />
          </Td>
          <Td>
            <Field.Email labelSrOnly value="kari@example.no" multiline />
          </Td>
          <Td verticalAlign="middle">
            <Button
              variant="tertiary"
              icon={trashIcon}
              tooltip="Delete row"
            />
          </Td>
        </tr>
        <tr>
          <Td>
            <Field.Number
              label="Quantity"
              labelSrOnly
              showStepControls
              width="small"
              value={1}
            />
          </Td>
          <Td>
            <Field.Number
              label="Quantity"
              labelSrOnly
              showStepControls
              width="small"
              value={2}
            />
          </Td>
          <Td verticalAlign="middle">
            <Button
              variant="tertiary"
              icon={trashIcon}
              tooltip="Delete row"
            />
          </Td>
        </tr>
        <tr>
          <Td>Kari</Td>
          <Td>kari@example.no</Td>
          <Td>
            <Button
              variant="tertiary"
              icon={trashIcon}
              tooltip="Delete row"
            />
          </Td>
        </tr>
      </tbody>
    </Table>
  )
}
render(<KeyboardNavigationTable />)

Table with sticky header

A Table Caption
Header

Row 1 with p

Row 1 with codeRow 1 with spanRow 1
Column which spans over two columnsRow 2Row 2
Row 3Row 3Row 3Row 3
FooterSum

Table with a max height

A sticky table header with sticky="css-position" and max-height on the Table.ScrollView.

Column 1Column 2Column 3Column 4
Row 1Row 1Row 1Row 1
Row 2Row 2Row 2Row 2
Row 3Row 3Row 3Row 3
Row 4Row 4Row 4Row 4
Row 5Row 5Row 5Row 5
Row 6Row 6Row 6Row 6
Row 7Row 7Row 7Row 7
Row 8Row 8Row 8Row 8
Row 9Row 9Row 9Row 9
Row 10Row 10Row 10Row 10
Row 11Row 11Row 11Row 11
Row 12Row 12Row 12Row 12

Several tables in one container

Read more: How the import and syntax is structured.
<TableContainer>
  <TableContainer.Head>
    <H2>Heading</H2>
  </TableContainer.Head>

  <TableContainer.Body>
    <Table>Content</Table>
    <Table>Content</Table>
  </TableContainer.Body>

  <TableContainer.Foot>
    <P>Footer</P>
  </TableContainer.Foot>
</TableContainer>

Header

Text

Table One
I have a superscript 1Column 2Column 3Column 4
Row 1Row 1Row 1Row 1
Row 2Row 2Row 2Row 2
Table Two
Column 1Column 2Column 3Column 4
Row 1Row 1Row 1Row 1
Row 2Row 2Row 2
Row 3Row 3Row 3
Row Header GroupRow 1Row 1
Row 2Row 2

Footer

With no (empty) head and foot content.

Column 1Column 2Column 3Column 4
Row 1Row 1Row 1Row 1
Row 2Row 2Row 2Row 2

Table with long header text (wrapping)

A Table Caption
Static long header senectus ornare convallis ut at erat imperdiet commodo

col span of 4

Table with pagination

Side 1

Table in Card

Using the subtle variant on the <Th>. The first <Tr> has the property variant="even" which will ensure a border below it to visually separate it from the body rows.

Watchlist

StockPriceChange
Acme Corporation142.50
Globex Industries87.30
Initech Solutions215.00
Umbrella Corp63.80

Responsive table in a Card

NB: For tables with lots of content, it's best to avoid repeating the header for each row. This can be overwhelming for users who rely on screen readers.

Also, it is important that the <td> without a <th> has a aria-label={header.title} to let users with screen readers know where "these tools" belong to.

This example uses scope="row" with a table header (<th>) in each row.

Card title
TittelLorem ipsum
BeskrivelseLorem ipsum
StatusIkke påbegynt
Frist17.04.2025
TittelLorem ipsum
BeskrivelseLorem ipsum
StatusIkke påbegynt
Frist17.04.2025

Column highlight

Use highlight on <Th>, <Tr>, or <Td> to apply a subtle background and border. When set on a <Tr>, all cells in that row are highlighted. You can also set it on individual <Td> cells.

To adjust the border colors accordingly, use the useTableHighlight hook and pass the returned ref to <Table>.

import Table, { useTableHighlight } from '@dnb/eufemia/components/Table'
const highlightRef = useTableHighlight()
render(<Table ref={highlightRef}>...</Table>)
Table with highlighted column
Column AColumn BColumn CColumn D
Row 1 HeaderRow 1Row 1Row 1Row 1
Row 2 HeaderRow 2Row 2Row 2Row 2
Row 3 HeaderRow 3Row 3Row 3Row 3

Example usage without and with classes

.dnb-table__th
.dnb-table__tr--even > .dnb-table__td
.dnb-table__tr--odd > .dnb-table__td