Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Session Expired Login Block for React

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 Base UI. 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.

  • Pro

    Session Expired Error

    Sign-in and identity

    A 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

    Session Timeout Dialog

    Status and errors

    A 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

    Welcome Back Login

    Account choosers

    A full-height returning-user sign-in for a reading tracker: a large initials avatar, Welcome back, Dara, a read-only address and one password field, with a swap to a different account at the same height.

  • Pro

    Session Limit Login

    Sessions and devices

    A sign-in gate for a video streaming service: a meter of screens in use, three sessions as radio rows, and one button that ends the chosen session so this browser can continue.

  • Pro

    Forgot Password Login

    Recovery and reset

    A forgot-password page for a school learning platform that never says whether an account exists, offers the right mail domain when one is a letter off, and resends the link on a 30-second wait.

  • Pro

    A panel of trusted devices for a smart-home app: each has a trust-expiry meter, Forget asks in an alert dialog, Undo brings the last one back and a Shine Button trusts this browser for 30 days.