shadcn.io is not affiliated with official shadcn/ui
Record Not Found Error Block for React
A split 404 page for an order desk: an inset frame that says what was asked for (the kind, the id and the result), and a lookup by kind and number over six typed records that finds the record or names the nearest number.
Installation
Overview
Say exactly what was missing, and offer a way to find it, with this record-not-found page for React with Base UI. It's the 404 of Tallybox, an order desk for small shops: the page's two side rails run its full height, and one band crosses the screen between two rules, split by a divider that meets both at a plus mark. The headline comes first in the page: the display "404", the heading, one sentence and an inset Frame that holds a Data List of what was asked for: the kind of record, its id and the result, not found. On a wide screen the lookup stands at the start: a Native Select for the kind (order, invoice or customer), a number in an Input inside a Field, and the Shine Button that looks it up, the only colored control. A hit shows the record with a link; a miss names the number and the nearest one. It's built from Frame, Data List, Native Select, Field, Input, Button, Shine Button and Guides, with a CSS entrance only. For dashboards and admin tools where records can be deleted or mistyped.
FAQ
What does the lookup search, and how does a miss work?
It searches six typed records, two orders, two invoices and two customers, by the number in what you type: "ord 12346", "ORD-12346" and "12346" all find the same order, and the kind you chose decides the prefix. A hit shows the record's number, its owner and a line about it, with an Open link. A miss says that number is not there and names the nearest record of the same kind, the lower one when two are as near, with a button that uses it: pressing "Use ORD-12346" fills the field and runs the lookup. Text with no digits in it is a problem under the field instead, since there is no number to look for.
What stays in the page, and how do I wire it for real?
The records are the typed ENTRIES at the top of the file and the lookup runs in the browser, so nothing is requested. To wire it, replace lookupOf with a request to your API for the kind and number, show the record it returns, and keep the miss message. The Open link and "back to all orders" point at # here: link them to the record's page and your orders list. Where the nearest number is a guess, leave it out if the number might belong to a record this person may not see.
Why is the Look up button never disabled?
A disabled button can't explain itself, and keyboard users can't reach it. Pressing it with the field empty, or with no digits in it, writes one sentence under the field and moves focus to it; typing clears the sentence. The line for the problem is always there, so one appearing never moves the page. Changing the kind clears the result and the problem.
Which status should a missing record return?
Return 404 for an id that was never there or that this person may not see, and 410 for one you know was deleted. The same page can serve both. Answer in the same way for records a visitor has no right to see, so the page doesn't reveal which ids exist. The id in the inset frame is typed here (ASKED_ID): in your app, read it from the address.
Why does the lookup come first on a wide screen but second in the page?
The page reads the headline, the facts and then the lookup, which is the order a screen reader and the keyboard follow, so the heading comes first. On a wide screen the grid places the lookup at the start and the message at the end; the markup order doesn't change. On a phone they stack in reading order.
Related
- Pro
404 With Ranked Results Error
Not foundA split 404 page for a developer blog host: the failed address in an editable field with its words as chips, and eight typed articles ranked by shared words with one letter of typo allowed, the matched words marked, re-ranking as you edit.
- Pro
404 With Address Guesses Error
Not foundA 404 page for a shipping dashboard that offers three guesses as radio rows, each showing its address with the changed part struck through or underlined and named in a word, and one button that opens the chosen guess.
- Pro
Search Command 404 Error
Not foundA full-height 404 page for a knitting-pattern library: the display 404, a heading that names the missing address, an inline command list in a framed panel that shows five popular pages and filters ten as you type, and one button to the homepage.
- Pro
Account Deleted Error
Locked and removedA full-screen page for someone who signs in to a deleted account: three facts on shared hairlines and two choice cells that spell out what recovering and starting fresh each mean, with a Shine Button that follows the choice.
- Pro
Removed Post Review Error
Locked and removedA page for a removed forum post: the post with its words under black bars except the phrase that broke a rule, underlined and named, then a field and one button to request a review that shows what a real review would do, and the case details.
- 404Pro
Animated Drop-In 404 Error
Not foundA full-height 404 page for a kids' language app where three digit tiles drop onto a rule one after the other with a small overshoot, in CSS only, and a button replays the drop.