suiss/ui ยท Block
Login Account
A two-step account sign-in form that asks for an email, then reveals a password field.
Login Account is an open-source block from suiss/ui for React, React Native, SwiftUI and Jetpack Compose. The @esuiss/ui CLI copies its source into your project, so you own the code.
A sign-in form that asks for an email first, then reveals a password field below it. Errors appear inline and shake the fields, followed by a Remember me checkbox and links for a forgotten password and account creation. A successful sign-in shows a greeting with a Sign out link. Use it for any email-and-password login.
Replace the second step of submit, which accepts any password of four or more characters after a delay, with your authentication call, and pass its error message to fail. Point the #forgot and #create links at your routes, and wire the Remember me checkbox, which is uncontrolled. Drop the greeting view if you redirect after login.
Inputs use the username and current-password autocomplete values so password managers work, and errors are tied to the fields and announced.
Installation
Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:
Usage
Web preview
A sign-in screen inside a KeyboardScrollView. The email Input comes first; once a valid address is submitted, the password field appears below it and takes focus. Invalid input shakes the form and shows an error. It also has a Remember me Checkbox with a Label, a Forgot password link, a create account link, and a Spinner while signing in, followed by a welcome view with an Avatar and a Sign out link.
Installation
- Install the following dependencies:
-
Add the pieces it builds on: Avatar, Button, Checkbox, Icon, Input, Keyboard Scroll View, Label, Screen, Spinner, Text.
-
Copy the animated view into
components/ui/animated-view.tsx:
- Copy and paste the following code into
components/blocks/login-account.tsx:
- Update the import paths to match your project setup.
- Install the following dependencies:
-
Add the pieces it builds on: Avatar, Button, Checkbox, Icon, Input, Keyboard Scroll View, Label, Screen, Spinner, Text.
-
Copy the animated view into
components/ui/animated-view.tsx:
- Copy and paste the following code into
components/blocks/login-account.tsx:
- Update the import paths to match your project setup.
- Install the following dependencies:
-
Add the pieces it builds on: Avatar, Button, Checkbox, Icon, Input, Keyboard Scroll View, Label, Screen, Spinner, Text.
-
Copy the animated view into
components/ui/animated-view.tsx:
- Copy and paste the following code into
components/blocks/login-account.tsx:
- Update the import paths to match your project setup.
-
Target iOS 17 or later.
-
Add the Swift package to your app:
- Copy the theme files every view uses:
- Copy the source and every file it uses:
- Add the files to your app target.
- Apply the Compose compiler plugin, enable Compose, set
compileSdkto 37 or higher andminSdkto 24 or higher, and add the dependencies:
- Copy the theme files every view uses:
- Copy the source and every file it uses:
- Update the
com.esuiss.uipackage names to match your project.
Usage
Wire onSubmit (receives the email and password) to your auth service, and onForgotPassword and onCreateAccount to your navigation. The sign-in delay and the success view are simulated in the component.