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

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

One HTML file. Save it and open it in any browser.Open full screen

Example: Ledgerline Orders, a sortable purchase-orders table for a billing dashboard.

  • Type in the search box (or press /) to filter 64 sample orders live. Press Esc to clear it.
  • Click a column header to sort it, and click again to reverse the order.
  • Use the status chips to narrow results, then click rows to select them.
  • The bulk bar shows the combined total. Try Mark as paid.
  • Search for something odd like "zebra" to see the empty state.
Written by AI from this prompt. Your results will vary.

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
How prompts are written and checked

Did this prompt work?

Keep exploring

More in Design