Docs
Table
Overview
Important
Bootstrap styling attributes require an explicit class argument as of release v0.22.0 . For example, use the following argument to accentuate a table with table-striped:
class="table-striped".
Responsive Table
Use the table shortcode to make your markdown table responsive. Responsive tables scroll horizontally to improve the layout on smaller screens. The following example illustrates how this works.
| # | Heading | Heading | Heading | Heading | Heading | Heading | Heading | Heading | Heading |
|---|---|---|---|---|---|---|---|---|---|
| 1. | cell | cell | cell | cell | cell | cell | cell | cell | cell |
| 2. | cell | cell | cell | cell | cell | cell | cell | cell | cell |
| 3. | cell | cell | cell | cell | cell | cell | cell | cell | cell |
{{< table >}}
| # | Heading | Heading | Heading | Heading | Heading | Heading | Heading | Heading | Heading |
|----|---------|---------|---------|---------|---------|---------|---------|---------|---------|
| 1. | cell | cell | cell | cell | cell | cell | cell | cell | cell |
| 2. | cell | cell | cell | cell | cell | cell | cell | cell | cell |
| 3. | cell | cell | cell | cell | cell | cell | cell | cell | cell |
{{< /table >}}Table Wrapping
Set wrap=true to wrap the last column around on smaller viewports.
| # | Heading | Heading | Wrapped |
|---|---|---|---|
| 1. | cell | cell | Lorem ipsum dolor sit amet, consectetur adipiscing elit. |
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
|||
| 2. | cell | cell | Nunc pretium, diam non euismod tincidunt, odio libero feugiat ligula. |
|
Nunc pretium, diam non euismod tincidunt, odio libero feugiat ligula.
|
|||
| 3. | cell | cell | Cras eu odio sit amet lectus efficitur accumsan. |
|
Cras eu odio sit amet lectus efficitur accumsan.
|
|||
{{< table wrap=true >}}
| # | Heading | Heading | Wrapped |
|----|---------|---------|-----------------------------------------------------------------------|
| 1. | cell | cell | Lorem ipsum dolor sit amet, consectetur adipiscing elit. |
| 2. | cell | cell | Nunc pretium, diam non euismod tincidunt, odio libero feugiat ligula. |
| 3. | cell | cell | Cras eu odio sit amet lectus efficitur accumsan. |
{{< /table >}}Data Table
Include the module simple-datatables to add advanced controls to your table. Features include in-line pagination, search, and sorting. Include the module in the frontmatter of your content page:
---
modules: ["simple-datatables"]
---As an example, the following shortcode displays a responsive table that is searchable, sortable, and enables paging (paginate) with a page size (pagination) of 5.
| # | Heading |
|---|---|
| 1. | Item 1 |
| 2. | Item 2 |
| 3. | Item 3 |
| 4. | Item 4 |
| 5. | Item 5 |
| 6. | Item 6 |
| 7. | Item 7 |
| 8. | Item 8 |
| 9. | Item 9 |
| 10. | Item 10 |
| 11. | Item 11 |
| 12. | Item 12 |
| 13. | Item 13 |
| 14. | Item 14 |
| 15. | Item 15 |
{{< table searchable="true" sortable="true" paginate="true" pagination=5 >}}
| # | Heading |
|-----|---------|
| 1. | Item 1 |
| 2. | Item 2 |
| 3. | Item 3 |
| 4. | Item 4 |
| 5. | Item 5 |
| 6. | Item 6 |
| 7. | Item 7 |
| 8. | Item 8 |
| 9. | Item 9 |
| 10. | Item 10 |
| 11. | Item 11 |
| 12. | Item 12 |
| 13. | Item 13 |
| 14. | Item 14 |
| 15. | Item 15 |
{{< /table >}}Configuration
With
Simple Datatables
enabled, add the attribute data-table to the class of any Markdown table. The following arguments are supported:
| Argument | Default | Description |
|---|---|---|
data-table-sortable |
true |
Toggle the ability to sort the columns. |
data-table-paging |
true |
Whether paging is enabled for the table. |
data-table-paging-option-perPage |
10 |
Paging option: Sets the maximum number of rows to display on each page. Type: int |
data-table-paging-option-perPageSelect |
[5, 10, 20, 50, ["{{ T "tablePerPageSelectAll" }}", -1]] |
Paging option: Sets the per page options in the dropdown. i18n translation id for all: tablePerPageSelectAll. |
data-table-searchable |
true |
Toggle the ability to search the dataset. |
Styling
The file assets/scss/components/_table.scss defines the Hinode-specific styling of the table shortcode.
.datatable-container {
border-bottom: none if($enable-important-utilities, !important, null);
}
.datatable-bottom {
padding-top: 0 if($enable-important-utilities, !important, null);
}
.datatable-sorter {
padding-left: 0;
padding-right: 1rem;
}
// Bootstrap stripes every odd row. A wrapped table renders two rows per record - the data row
// and the row holding the wrapped last column - so `odd` would stripe every record instead of
// alternating. Recompute the stripes per record pair.
.table-wrap.table-striped {
> tbody > tr:nth-of-type(n) > * {
--bs-table-color-type: initial;
--bs-table-bg-type: initial;
}
> tbody > tr:nth-of-type(4n + 1) > * {
--bs-table-color-type: var(--bs-table-striped-color);
--bs-table-bg-type: var(--bs-table-striped-bg);
}
}
// A folded group holds the values of several columns in one cell, with their headings hidden. They
// are laid out rather than concatenated: the cells are merged verbatim, so without this the values
// would run together into one string ("DatabaselaunchShipped").
//
// Equal, left-aligned columns, so values line up down the table instead of drifting with their own
// widths - the alignment the hidden headings would otherwise have provided.
//
// The column count adapts rather than matching the folded column count. Four equal tracks across a
// 390px viewport are ~74px each, which is narrower than a label like "Warehouse" - and a rendered
// badge is wider than its bare text - so a fixed count breaks values mid-word. `auto-fit` keeps the
// tracks equal and drops to as many as fit, laying four values out 2x2 on a phone and 4-across when
// there is room. `min(100%, 7rem)` keeps a single-value group (a description) full width instead of
// forcing a 7rem minimum on a viewport narrower than that.
//
// This sits on a wrapper inside the cell, never on the cell itself: a `display` of grid or flex
// takes a `td` out of the table formatting context and `colspan` stops applying with it, leaving
// the folded row's stripe and border cut off part way across the table.
.table-wrap-group {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(min(100%, 7rem), 1fr));
// Values fill their track rather than being sized to content, so the column's own alignment
// still decides where the value sits. Left is simply what `text-align` already resolves to, so
// an unaligned table reads left-aligned without that being hard-coded here - and a column the
// author centred or right-aligned keeps that after folding.
place-items: center stretch;
gap: 0.25rem 0.5rem;
}
// A value wider than its track would otherwise spill into the next one and collide with it
// ("Warehouseplateau-1"). `min-width: 0` lets the track shrink below its content so the value wraps
// inside its own column instead; `anywhere` because these are single words often enough that
// `break-word` alone would leave the overflow in place.
.table-wrap-value {
min-width: 0;
overflow-wrap: anywhere;
}
@include media-breakpoint-down(#{$main-breakpoint}) {
// Below the breakpoint the data row and the row holding the wrapped column must read as a
// single record, so the data row drops its bottom border.
.table-border-bottom-wrap {
border-bottom-style: none !important;
}
// Here the second row of each pair is visible too, so it joins its record's stripe.
.table-wrap.table-striped > tbody > tr:nth-of-type(4n + 2) > * {
--bs-table-color-type: var(--bs-table-striped-color);
--bs-table-bg-type: var(--bs-table-striped-bg);
}
// `wrap-cols` renders a record across more than two rows, which moves the stripe. The pattern
// alternates per record, so a record of $rows rows has a period of 2 * $rows and the striped
// record occupies the first $rows of it. `nth-of-type` accepts no custom property, so the rule
// is emitted per row count rather than parameterised. These rules live inside the query because
// wrapping only applies below the breakpoint - above it the record is one row and Bootstrap's
// own striping is correct. Two rows keeps the pair of rules above; the loop starts at three.
@each $rows in (3, 4, 5, 6) {
$period: $rows * 2;
@for $i from 1 through $rows {
.table-wrap-#{$rows}.table-striped > tbody > tr:nth-of-type(#{$period}n + #{$i}) > * {
--bs-table-color-type: var(--bs-table-striped-color);
--bs-table-bg-type: var(--bs-table-striped-bg);
}
}
@for $i from ($rows + 1) through $period {
.table-wrap-#{$rows}.table-striped > tbody > tr:nth-of-type(#{$period}n + #{$i}) > * {
--bs-table-color-type: initial;
--bs-table-bg-type: initial;
}
}
}
}
@if $enable-dark-mode {
@include color-mode(dark) {
.table-striped, .table-striped-columns {
--bs-table-striped-bg: var(--bs-tertiary-bg);
--bs-table-striped-color: var(--bs-body-color);
}
.table-hover {
--bs-table-hover-bg: var(--bs-tertiary-bg);
--bs-table-striped-color: var(--bs-body-color);
}
.datatable-pagination-list-item {
&:hover,
&:focus,
&.datatable-active {
color: var(--bs-body-bg) !important;
}
}
}
}Arguments
The shortcode supports the following arguments:
| Name | Type | Required | Default | Comment |
|---|---|---|---|---|
| breakpoint | select | Breakpoint of the element. Supported values: [none, xs, sm, md, lg, xl, xxl]. |
||
|
Breakpoint of the element. Supported values: [
none, xs, sm, md, lg, xl, xxl].
|
||||
| caption | string |
v3.12.0
Caption rendered as the table’s <caption> element, describing the table’s contents. Supports inline Markdown. |
||
|
v3.12.0
Caption rendered as the table’s
<caption> element, describing the table’s contents. Supports inline Markdown.
|
||||
| caption-top | bool |
v3.12.0
Whether the caption renders above the table (Bootstrap caption-top). Requires caption. |
||
|
v3.12.0
Whether the caption renders above the table (Bootstrap
caption-top). Requires caption.
|
||||
| class | string | Class attributes of the element. It supports Bootstrap attributes to modify the styling of the element. | ||
|
Class attributes of the element. It supports Bootstrap attributes to modify the styling of the element.
|
||||
| filter | string, slice | Slice of category values used to render a filter button group above the element. Each value becomes a button label. An “All” button is always prepended. Uses the text content of the column at filter-col to match rows. | ||
|
Slice of category values used to render a filter button group above the element. Each value becomes a button label. An “All” button is always prepended. Uses the text content of the column at filter-col to match rows.
|
||||
| filter-col | int | 1 |
Zero-indexed column number whose text content is matched against the active filter value. Defaults to 1. Only used when filter is set. | |
|
Zero-indexed column number whose text content is matched against the active filter value. Defaults to 1. Only used when filter is set.
|
||||
| filter-responsive | bool |
v3.22.0
Whether the filter button group collapses into a dropdown below the site’s main breakpoint, for groups too wide to fit a narrow viewport. Defaults to false, so the button group renders at every width. Requires filter, and has no effect when the main breakpoint is xs. |
||
|
v3.22.0
Whether the filter button group collapses into a dropdown below the site’s main breakpoint, for groups too wide to fit a narrow viewport. Defaults to false, so the button group renders at every width. Requires
filter, and has no effect when the main breakpoint is xs.
|
||||
| justify | select | start |
v3.18.0
Horizontal alignment of the filter controls. Requires filter, which is the only element this argument positions — the table itself always spans the full width of its container. Supported values: [start, end, center, between, around, evenly]. |
|
|
v3.18.0
Horizontal alignment of the filter controls. Requires
filter, which is the only element this argument positions — the table itself always spans the full width of its container. Supported values: [start, end, center, between, around, evenly].
|
||||
| pagination-select | string |
v1.23.0
Sets the per page options in the dropdown. Must be an array of integers or arrays in the format [label (string), value (int)]. Requires paginate = true. It is recommended to configure values that are a multitude of the pagination value. |
||
|
v1.23.0
Sets the per page options in the dropdown. Must be an array of integers or arrays in the format [label (string), value (int)]. Requires
paginate = true. It is recommended to configure values that are a multitude of the pagination value.
|
||||
| paging | bool |
v0.24.13
v1.23.0
Use paginate instead. Whether paging is enabled for the table. |
||
| pagingOptionPageSelect | string |
v0.27.8
v1.23.0
Use pagination-select instead. Sets the per page options in the dropdown. Must be an array of integers or arrays in the format [label (string), value (int)]. Requires paginate = true. |
||
| pagingOptionPerPage | int |
v0.27.8
v1.23.0
Use pagination instead. Sets the maximum number of rows to display on each page. Requires paging = true. |
||
| searchable | bool | v0.24.13 Toggle the ability to search the dataset. | ||
|
v0.24.13
Toggle the ability to search the dataset.
|
||||
| sortable | bool | v0.24.13 Toggle the ability to sort the columns. | ||
|
v0.24.13
Toggle the ability to sort the columns.
|
||||
| wrap | bool | Toggle the last column to wrap to a new row on smaller devices. | ||
|
Toggle the last column to wrap to a new row on smaller devices.
|
||||
| wrap-cols | string |
v3.23.0
Comma-separated column count per rendered row when wrapping, summing to the table’s column count. Splits a record across more than two rows on small devices, for example “2,4,1”. Only the first group keeps one cell per column; later groups collapse into a single spanning cell. Requires wrap; an invalid list falls back to wrapping the last column only. |
||
|
v3.23.0
Comma-separated column count per rendered row when wrapping, summing to the table’s column count. Splits a record across more than two rows on small devices, for example “2,4,1”. Only the first group keeps one cell per column; later groups collapse into a single spanning cell. Requires
wrap; an invalid list falls back to wrapping the last column only.
|
||||
| wrapper | string |
v2.0.0
Class attribute of the element’s wrapper. It supports Bootstrap attributes to modify the styling of the element. Icons include the fa-wrapper and fa-fluid attributes by default. |
||
|
v2.0.0
Class attribute of the element’s wrapper. It supports Bootstrap attributes to modify the styling of the element. Icons include the
fa-wrapper and fa-fluid attributes by default.
|
||||