shadcn.io is not affiliated with official shadcn/ui
Avatar Preview Login Block for React
A full-height sign-in page for a family organizer where a large avatar builds from the email as you type, a typed demo account shows its name, and Enter takes you to the password.
Installation
Overview
Show people who they are as they sign in, with this avatar preview login block for React with Base UI. It's the sign-in of Nestwick, a family organizer: the page's side rails run the full height of the screen and the band across it is itself the split. At the end, the product's mark, the heading and the form, a Field with an Input for the email, another with a Password Input and the Shine Button that signs in, the only colored control. At the start, a large Avatar builds from the address as it is typed: maya.alvarez@ gives "MA", and until there is a name it holds a neutral person glyph, with the typed address under it. Typing one of the two demo accounts shows its name too, and Enter in the email field takes you on to the password. A hairline divider meets both band rules at a plus mark. On a phone the avatar isn't a drawn side but the email field's feedback: a small chip above the field. It's built from Avatar, Field, Input, Password Input, Button, Shine Button and Guides, with a CSS entrance only. For family, team and household apps.
FAQ
What stays in the page, and does it call an avatar service?
Nothing is looked up and no avatar service is called. The monogram is worked out from the typed address in the page, and the two demo accounts (Maya Alvarez and Joaquin Alvarez) are typed constants. Sign-in waits under a spinner for less than a second, then shows "You're signed in" with the name or the address and a polite status message says nothing was sent. For real, post the form to your auth endpoint where the code says so; for a photo, put an image URL from your own user service in the avatar and keep the initials as its fallback.
How is the monogram worked out?
From the part of the address before the at sign: it is split on dots, underscores, plus signs and hyphens, and the first letter of each of the first two parts is taken, so maya.alvarez gives MA and maya gives M. Digits and symbols are ignored, any script's letters work, and with no letter at all the avatar shows the person glyph. A demo account swaps in its own monogram once the whole address matches.
Isn't showing a name before the password a privacy leak?
It can be. If a server answered for any typed address, it would tell strangers which accounts exist. Here the two accounts are typed into the page to show the pattern. In a product, show a name only from what this browser already knows, such as the account it signed in with last time, and keep the answer to a typed address the same whether or not the account exists.
What does Enter do in the email field?
When the address is a whole address (a name, an at sign and a domain) and the password is still empty, Enter moves focus to the password instead of sending the form, so a problem isn't shown before you have had the chance to type it. In any other case Enter sends the form as usual: it checks both fields, writes a sentence under each one that is wrong and moves focus to the first. The two demo accounts are also buttons under the form that type their address for you.
Where does the avatar go on a phone?
Below the large breakpoint it becomes a compact chip, the avatar at 48 pixels with the name and the typed address beside it, between the heading and the email field, so the field it reflects is right under it and the Sign in button stays on the first screen. From the large breakpoint it fills the start half of the band at 144 pixels. It is the same element in both places.
How is the avatar announced?
The avatar is decoration: the typed address and, for a demo account, the name are text beside it, so nothing is read twice. A polite status message speaks once when the address becomes one of the demo accounts ("Maya Alvarez's account. Press Enter to go to the password.") and stays silent while you type anything else, so a screen reader isn't interrupted at every key.
Related
- Pro
Welcome Back Login
Account choosersA 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
Recent Accounts Login
Account choosersAn account chooser: three recent accounts as hairline rows with initials and a session state, Remove with a permanent Undo, and a password, a plain Continue or an email and password pair under the list.
- Pro
Profile Switch Login
Account choosersA who is watching page: four profile tiles with initials and a lock, an Add profile tile, an Edit mode that turns names into fields and shows Remove with a permanent Undo, and a four-digit PIN for the locked profile.
- 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
Floating Labels Sign In Login
Centered formA member sign-in page whose labels sit inside the fields and rise on focus, with text or when the browser fills them in, all in CSS, in one bordered group of two cells split by a hairline.
- 12345Pro
Quick Actions Login
Account choosersA return-to sign-in: five destination rows with the keys 1 to 5, a password and a button that reads Sign in and open Inbox, and an always pick up where I stopped switch that picks the first row.