shadcn.io is not affiliated with official shadcn/ui
Social Connect Login Block for React
A panel of four sign-in methods (Password, Google, GitHub, X) with Connect and Disconnect that refuses to remove the last one, an alert dialog and Undo for the others, and a choice of which shows first.
Installation
Overview
Let people manage how they get in without ever locking themselves out, with this social connect login block for React with Base UI. It's the sign-in methods panel of Bioloft, link-in-bio pages: a short header over one framed panel with a plus mark on each corner. The first band lists four ways in, Password, Google, GitHub and X, each with a two-letter tile, a detail line (an account, a date or "Not connected") and a Connect or Disconnect Button. The rule is a real one: the last remaining way in can't be removed, so its Disconnect stays pressable, says "Keep at least one way to sign in." and its row reads "Your only way in. Connect another first." Disconnecting any other method asks first in an Alert Dialog, and a polite status line in the foot reports what changed with an Undo that puts it back. A second band, a Radio Group, picks which connected method the sign-in page shows first; it moves on by itself if you disconnect that method, and Undo moves it back. It's built from Alert Dialog, Radio Group, Field, Button and Guides, and the panel never changes height. For account and security settings of any product with more than one way to sign in.
FAQ
How does the panel stop the last method being removed?
The row of the only connected method counts as the last way in: its Disconnect button gets aria-disabled instead of disabled, so it stays focusable and pressable, and pressing it says why in the status line and never opens the dialog. The rule lives in the block's state (the list of connected methods), not in the button, so no path can reach zero. In your app enforce it on the server too, and count a passkey or an SSO login as a way in.
What do the dialog and Undo do?
Disconnecting asks first in an Alert Dialog whose first focus is "Keep it", with no close on an outside click. Confirming removes the method and leaves an Undo in the foot; pressing it reconnects the method and puts back the method that was shown first. Connecting another method clears the Undo, because the last change is no longer the one on top. Focus moves to the button that replaced the one you pressed.
What stays local, and how do I wire it for real?
Everything. Connect marks a method as connected and links nothing, and the accounts shown are made up. For real, send the visitor to the provider to authorise on Connect and store the link when they return; on Disconnect revoke the provider's grant and delete your link, and only after the server confirms that another way in remains.
How does the choice of method to show first work?
It is a Radio Group of the four methods, and only connected ones can be chosen: the others keep their place in the grid so nothing moves, but are hidden and out of the tab order. Choosing one says "Google will show first." in the status line. Disconnecting the chosen method moves the choice to the first one left, so the sign-in page never leads with something that isn't there.
How does it look on a phone?
Each row stacks: the tile and the name on top, the button under the detail line. The detail line keeps room for two lines so a longer message doesn't push the next row, and the radio choices form two columns. The panel keeps its height whatever is connected.
Is it usable with a keyboard and a screen reader?
Yes. Every button is named for its method ("Disconnect GitHub", "Connect X"), the count of connected methods is text, the dialog traps focus and returns it, and one polite status line reports each change. The Undo is out of the tab order and the reading order when there is nothing to undo.
Related
- Pro
Connected Accounts Account
Connected appsThe sign-in providers linked to an account: each with its address, link date and use history, an Unlink that asks first and refuses on the only way in, an Undo line and quiet buttons to link more.
- Pro
Linked Accounts Account
Connected appsWhen a provider's email is not yours: a table of what each provider returned, a choice under each mismatch to add it as a second email or keep it separate, and a count of sign-ins that would make a new account.
- Pro
Identity Provider Login
SSO and providersA searchable list of ten sign-in providers in three groups with counts and a Connected before marker: typing filters, Enter or a press chooses, the button names the choice and shows where a real sign-in would go.
- Pro
Federated Identity Login
SSO and providersA provider chooser for a cloud console: a table of five identity providers with protocol, a health word and dot, and the last check, where a provider in maintenance can't be chosen and says why, and one button connects.
- Pro
Social Buttons Login
SSO and providersA full-height provider-first sign-in page for a photo-sharing app: four hairline rows for Google, GitHub, Apple and Microsoft with a Last used badge that moves, and an email form that opens in place.
- Pro
Passkey Login
PasswordlessAn online bank's sign-in page and its passkey chooser shown open over a drawn sign-in screen: two passkeys as radio rows, Cancel and Continue, a verifying step and a signed-in result, with the real dialog behind the Use your passkey button.