diff --git a/config/postcss.config.js b/config/postcss.config.js
index 2a1a1eae7..dc0b756cc 100644
--- a/config/postcss.config.js
+++ b/config/postcss.config.js
@@ -56,6 +56,8 @@ const purgecss = purgeCSSPlugin({
// would therefore lose the rule, leaving the wrapped column's cells on `d-none` alone and so
// hidden at every width.
/^d-(sm|md|lg|xl|xxl)-table-cell$/,
+ // Applied by assets/table.html only when caption-top=true
+ 'caption-top',
// SimpleDatatables search component
'search-data-table',
'search-input',
diff --git a/data/structures/table.yml b/data/structures/table.yml
index 7326922bd..6e3fc38d4 100644
--- a/data/structures/table.yml
+++ b/data/structures/table.yml
@@ -32,6 +32,18 @@ arguments:
wrap:
wrapper:
release: v2.0.0
+ caption:
+ comment: >-
+ Caption rendered as the table's `
` element, describing the
+ table's contents.
+ release: v3.3.0
+ caption-top:
+ type: bool
+ default: false
+ optional: true
+ comment: >-
+ Whether the caption renders above the table (Bootstrap `caption-top`).
+ release: v3.3.0
# deprecated arguments
paging:
type: bool
diff --git a/exampleSite/config/postcss.config.js b/exampleSite/config/postcss.config.js
index f8ca700d6..3aed30aa8 100644
--- a/exampleSite/config/postcss.config.js
+++ b/exampleSite/config/postcss.config.js
@@ -56,6 +56,8 @@ const purgecss = purgeCSSPlugin({
// would therefore lose the rule, leaving the wrapped column's cells on `d-none` alone and so
// hidden at every width.
/^d-(sm|md|lg|xl|xxl)-table-cell$/,
+ // Applied by assets/table.html only when caption-top=true
+ 'caption-top',
// SimpleDatatables search component
'search-data-table',
'search-input',
diff --git a/exampleSite/content/en/table-demo.md b/exampleSite/content/en/table-demo.md
index ececbfc62..3ed1dee83 100644
--- a/exampleSite/content/en/table-demo.md
+++ b/exampleSite/content/en/table-demo.md
@@ -60,3 +60,13 @@ modules: ["simple-datatables"]
| charlie | widget | The third record. Short. |
| delta | gadget | The fourth record, whose description runs on for a little while. |
{{< /table >}}
+
+## Table with caption
+
+{{< table caption="Overview of records" class="fixture-caption" >}}
+
+| Name | Type | Description |
+|-------|--------|--------------------|
+| alpha | widget | The first record. |
+| bravo | gadget | The second record. |
+{{< /table >}}
diff --git a/exampleSite/hugo_stats.json b/exampleSite/hugo_stats.json
index 0a5e705bb..45e4ffaff 100644
--- a/exampleSite/hugo_stats.json
+++ b/exampleSite/hugo_stats.json
@@ -6,6 +6,7 @@
"blockquote",
"body",
"button",
+ "caption",
"code",
"dialog",
"div",
@@ -419,6 +420,7 @@
"file-controls",
"file-panel",
"fixed-top",
+ "fixture-caption",
"fixture-data",
"fixture-filter",
"fixture-filter-wrap",
@@ -1255,6 +1257,7 @@
"mindmap",
"minimal",
"minimal-cards",
+ "minimal-nav-no-parent-args-single-item",
"modal-search",
"mode-switcher",
"more-type",
@@ -1490,6 +1493,7 @@
"tab-list",
"table",
"table-demo",
+ "table-with-caption",
"table-wrapping",
"tablet-preview",
"tabs",
diff --git a/layouts/_partials/assets/table.html b/layouts/_partials/assets/table.html
index a1d7727a6..099a7d86b 100644
--- a/layouts/_partials/assets/table.html
+++ b/layouts/_partials/assets/table.html
@@ -47,6 +47,7 @@
caller's class list. The template adds it back below when the wrap genuinely applies. */}}
{{ $class := delimit (complement (slice "table-wrap") (split (or $args.class "") " ")) " " }}
{{ if $dataTable }}{{ $class = trim (printf "%s data-table" $class) " " }}{{ end }}
+{{ if and $args.caption $args.captionTop }}{{ $class = trim (printf "%s caption-top" $class) " " }}{{ end }}
{{ $attributes := "" }}
{{ if $args.sortable }}{{ $attributes = printf "%s data-table-sortable=true" $attributes }}{{ end }}
@@ -103,6 +104,13 @@
{{ $new := printf `" $rendered) 1 }}
+ {{ end }}
+
{{ $wrapper := $args.wrapper | default "" }}
{{ if $filter }}
diff --git a/layouts/_shortcodes/table.html b/layouts/_shortcodes/table.html
index 19a8ee045..0430fb9fa 100644
--- a/layouts/_shortcodes/table.html
+++ b/layouts/_shortcodes/table.html
@@ -73,6 +73,8 @@
"filter-col" $args.filterCol
"wrap" $args.wrap
"wrapper" $args.wrapper
+ "caption" $args.caption
+ "caption-top" $args.captionTop
"_default" $args.default
) }}
{{ end }}
\ No newline at end of file