Table
Renders interactive sortable, filterable tables in the browser by writing a zero-dependency HTML file and opening it via Chrome DevTools.
Workflow
- Extract columns and rows — identify column names, value types (text, number, badge, rating, boolean, tag), and all row data from user context. See TEMPLATE.md for column type definitions.
- Map column types — assign a
typeto each column: text, number, badge, rating, boolean, or tag. See TEMPLATE.md for rendering rules per type. - Choose a unique filename — use
/tmp/table.htmlby default. If a file with that name already exists (check with Bashls /tmp/table.html), use a descriptive slug instead (e.g./tmp/genai-taxonomy.html,/tmp/db-comparison.html). Never silently overwrite an existing file with unrelated content. - Write the HTML file — write a complete self-contained file to the chosen path using the vanilla JS template. See TEMPLATE.md for the full template with sort and filter implementation.
- Render in browser — follow
_shared/chrome-devtools-render.mdto open the HTML file, wait for render, screenshot, and fix-and-reload if needed.wait_forthe text of the first column header. See TROUBLESHOOTING.md for table-specific fixes.
Self-review checklist
Before delivering, verify ALL:
- Screenshot shows all columns with readable headers and all rows with populated cells
- Sort works: clicking a column header changes row order and shows a ▲ or ▼ indicator
- Filter works: search input above the table is present with
placeholder="Filter..." - Dark background (#1e1e2e) is applied — not white or gray
- No horizontal scroll is visible when the table fits the viewport
- Sticky header (
position: sticky; top: 0) is present in the CSS - All CSS color values use
var(--token)references — no hardcoded hex in element styles -
wait_forwas called beforetake_screenshot - Rating cells render as star characters (e.g. ⭐⭐⭐), not raw numbers
- Boolean cells render as ✓ or ✗, not true/false
Golden rules
Hard rules. Never violate these.
- Always define colors as CSS variables on
:root. Never write a hex color value directly into an element style. Every color used must reference avar(--token). - Always include both sort AND filter. A table missing either feature is incomplete. Both must be present in every output, even for small datasets.
- Never use an external library. Implement sort and filter in plain JS. The complete implementation is under 50 lines. See TEMPLATE.md.
- Always use
position: sticky; top: 0onthead. Apply this to every table regardless of row count. - Always call
wait_forbeforetake_screenshot. Wait on the first column header text string. Never screenshot immediately afternew_page. - Always use
overflow-x: autoon the table container. Without it, wide tables break the page layout. - Always
.toLowerCase()both sides in the filter comparison. Case-sensitive filtering breaks on mixed-case data.
Reference files
| File | Contents |
|---|---|
| TEMPLATE.md | Complete vanilla JS HTML template with full sort and filter implementation, CSS design tokens, column type rendering rules |
| TROUBLESHOOTING.md | Failure diagnosis table: symptoms, likely causes, and fixes |