Skip to content

Table

The bq-table component renders data tables with sortable columns, striped rows, bordered cells, hover highlighting, and a loading state.

Basic Usage

html
<bq-table
  columns='[{"key":"name","label":"Name"},{"key":"email","label":"Email"}]'
  rows='[{"name":"Alice","email":"alice@example.com"},{"name":"Bob","email":"bob@example.com"}]'
></bq-table>

Sortable Columns

html
<bq-table
  columns='[{"key":"name","label":"Name","sortable":true},{"key":"age","label":"Age","sortable":true}]'
  rows='[{"name":"Alice","age":30},{"name":"Bob","age":25},{"name":"Carol","age":35}]'
  sort-key="name"
  sort-dir="asc"
></bq-table>

Striped & Bordered

html
<bq-table
  striped
  bordered
  columns='[{"key":"id","label":"ID"},{"key":"product","label":"Product"},{"key":"price","label":"Price"}]'
  rows='[{"id":1,"product":"Widget","price":"$9.99"},{"id":2,"product":"Gadget","price":"$19.99"},{"id":3,"product":"Doohickey","price":"$4.99"}]'
></bq-table>

Hover Highlight

html
<bq-table
  hover
  columns='[{"key":"name","label":"Name"},{"key":"role","label":"Role"}]'
  rows='[{"name":"Alice","role":"Admin"},{"name":"Bob","role":"Editor"}]'
></bq-table>

Loading State

html
<bq-table
  loading
  columns='[{"key":"name","label":"Name"},{"key":"status","label":"Status"}]'
  rows="[]"
></bq-table>

Properties

PropertyTypeDefaultDescription
columnsstring (JSON)JSON array of column definitions ({ key, label, sortable? })
rowsstring (JSON)JSON array of row data objects
captionstringAccessible table caption
sort-keystringKey of the currently sorted column
sort-dirasc | descCurrent sort direction
stripedbooleanfalseAlternates row background colors
borderedbooleanfalseAdds borders to cells
hoverbooleanfalseHighlights rows on hover
loadingbooleanfalseShows a loading indicator

Events

EventDetailDescription
bq-sort{ key: string, dir: string }Fired when a sortable column header is activated by click or keyboard (Enter/Space)

CSS Parts

PartDescription
tableThe table element
captionTable caption
theadTable header section
header-rowHeader row
thHeader cell
tbodyTable body section
rowBody row
tdBody cell

Accessibility

  • The component preserves native <table> semantics for rows, headers, and cells.
  • Sortable headers are keyboard-activatable with Enter and Space.
  • Loading and empty states use localized copy from the i18n layer.

Released under the MIT License.