Skip to content

Striped and Hover Table Styles

Interactive Bootstrap 6 table style playground: toggle striped, hover, bordered, small and dark variants and copy the resulting table markup.

Also known as: table style variants, striped table, hover table, table playground, dark table variant

Bootstrap 6 Tables Responsive #dark #hover #responsive #striped #table

Striped and Hover Table Styles live demo

Open in new tab

Bootstrap 6 code (HTML, CSS, JS)

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 checked from an option's checkbox, and the matching class from the <table>, to change the starting combination.
  • Add another variant, such as table-striped-columns or table-borderless, as a new .sht-opt label with that name in data-sht-class.
  • --sht-roast and --sht-crema on .sht-root: change the button color and the score pill gradient.
  • --sht-page and --sht-ink (light) and their values in .sht-root--dark: set the page and text colors for each mode.
  • --sht-code-bg on .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.

Striped and Hover Table Styles at a glance

Framework
Bootstrap 6
Code
HTML, CSS, JavaScript
JavaScript
Vanilla JavaScript, no jQuery
Dependencies
Bootstrap 6, Bootstrap Icons
Layout
Responsive, works on mobile
Category
Tables
License
Free for personal and commercial use

Questions about this template

Can I use the Striped and Hover Table Styles code for free?

Yes. You can copy or download the code and use it in personal and commercial projects, including client work. No sign-up is needed. Reselling it as part of a component library or template collection is not allowed; see the license.

How do I add it to my website?

Load Bootstrap 6 and Bootstrap Icons from a CDN (the links are under Requirements). Paste the HTML where the component should appear, add the CSS to your stylesheet and load the JavaScript before the closing </body> tag. Download HTML gives you a complete page with everything already linked.

Does it need jQuery or a JavaScript framework?

No. The script is plain vanilla JavaScript, so it works without jQuery, React or Vue. You can still use the markup inside those frameworks.

Does it work on mobile?

Yes. The layout adapts to small screens. Use the Mobile and Tablet buttons above the live demo to check it at phone and tablet width.

Requirements

Add these to your page (already included in the download):

  • <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@6.0.0-alpha.1/dist/css/bootstrap.min.css">
  • <script type="module" src="https://cdn.jsdelivr.net/npm/bootstrap@6.0.0-alpha.1/dist/js/bootstrap.bundle.min.js"></script>
  • <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">

Built for Bootstrap 6.0.0-alpha.1. Bootstrap 6 ships as an ES module, so its script and this component's JavaScript load with type="module". Alpha releases can still change before the stable version.

Striped and Hover Table Styles – free Bootstrap 6 table template
Striped and Hover Table Styles · free Bootstrap 6 table template

More Tables

Table with Search Filter – free Bootstrap 5 table template

Table with Search Filter

Bootstrap 5 team directory table with live search, status filter, highlighted matches, result counter and empty state.

Sortable Data Table – free Tailwind CSS table template

Sortable Data Table

Tailwind CSS data table with clickable column headers that sort text, dates and numbers, with aria-sort, arrow indicators and a responsive scroll wrapper.

Users Table with Avatars – free Bootstrap 6 table template

Users Table with Avatars

Dark Bootstrap 6 team members table with photo avatars, presence dots, role badges, status, search, role filter and per-row action menus that stacks into cards on mobile.

Table with Checkbox Selection – free Bootstrap 6 table template

Table with Checkbox Selection

Bootstrap 6 orders table with row checkboxes, an indeterminate select-all box, Shift-click ranges and a bulk actions bar with export menu, delete and undo.

Table with Search and Pagination – free Bootstrap 6 table template

Table with Search and Pagination

Bootstrap 6 customer table with debounced live search and match highlighting, sortable columns with aria-sort, a rows-per-page select and smart pagination.

Responsive Table with Actions – free Bootstrap 6 table template

Responsive Table with Actions

Bootstrap 6 invoice table with status badges, per-row action Menus, a delete confirmation Dialog, Toast feedback and stacked cards on narrow screens.