Data Table
UI Coding
Medium
25 min
pagination
state
accessibility
tables
Build a DataTable that displays a list of users one page at a time.
The starter renders every user in a plain table. The data lives in users.js (23 users with id, name, age and occupation).
Requirements
- Show the columns ID, Name, Age, Occupation.
- Show 5 rows per page by default.
- A "Rows per page"
<select>offers 5, 10 and 20. Changing it goes back to page 1. - Previous page / Next page buttons move between pages. Previous is disabled on the first page and Next is disabled on the last page.
- Show a
Page X of Yindicator, e.g.Page 2 of 5. - Accessibility:
- Use semantic table markup (
<table>,<caption>,<thead>,<th scope="col">). - The select has a visible
<label>. - The arrow buttons have accessible names (
"Previous page","Next page"). - Screen-reader users hear the new page number when it changes.
- Use semantic table markup (
Follow-up
- What happens if the
usersprop shrinks while you're on the last page? - How would this change if the server paginated the data (
?page=2&limit=10)? - Add sorting and filtering (see Data Table II).
Spotted a mistake or a rights concern? Report an issue