Skip to main content Home About the Design SystemRoadmap OverviewDesignersDevelopers OverviewColorGridIconographyInteractionsSpacingTypography Overview Global colorBox shadowTypographyBorderOpacitySpaceLengthIconBreakpointsMedia queries All elements Accordion Alert Announcement Audio player Avatar Back to top Badge Blockquote Breadcrumb Button Card Chip Code block Call to action Dialog Disclosure Footer Health index Icon Jump links Menu dropdown Navigation link Navigation (primary) Navigation (secondary) Navigation (vertical) Pagination PopoverPlanned Progress stepper Scheme toggle Site status Skeleton Skip link Spinner Statistic Subnavigation Surface Switch Table Tabs Tag Tile Timestamp Tooltip Video embed OverviewColor PalettesCustomizingDevelopers All PatternsAccordionAlertCall to ActionCardFilterFormLink with iconLogo wallSearch barSticky bannerSticky cardTabsTagTile All Personalization PatternsAnnouncement FundamentalsAccessibility toolsAssistive technologiesCI/CDContentContributorsDesignDevelopmentManual testingResourcesScreen readers Design/code status Release notes Get support

Table

OverviewStyleGuidelinesCodeAccessibilityDemos
ImportingUsagerh-tablerh-sort-buttonImportingUsagerh-tablerh-sort-button

Importing

Add rh-table to your page with this import statement:

<script type="module">
  import '@rhds/elements/rh-table/rh-table.js';
</script>
Copy to Clipboard Wrap lines

To learn more about installing RHDS elements on your site using an import map read our getting started docs.

Lightdom CSS

This element requires you to load "Lightdom CSS" stylesheets for styling deeply slotted elements.

Note

Replace /path/to/ with path to the CSS file, whether local or CDN.

<link rel="stylesheet" href="/path/to/rh-table/rh-table-lightdom.css">

Usage

<rh-table>
  <table>
    <caption>
      Concerts
    </caption>
    <colgroup>
      <col>
      <col>
      <col>
    </colgroup>
    <thead>
      <tr>
        <th scope="col">Date</th>
        <th scope="col">Event<rh-sort-button></rh-sort-button>
        </th>
        <th scope="col">Venue<rh-sort-button></rh-sort-button>
        </th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>12 February</td>
        <td>Waltz with Strauss</td>
        <td>Main Hall</td>
      </tr>
      <tr>
        <td>24 March</td>
        <td>The Obelisks</td>
        <td>West Wing</td>
      </tr>
      <tr>
        <td>14 April</td>
        <td>The What</td>
        <td>Main Hall</td>
      </tr>
    </tbody>
  </table>
  <small slot="summary">Dates and venues subject to change.</small>
</rh-table>

<link rel="stylesheet" href="../rh-table-lightdom.css">

<script type="module">
  import '@rhds/elements/rh-table/rh-table.js';
</script>
Copy to Clipboard Wrap lines

Title

Specify the title of the table using a <caption> element.

<rh-table>
  <table>
    <caption>
      Concerts
    </caption>
    <!-- ...table data -->
  </table>
</rh-table>

Responsive tables

<rh-table> will automatically reformat to a "stacked" presentation in narrow containers such as on small screens and mobile devices or in page sidebars. For simple table structures, each table cell heading will be auto-generated for its responsive layout.

For complex tables (i.e., including colspan or rowspan attributes), or to customize or override individual table cell headings on mobile devices, use a data-label attribute on the <td> elements to label them.

<rh-table>
  <table>
    <caption>
      Concerts
    </caption>
    <colgroup>
      <col>
      <col>
      <col>
    </colgroup>
    <thead>
      <tr>
        <th id="concerts-date" scope="col">Date</th>
        <th id="concerts-event" scope="col">Event<rh-sort-button></rh-sort-button></th>
        <th id="concerts-venue" scope="col">Venue<rh-sort-button></rh-sort-button></th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td headers="concerts-date">12 February</td>
        <td headers="concerts-event">Waltz with Strauss</td>
        <td headers="concerts-venue">Main Hall</td>
      </tr>
      <tr>
        <td headers="concerts-date">24 March</td>
        <td headers="concerts-event">The Obelisks</td>
        <td headers="concerts-venue">West Wing</td>
      </tr>
      <tr>
        <td headers="concerts-date" data-label="Custom heading 1">14 April</td>
        <td headers="concerts-event" data-label="Custom heading 2">The What</td>
        <td headers="concerts-venue" data-label="Custom heading 3">Main Hall</td>
      </tr>
    </tbody>
  </table>
  <small slot="summary">Dates and venues subject to change.</small>
</rh-table>

Column highlighting

To enable column highlighting, the <table> element must also include a <col> element for each column in the table, typically wrapped with a <colgroup>.

<rh-table>
  <table>
    <caption>
      Concerts
    </caption>
    <colgroup>
      <col>
      <col>
      <col>
    </colgroup>
    <!-- ...table with three columns -->
  </table>
</rh-table>

Sorting

To enable sorting on a column, add an <rh-sort-button> as the last child of the <th> cell.

<rh-table>
  <table>
    <caption>
      Concerts
    </caption>
    <colgroup>
      <col>
      <col>
      <col>
    </colgroup>
    <thead>
      <tr>
        <th id="concerts-date" scope="col">Date</th>
        <th id="concerts-event" scope="col">Event<rh-sort-button></rh-sort-button></th>
        <th id="concerts-venue" scope="col">Venue<rh-sort-button></rh-sort-button></th>
      </tr>
    </thead>
    <!-- ...table data sortable by Event and Venue -->
  </table>
</rh-table>

Summary

Additional information about the data in the table should be slotted into the summary slot after the table element.

<rh-table>
  <table>
    <caption>
      Concerts
    </caption>
    <colgroup>
      <col>
      <col>
      <col>
    </colgroup>
    <thead>
      <tr>
        <th id="concerts-date" scope="col">Date</th>
        <th id="concerts-event" scope="col">Event<rh-sort-button></rh-sort-button></th>
        <th id="concerts-venue" scope="col">Venue<rh-sort-button></rh-sort-button></th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td headers="concerts-date">12 February</td>
        <td headers="concerts-event">Waltz with Strauss</td>
        <td headers="concerts-venue">Main Hall</td>
      </tr>
      <tr>
        <td headers="concerts-date">24 March</td>
        <td headers="concerts-event">The Obelisks</td>
        <td headers="concerts-venue">West Wing</td>
      </tr>
      <tr>
        <td headers="concerts-date">14 April</td>
        <td headers="concerts-event">The What</td>
        <td headers="concerts-venue">Main Hall</td>
      </tr>
    </tbody>
  </table>
  <small slot="summary">Dates and venues subject to change.</small>
</rh-table>

rh-table

A table provides a container for displaying tabular data, allowing users to scan and compare information. Authors must include a <table> with <thead>, <tbody>, and scoped <th> for ARIA screen reader navigation. Should use <col> for column hover and <caption> for context. Tab and arrow keys scroll overflow. Avoid using tables for layout.

Slots 2

Slot Name Summary Description
[default]

Default slot for the table element

Expects a native HTML <table> element with semantic markup. Authors must include <thead>, <tbody>, and scoped <th> elements so that screen readers can navigate the table structure.
Note: [default] unnamed slots do not have a slot="name" attribute.

summary

Summary slot for table description

An optional description of the table data displayed below the table. The element links this content to the table via aria-describedby for screen reader users. Authors should use inline elements like <small>.

Attributes 0

None

Methods 0

None

Events 0

None

CSS Shadow Parts 1

Part Name Summary Description
container

The outer wrapper around the table and summary slots. Use to customize padding or background.

style. Uses --rh-border-width-sm width and --rh-color-border-subtle-on-light color tokens. Row hover background. Uses --rh-color-gray-40 token at 10% opacity for the light theme. Column hover background. Uses --rh-color-blue-50 token at 10% opacity for the light theme.

CSS Custom Properties 3

CSS Property Description Default
--rh-table-row-border

row border

var(--rh-border-width-sm, 1px) solid var(--rh-color-border-subtle-on-light, #c7c7c7)
--rh-table-row-background-hover-color

row hover background color

rgba(from var(--rh-color-gray-40, #a3a3a3) r g b / 0.1)
--rh-table-column-background-hover-color

column hover background color

rgba(from var(--rh-color-blue-50, #0066cc) r g b / 0.1)

Design Tokens 16

Token Description Copy
--rh-color-text-primary

Primary text color for table content

Full CSS Variable Permalink to this token
--rh-color-gray-50

Subtle icon

Full CSS Variable Permalink to this token
--rh-color-border-subtle
Full CSS Variable Permalink to this token
--rh-border-width-sm

1px border width; Example: Secondary CTA or Button

Full CSS Variable Permalink to this token
--rh-color-border-subtle-on-light

Subtle border color (light theme)

Full CSS Variable Permalink to this token
--rh-color-gray-40

Subtle icon (hover state)

Full CSS Variable Permalink to this token
--rh-color-white

Lightest surface (light theme) or primary text (dark theme)

Full CSS Variable Permalink to this token
--rh-color-blue-50

Label - Filled (Blue) accent color

Full CSS Variable Permalink to this token
--rh-color-blue-70

Alert - Info title text

Full CSS Variable Permalink to this token
--rh-space-xl

24px spacer

Full CSS Variable Permalink to this token
--rh-space-lg

16px spacer

Full CSS Variable Permalink to this token
--rh-color-text-secondary

Secondary text color for summary description

Full CSS Variable Permalink to this token
--rh-font-family-body-text

Body text font for summary

Body text font family

Full CSS Variable Permalink to this token
--rh-font-size-body-text-md

Medium body text size for summary

16px font size

Full CSS Variable Permalink to this token
--rh-font-weight-body-text-regular

Regular weight for summary text

Regular font weight

Full CSS Variable Permalink to this token
--rh-line-height-body-text

Body text line height for summary

Line height for body text

Full CSS Variable Permalink to this token

rh-sort-button

A button for sorting table columns in ascending or descending order. Authors must place this element inside a <th> cell within an <rh-table> element. The button provides a screen reader accessible label announcing the current sort direction and column name. Authors should set the column attribute to identify the sorted column for assistive technology users.

Slots 1

Slot Name Summary Description
accessible-label

Must not use unless localizing the table. Automatically set based on sort-direction. Overrides the accessible-label attribute.

Attributes 3

Attribute DOM Property Description Type Default
sort-direction sortDirection

The button's sorting order

'asc' | 'desc'
unknown
accessible-label accessibleLabel

Automatically set based on sort-direction. Use this attribute or the accessible-label slot when localizing a table, but be certain to update the text based on sort direction whenever it changes.

string
unknown
column column

The column name associated with this button (for screen readers)

string
unknown

Methods 1

Method Name Description
sort()

Dispatch a request-sort event in ascending (asc) or descending (desc) order

Events 1

Event Name Description
request-sort

Fired when the user activates the sort button. The event detail includes a direction property set to 'asc' or 'desc'. Cancelling this event prevents the default sort behavior.

CSS Shadow Parts 2

Part Name Summary Description
sort-button

The native button element. Use to customize the sort button appearance.

sort-indicator

The wrapper around the sort direction SVG icon.

CSS Custom Properties 0

None

Design Tokens 1

Token Description Copy
--rh-color-text-primary

Primary text color for the sort button

Full CSS Variable Permalink to this token
© 2026 Red Hat Deploys by Netlify