Back to Snippets

Advanced Data Grid Table UI JS

A team members table with a search field, an add button, per row checkboxes and a theme switch. It is a real table element, so it stays readable to screen readers and pastes cleanly into a spreadsheet.

The header checkbox sets every row checkbox to match itself. Ticking rows one at a time walks the whole set and only leaves the header checked when all of them are, so the header never claims a state the rows below do not have.

Theming is a token swap. Every color is a CSS custom property, and a dark class on the body redefines that block, so one class flips the whole table and the toggle stays three lines of JavaScript. The table sits in a wrapper with overflow-x auto, so narrow screens scroll it sideways instead of crushing the columns. Search and sorting are not wired up yet, so treat the input as presentation for now.

209
#javascript
#css
#table
#data grid
#dashboard
#ui
#dark mode
#responsive
#saas