An interactive Bootstrap 6 table style playground. Five toggle buttons switch the striped, hover, bordered, small and dark variants on a sample coffee menu table. A code bar below always shows the exact markup for the current combination, with a Copy button. Use it as a style reference in docs or a design system page, or copy the table and keep only the classes you need.
How it works
The table is a regular <table class="table table-striped table-hover sht-table"> inside a .table-responsive.table-card wrapper, which rounds the corners and lets wide tables scroll sideways on phones. Row headers use <th scope="row">, and the caption sits below the table with caption-side: bottom.
The options are Bootstrap 6 toggle buttons: each is a <label class="btn-check btn-outline theme-primary"> with a checkbox inside, grouped in a .btn-toolbar. Four checkboxes carry a data-sht-class attribute (table-striped, table-hover, table-bordered, table-sm). On every change, apply() toggles that class on the table.
The fifth checkbox has data-sht-theme="dark". In Bootstrap 6 there is no table-dark class, so dark tables come from the color mode. The script sets data-bs-theme="dark" on the .sht-stage wrapper, and all table tokens switch through light-dark(). .sht-root--dark also darkens the page behind it, so the dark table is shown in context.
snippet() builds the markup string, including the data-bs-theme wrapper when Dark is on, and writes it into .sht-code. The Copy button uses navigator.clipboard.writeText(). If the clipboard is blocked, for example in a sandboxed iframe, the code is selected instead so Ctrl+C works.
Customization
- Remove
checkedfrom an option's checkbox, and the matching class from the<table>, to change the starting combination. - Add another variant, such as
table-striped-columnsortable-borderless, as a new.sht-optlabel with that name indata-sht-class. --sht-roastand--sht-cremaon.sht-root: change the button color and the score pill gradient.--sht-pageand--sht-ink(light) and their values in.sht-root--dark: set the page and text colors for each mode.--sht-code-bgon.sht-root: changes the code bar background.- To use a plain static table, delete the toolbar, the code box and
script.js. The classes on the<table>are all you need.
Use cases
- Documentation pages: toggle striped, hover, bordered, small and dark styles to compare them
- Design decisions: preview which table variant suits your layout before you build
- Learning projects: copy the resulting table markup straight into your page
- Component libraries: one interactive demo replaces several static table examples
Accessibility
Each toggle is a real checkbox inside its label, so Space toggles it and screen readers announce "checked" or "not checked". The group has aria-label="Table style options", and focused toggles show an outline. The table has a visible caption, column headers with scope="col" and row headers with scope="row". The copy result is announced through a visually hidden aria-live region. The page color change is not animated under prefers-reduced-motion.
Bootstrap 6 notes
Table classes such as table-striped, table-hover, table-bordered and table-sm are the same as in Bootstrap 5. table-dark is gone: use data-bs-theme="dark" on the table or a wrapper. Toggle buttons now put the input inside a .btn-check label, and btn-outline-primary becomes btn-outline theme-primary. .table-card is new. Built on Bootstrap 6.0.0-alpha.1, so APIs can still change. Icons come from Bootstrap Icons.