Dark Mode & Theming
TableCrafter ships with automatic high-contrast and reduced-motion theming driven by OS preferences, plus a dark-aware loading skeleton. There is no full dark table theme out of the box, but every visual surface is a plain CSS class you can override to build one.
What TableCrafter does automatically
Theming in TableCrafter is preference-driven, not attribute-driven. When a table initializes, the script inspects the visitor's operating-system settings and applies matching classes to the table container. There is nothing to configure in the shortcode for this to work.
- Dark loading skeleton — the shimmer placeholder shown while data loads switches to dark gray tones under
@media (prefers-color-scheme: dark). - High-contrast theme — if the OS reports
prefers-contrast: high, thetc-high-contrastclass is added and a small set of CSS variables takes over colors. - Reduced motion — if the OS reports
prefers-reduced-motion: reduce, thetc-reduced-motionclass is added and animations/transitions are effectively disabled.
Be honest about scope: prefers-color-scheme: dark only restyles the loading skeleton. The rendered table (headers, rows, badges, links, pagination) keeps its light palette in dark mode unless you add your own CSS. A full dark table is a theming task, covered below.
There is no theme or dark shortcode attribute
The [tablecrafter] shortcode has no color, theme, skin, or class attribute. Its real attributes are data and behavior oriented:
| Attribute | Purpose | Required |
|---|---|---|
| source | URL of the CSV / Google Sheet / JSON data source. | Required |
| id | Custom DOM id for the container (auto-generated if omitted). | Optional |
| search | Enable the global search box. | Optional |
| filters | Enable per-column filters. | Optional |
| export | Enable the export toolbar. | Optional |
| per_page | Rows per page. | Optional |
| sort | Initial sort as column:direction. | Optional |
To theme a table you target it by its id (set one with the id attribute) or by the container class, then write CSS. The shortcode itself stays focused on data.
// Give the table a stable id you can target in CSS
[tablecrafter source="https://example.com/data.csv" id="pricing-table" search="true" export="true"]
The container classes you target
Two wrapper classes exist depending on how the table is rendered. Both are stable hooks for your CSS.
| Class | Where it appears |
|---|---|
| .tablecrafter-container | Outer server-rendered wrapper emitted by the shortcode (carries the id and all data-* config). |
| .tc-wrapper | Inner client-rendered wrapper; receives tc-high-contrast / tc-reduced-motion at runtime. |
High-contrast theming via CSS variables
The one place TableCrafter exposes CSS custom properties is the high-contrast theme. When tc-high-contrast is active, four variables are defined on the wrapper and consumed across the table. These are the only theming variables in the plugin.
| Variable | Default | Applies to |
|---|---|---|
| --tc-border-color | #000000 | Table, header, and cell borders. |
| --tc-text-color | #000000 | Header and cell text. |
| --tc-bg-color | #ffffff | Header and cell background. |
| --tc-focus-color | #ff0000 | Focus outline color for keyboard navigation. |
Because these variables are scoped to .tc-high-contrast, you can redefine them in your theme to recolor the high-contrast experience without touching the plugin:
/* Recolor the high-contrast theme (only active when the OS
reports prefers-contrast: high) */
.tc-wrapper.tc-high-contrast {
--tc-border-color: #0a0a0a;
--tc-text-color: #0a0a0a;
--tc-bg-color: #ffffff;
--tc-focus-color: #0044cc;
}
High-contrast styles use !important so they override base colors reliably. If you want a high-contrast dark look, set --tc-bg-color to a dark value and --tc-text-color to a light one inside the .tc-high-contrast block.
Building a full dark table yourself
For a true dark theme across the whole table, wrap your overrides in @media (prefers-color-scheme: dark) and restyle the real classes. None of these are variables, so you set colors directly. The classes below are all present in the rendered markup:
| Class | Element |
|---|---|
| .tc-table-container | Scroll container with border and radius. |
| .tc-table | The table element. |
| .tc-table th | Header cells (sticky). |
| .tc-table td | Body cells. |
| .tc-sortable | Sortable header cells. |
| .tc-link | Auto-rendered email/URL links. |
| .tc-badge / .tc-badge-success / .tc-badge-error | Boolean cell badges. |
| .tc-pagination | Pager controls. |
@media (prefers-color-scheme: dark) {
#pricing-table .tc-table-container {
background: #1f2430;
border-color: #374151;
}
#pricing-table .tc-table th {
background-color: #2a3142;
color: #e5e7eb;
}
#pricing-table .tc-table td {
color: #d1d5db;
border-bottom-color: #374151;
}
#pricing-table .tc-table tr:hover {
background-color: #2a3142;
}
#pricing-table .tc-link { color: #60a5fa; }
}
Scope dark rules to your table's id (here #pricing-table) so they don't bleed into other tables or your theme. Add the same overrides without the media query behind a manual class (e.g. a body class your theme's dark toggle sets) if you support a user-controlled dark switch instead of OS preference.
Reduced motion
When the OS requests reduced motion, TableCrafter adds tc-reduced-motion to the wrapper, which forces animation and transition durations to near-zero and disables smooth scrolling. This applies to the loading shimmer, sort transitions, and editable-cell highlights. You generally do not need to touch this, but you can extend it for custom animations you add:
.tc-wrapper.tc-reduced-motion .my-custom-anim {
animation: none !important;
}
Where to add your CSS
Because there is no theme picker in the admin, theming is done with CSS. Add your overrides in any of these standard WordPress locations:
- Appearance → Customize → Additional CSS for quick, site-wide rules.
- Your child theme's
style.cssfor version-controlled overrides. - A small plugin or
wp_enqueue_stylesnippet if you need the CSS to load alongside other functionality.
The TableCrafter admin screen itself lives under the TableCrafter top-level menu in wp-admin; it manages data sources and shortcodes, not colors.
The high-contrast and reduced-motion classes are toggled live: if a visitor changes their OS contrast or motion setting while the page is open, TableCrafter listens for the change and updates the table without a reload.
Summary
- Automatic, no-config: dark loading skeleton, high-contrast theme (4 CSS variables), reduced motion — all driven by OS preferences.
- No
theme/dark/classshortcode attribute — theming is done with CSS against stable.tc-classes. - The only CSS variables are
--tc-border-color,--tc-text-color,--tc-bg-color, and--tc-focus-color, scoped to.tc-high-contrast. - For a full dark table, override the real classes inside
@media (prefers-color-scheme: dark), scoped to your table'sid.
Next steps: see accessibility.html for the keyboard navigation and ARIA behavior that the high-contrast and reduced-motion themes build on, and shortcode-reference.html for the complete list of real [tablecrafter] attributes you can pair with your custom styling.