Vanilla Breeze v0.7.4

Vanilla Breeze v0.7.4 released

0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…

Read the release notes

tr

The tr element defines a row of cells in a table. Vanilla Breeze adds data attributes for row states like selection, highlighting, and expandable detail rows.

Description

The <tr> (table row) element is a container for a horizontal group of cells. Each row must contain at least one <th> or <td> element, and all rows in a table should have the same number of cells (accounting for colspan).

Vanilla Breeze applies hover effects to rows within <tbody> and provides data attributes for common row states: selection, highlighting, disabling, and expandable detail rows.

When to Use

  • Every table row: All rows of data, headers, and footers require tr elements
  • Grouping cells: Each horizontal set of related data goes in one row
  • Header rows: In <thead>, rows typically contain <th> elements
  • Data rows: In <tbody>, rows typically contain <td> elements (with optional <th scope="row">)

Examples

Basic Table Rows

Rows contain cells that align with the table's column structure. Hover over rows to see the built-in highlight effect.

Row States

Vanilla Breeze provides data attributes for common row states. Selected and highlighted rows get a tint and a bar on the row's inline-start edge, so the state is not carried by colour alone; in forced-colors mode they switch to system colours (Highlight, Mark) with a real border. The attributes are visual only. They add no semantics, so pair each state with visible text or a control, as the demo's Status column does.

Row Hover Effect

Rows in <tbody> receive a hover effect automatically to help users track data across columns. This is applied by default in Vanilla Breeze and requires no additional attributes.

Selectable Rows

In an authored table, mark the selected row with data-selected. <data-table> manages selection itself: rows with data-selectable get a checkbox, and the component writes data-state-selected on the selected rows. VB styles both attributes identically, so the two can be mixed. The checkbox (or visible "Selected" text in a static table) is the accessible cue; aria-selected is not valid on plain table rows.

Disabled Rows

data-disabled only changes the look: the row's text switches to the muted text colour (not reduced opacity, which would drop below AA contrast). To actually disable the row, add the native inert attribute as well. It takes every link and button in the row out of the tab order, blocks pointer input, and hides the row's controls from assistive technology. VB styles tr[inert] the same as tr[data-disabled].

Expandable Rows

Expandable rows are a <data-table> feature. Put data-expandable on the trigger row with a toggle button (data-action="toggle-expand", with an accessible name), and follow it with a detail row marked data-expand-content and hidden. When the user expands it, the component puts data-state-expanded on the trigger row, removes hidden from the detail row, and keeps aria-expanded on the button in sync. The detail row usually spans all columns with colspan; VB pads whatever element you put inside its cell.

VB Data Attributes

Attribute Purpose Applied To
data-selected Marks a row as selected (interactive tint + inline-start bar). <data-table> writes data-state-selected, styled the same <tr> in <tbody>
data-disabled Mutes the row's text colour. Visual only: add inert to disable it <tr> in <tbody>
data-highlight Warning tint + inline-start bar <tr> in <tbody>
data-selectable In <data-table>: the row gets a selection checkbox <tr> in <tbody>
data-expandable Marks a row as having an expandable detail row (in <data-table>) Trigger <tr>
data-state-expanded Written by <data-table> while the detail row is open; raised background, rotated toggle Trigger <tr>
data-expand-content The detail row; starts hidden, raised background, padded content Detail <tr> after the trigger
data-state-hidden Written by <data-table> on rows filtered or paged out (display: none) Any body <tr>

CSS Reference

Valid Parent Elements

The <tr> element must be a child of one of these elements:

Parent Purpose Typical Content
<thead> Header rows <th scope="col"> cells
<tbody> Data rows <td> and optional <th scope="row">
<tfoot> Footer/summary rows <td> cells with totals/summaries

Accessibility

  • Consistent cell count: All rows should have the same number of cells (accounting for colspan)
  • Row headers: Use <th scope="row"> when the first cell identifies the row
  • Screen reader navigation: Users can navigate row by row through table data
  • Implicit role: <tr> has an implicit ARIA role of row
  • Disabled rows: data-disabled is visual only. Add inert so the row's controls can't be reached by keyboard or pointer
  • Selected and highlighted rows: the attributes carry no semantics and aria-selected is not valid on a plain table row. State it in the row itself: a checked checkbox (as <data-table> does) or visible text such as "Selected"
  • Not colour alone: selected and highlighted rows show an inline-start bar as well as a tint, and use system colours in forced-colors mode

Related

  • <th> - Header cells within rows
  • <td> - Data cells within rows
  • <thead> - Header row group
  • <tbody> - Body row group
  • <tfoot> - Footer row group
  • <table> - The table container
  • <data-table> - Interactive table component with built-in sorting, filtering, and row selection
  • inert - Pair with data-disabled to disable a row
↑