Build a Sortable, Filterable Data Table with Pagination in One HTML File
A polished vanilla JavaScript orders table with column sorting, live search, status filters, row selection with bulk actions, pagination and an empty state, all in one HTML file.
You getone complete HTML file in a single code block, then 3 short ideas to extend it.
The prompt
Act as a senior front-end engineer and UI designer. Build "Ledgerline Orders", a purchase-orders data table for a small wholesale billing dashboard, as one self-contained page in vanilla JavaScript with no libraries. Generate 64 realistic sample records in code with a seeded random function: order ID, customer name and company, region, status (Paid, Pending, Overdue, Refunded), date and amount in US dollars.
Rules:
1. Sorting: every column header is a button. Clicking it toggles ascending and descending order, shows an arrow and sets aria-sort. The default sort is newest date first.
2. Filtering: a live search box matches ID, name, company, region and status as you type. Status chips show counts and narrow the results. Press / to focus search and Escape to clear it.
3. Selection: each row has a checkbox, and a header checkbox with an indeterminate state covers the current page. Clicking a row toggles it. A bulk bar shows the count, the combined total, and Mark as paid and Clear buttons.
4. Pagination: 10, 20 or 50 rows per page, Previous and Next buttons, numbered pages with ellipses, and a Showing 1–10 of 64 line.
5. Empty state: a friendly illustration, the search term and a button that resets every filter.
6. Design: system fonts, one blue accent, soft status badges, tabular numbers, horizontal scroll on narrow screens, visible focus rings and a polite live region announcing result counts.
Output format: one complete HTML file in a single code block, then 3 short ideas to extend it.Example output
Tips and common edits
Why this works
- Seeded sample data is generated in code, so the table looks real and stays the same on every load without any external files.
- A single state object (query, status, sort, page, size) feeds one render function, which keeps sorting, filtering and paging in sync.
- Naming exact accessibility details like aria-sort, the indeterminate checkbox and a live region gets usable keyboard and screen reader support on the first try.
Paste the prompt into ChatGPT, Claude or Gemini. Save the code it returns as an .html file and open it in any browser, or view it in the chat's preview or canvas panel. No setup or internet connection is needed.
Common edits
- Swap the dataset for your own domain, such as employees, invoices or inventory, by changing the name lists, columns and status labels.
- Add a CSV export button, inline row editing or a dark theme by asking for it in rule 6.
Prompt details
- By
- Prompts-GPT editors
- Published
Did this prompt work?
Keep exploring
More like this
Build an Analytics Dashboard with Sidebar, KPI Cards and SVG Charts in One HTML File
A responsive store analytics dashboard with a collapsible sidebar, four KPI cards with sparklines, and hand-drawn SVG line, donut and bar charts.
Build a Light/Dark Mode Toggle Demo Page with Smooth Theme Switching
A single HTML page with a polished light/dark theme switch built on CSS custom properties that defaults to the system theme, honors reduced motion, and uses no storage.
Build a Multi-Step Onboarding Wizard with Stepper and Inline Validation
A four-step onboarding wizard in one HTML file, with a clickable stepper, progress bar, inline validation, a review screen, and keyboard and swipe navigation.
Build a Playful Animated 404 Error Page with SVG Art and Site Search
A complete single-file 404 page with an original animated hot-air balloon SVG, a live-filtering search box and helpful recovery links that respect reduced motion.
Build a Responsive Navigation Bar With Mega Menu and Mobile Drawer in HTML
A complete single-file site header with a hover, click and arrow-key mega menu on desktop and an animated hamburger drawer with accordions on small screens.
Build a Responsive Three-Tier Pricing Section with Monthly/Yearly Toggle
A single HTML file with three pricing cards, a working billing switch that recalculates prices, a highlighted recommended plan and accessible feature checkmarks.
- Build a SaaS Landing Page Hero with a CSS-Drawn Product Mockup
- Build a Sticky-Header Plan Comparison Page with Swipeable Mobile Columns
- Build an Accessible Modal, Toast and Tooltip Showcase in One HTML File
- Build an Empty States and Loading Skeletons Gallery in One HTML File
- Build an Interactive Habit Tracker Mobile App Prototype in One HTML File
- Design an Accessible Settings Page with Toggles, Segmented Controls and Sliders