shadcn.io is not affiliated with official shadcn/ui
Sign-In Gate Dialog Block for React
A paid newsletter page with its sign-in dialog shown open: email and password with a show and hide button, a remember box, a reset link, two provider rows, and a page that lifts its blur once you are in.
Installation
Overview
Gate members-only pages behind a clear sign-in, with this sign-in dialog for React with Base UI. It opens from the essay page of Inkvale, a paid weekly newsletter reader: the page's header holds an outline Sign in Button, and the page itself is drawn under a soft scrim inside a hairline frame with a plus mark on each corner, its first paragraphs in the clear and the rest blurred behind a "Members only" row. The dialog holds an email Input and a Password Input with a show and hide button, each in a Field that names its problem under itself and takes focus, a Checkbox for "Remember me on this browser", a "Forgot password?" link, two outline provider rows with a two-letter tile and the provider's name, and Sign in, the only Shine Button. Here any valid email with a password of 8 or more characters gets in, the hint says so, and the page behind lifts its blur and reads "Reading as" the address, with an initials avatar in its top bar. For preview the dialog is drawn open in place when the page loads; the Sign in button opens the real Dialog, with the same fields and the same state. For paywalls, member areas, shared documents and any app with a sign-in.
FAQ
Why is the dialog already open, and what do I keep?
So you can see it without a click. On load the dialog is a copy drawn in place over the page: a native dialog element that isn't modal, so nothing is trapped, hidden or focused, and the page around the preview keeps working. The Sign in button opens the real Dialog, modal, with its focus trap, Escape and focus return, and the copy stays closed until a reload. Both show the same LoginFields component and share the block's state, so an address typed in the copy is there in the real one. In your app keep the Dialog and drop the copy: the "in-place" state, the scrim and the dialog element inside the frame.
How are the fields checked?
When you press Sign in. An empty email asks for an address, one without an at sign and a dot asks for a full address, an empty password asks for it, and a password under 8 characters says how many it needs. Each problem sits under its own field in a slot that is always there, so the dialog never moves, and the first field with a problem takes focus. The 8 characters are this demo's rule, written once as MIN_PASSWORD: your server decides what really signs a person in.
What stays local, and how do I wire it for real?
Nothing signs in. A valid email and password only set a local reader, which lifts the blur on the drawn page, changes its lock row and puts an initials avatar in its top bar; the header's button becomes Sign out, which puts the blur back. "Remember me" stores nothing. In your app, post the address and password to your sign-in endpoint in signIn, set the session in a cookie on the server (never keep the password in state longer than the request), show the server's reason under the field on a refusal and keep the dialog open.
What do the provider rows do?
They say they aren't connected: pressing one swaps the word "or" between the form and the rows for "Google isn't connected in this demo" and the polite status says it too. The tile holds two typed letters, not a logo. In your app a row starts your OAuth redirect, and the tile is an icon slot for the provider's own mark, used under its brand terms.
Can a password manager fill it?
Yes. The email field is autocomplete="username" with a real email type and the password field is current-password, so managers recognise the pair. The eye button is a real button you can reach by keyboard: Enter or Space shows or hides the password, and Enter in either field submits.
Is it accessible from the keyboard?
Yes. The real dialog is named by its title and described by its sentence, focus starts in the email field and stays inside until it closes, and Escape, Cancel and the close button all return focus to the Sign in button. The trigger is passed to DialogTrigger through render, and the dialog is controlled with open and onOpenChange. The copy shown on load moves no focus; Escape inside it, Cancel and its close button close it and put focus on Sign in. One polite status message reports each result.
How does it look on a phone?
The copy shown on load docks to the foot of the page as a bottom sheet, its actions pinned at the bottom with Sign in on top, and the fields scroll above them; the provider rows stack. The real dialog keeps the Dialog's own phone layout: a sheet stuck to the bottom of the screen.
Related
- 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
Age-Aware Sign-Up Dialog
Account and securityA recipe community page with its sign-up dialog shown open: a rail of promises, name, email, password and date of birth fields, the terms, and a button that changes with the age worked out from the date.
- Pro
Two-Step Setup Dialog
Account and securityA cloud editor's security page with a three-step dialog shown open: a QR code and its key, eight backup codes to copy or download, and a six-digit check, ending in a note that two-step sign-in is on.
- Pro
Session Timeout Dialog
Status and errorsA bank's accounts page with an alert dialog shown open that warns before an idle session ends: a one-minute clock with a draining bar, Stay signed in and Sign out now, and a signed-out view at zero.
- Pro
Auth Buttons Navbar
Accounts and scopesA navbar with a working sign-in flow: Sign in and Sign up open a small dialog, continuing swaps the buttons for an avatar menu and Sign out swaps them back, with the same two states in the phone sheet.
- Pro
Add Profile Dialog
Account and securityA newsletter's writers page with its byline composer shown open: a name, what they write, a 120 character bio, a mark from six drawn glyphs or initials and a switch, beside a card that shows the byline as it will print.