Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Session Expired Login Block for React Aria

A re-authentication page for a document editor that keeps the email read-only, asks only for the password, shows where you were, and confirms before switching account.

Framework
UI library

Preview

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Overview

Ask only for what is missing when a session ends, with this session expired login block for React with React Aria. It's the page Drafthurst, a document editor, shows after 30 minutes idle: the page's side rails run the full height and one band crosses it, with a centred column. The session ended at a fixed 14:11 UTC, so the page asks for the password only: the email is shown read-only, and a "Where you were" row keeps the draft and its 14 changes in view ("Draft: Q3 plan, 14 changes kept in this demo"). Switch account asks first, in an Alert Dialog that says what stays behind; confirming makes the email field editable, clears the note and swaps the words above, all without the page moving. It's built from Password Input, Input, Alert Dialog, Field, Button, Shine Button and Guides, with a CSS entrance only. For re-authentication after a timeout, and where keeping someone's place matters more than a fresh start.

FAQ

What stays in the page, and how do I wire it for real?

Everything. The account, the draft and its 14 changes are typed constants; any password signs in, and the result waits 700 milliseconds and says nothing was sent and no session was kept. In a product, keep the draft in your own storage tied to the account, not in the page, send the password to your auth endpoint, and return the person to the route they were on.

Why is the email shown but not editable?

Because the session belonged to that account, and asking for the email again only invites a typo. The field is a real read-only input with its label, in the same box as the editable one, so a screen reader reads the address and the field keeps its place. Switch account is the only way to change it.

What does Switch account do?

It opens an alert dialog first, because it clears the "Where you were" note: the dialog says the draft stays with the old account and the next one starts fresh. Focus starts on Stay signed out; Escape closes it too, and focus returns to Switch account. Confirming closes it, makes the email empty and editable, swaps the heading to "Sign in to Drafthurst" and puts focus in the email field. Use the saved account brings it back.

How does it keep the page from moving?

Every sentence that changes with the account (the heading, the line under it, the note) is laid over an unseen copy of its other state in one grid cell, so the longer of the two sets the size. The result also takes the form's place in the same cell, and the page is centred, so anything that grew would have moved the heading.

What if I press Sign in with an empty password?

The button is never disabled: it names the problem ("Enter your password.") under the field and in the status line and puts focus on the field. After Switch account the email is checked first, for both an empty and a malformed address.

Does the alert dialog work the same everywhere?

Yes on all seven targets: it is modal, takes focus on its Cancel button, closes on Escape and returns focus to the trigger. When it closes because you confirmed, the trigger is gone from view, so the page moves focus to the email field itself about 300 milliseconds later.