shadcn.io is not affiliated with official shadcn/ui
401 Unauthorized Error Block for React
A full-screen 401 page for a reporting workspace: the heading, where the visitor was going, Sign in, and a framed list of other ways in where Single sign-on and Email me a link turn their own row into an email field in place.
Installation
Overview
Send signed-out visitors to the right door, with this 401 error page for React with Base UI. It's the error screen of Briefroom, a reporting workspace: a whole screen with the page's rails and one band across it, split in two. At the start sit the status code as display text, the heading "Sign in to continue", one sentence that says the workspace doesn't know who you are yet, a chip with the path the visitor was heading for ("After signing in you'll return to /reports/q3/revenue-by-region") and the way forward: a Shine Button Sign in beside a quiet link to create an account. At the end a framed panel, ruled by Guides, lists four other ways in as equal Buttons: Continue with Google and Continue with GitHub, each with a two-letter tile, and Single sign-on and Email me a link, which turn their own row into an email Input with a Continue or Send button. The row keeps its height, so nothing on the page moves. It's built from Shine Button, Button, Input and Guides, with a CSS entrance only. For any app with signed-in areas.
FAQ
What do the other ways in do, and what stays in the page?
Nothing leaves the page. A provider row says, in a polite status line, that the provider's own sign-in page would open and that nothing opens here. The two email rows check what you typed (an empty field or an address that isn't whole names the problem and keeps focus in the field), then say what a real page would do: "Would redirect to your identity provider" or "A sign-in link would be emailed to you", put the row back and give it focus. To wire it for real, send Google and GitHub through your OAuth flow, look up the identity provider from the domain of the work email for single sign-on, and email a one-time link for the last row.
How does the page remember where the visitor was going?
It doesn't: the path is the constant RETURN_TO, fixed so the block reads the same everywhere. In your app, read the requested path on the server when you decide to show this page, carry it through your sign-in flow (a next or callbackUrl parameter) and check that it is a path on your own site before redirecting back, so the parameter can't be used to send people elsewhere.
Why do Single sign-on and Email me a link turn into fields instead of opening a section?
Because the page is centred in the screen, and anything that grew would move the heading. Pressing either row swaps its button for a field and a Continue button of the same height, moves focus into the field and says so in the status line. Escape puts the row back with focus on it, and choosing another row ends the edit; the address you typed stays for the next try.
Does this return a 401 status to browsers and clients?
No: a component can't. Send the real HTTP status from your server or framework, so monitors and API clients see a 401 and not a 200 with an error drawn on it. For pages in a browser it is common to redirect to your sign-in page instead; this screen is for products that show the gate in place.
Are those the real Google and GitHub marks?
No. Each row has two typed letters in a neutral square, with the provider's name in text beside them, and a code comment marks the slot where you can put the provider's own logo under its brand rules. The block never draws a brand mark of its own.
Where do Sign in and Create an account go?
Both are plain links to #: point them at your sign-in and sign-up routes. Sign in is a Shine Button with render set to an a element and nativeButton={false}. The code 401 is decoration and hidden from assistive technology; the sentence under the heading says "Error 401" in words.
Related
- 43Pro
403 Forbidden Error
Locked and removedA full-screen 403 page for a team wiki: a door drawn as the zero of 403, the heading 'Ask someone who can say yes', the three workspace admins in a framed list with a Copy email button each, and a way back to the wiki.
- Pro
Invalid Token Error
Sign-in and identityA full-screen invalid-token page for an identity API: three ruled checks (Format failed with the parts drawn, Signature and Expiry not checked), a masked fingerprint to copy, Sign in again, and a Report to security list of exactly what a report would attach.
- Pro
Session Expired Error
Sign-in and identityA full-screen session-ended page for a billing back office: a session ruler from 09:00 to 10:30 UTC with the active time solid and the idle gap hatched, a legend of when you signed in, were last active and were signed out, and a demo control that swaps the cause.
- Pro
Role Ladder Permission Denied Error
Locked and removedA full-screen permission page for a design-system manager: a role ladder of four rising steps with you at Viewer and Admin marked as needed, 'Two roles up' in words, and a Request access dialog that records a note and an owner in local state.
- Pro
Centered Sign In Login
Centered formA full-height sign-in page for a team chat app: the product's mark, Google and GitHub rows with lettermark tiles, an or rule, email and password checked on submit, and one Sign in button with a simulated wait and its result.
- Pro
Captcha Failed Error
Sign-in and identityA full-screen page for a human check that timed out: a box to tick that escalates to a typed question, with no picture to read, over four accordion rows that show what the check looked at and what to do.