create a saas login page with shopify polaris
- User
create a saas login page with shopify polaris
Assistant
Shopify Polaris SAAS Login Page
Here's a complete implementation of a SAAS login page using Shopify's Polaris design system. This includes a clean, modern login form with email/password fields, social login options, and a password recovery link.
Implementation
First, make sure you have the required dependencies installed:
npm install @shopify/polaris @shopify/app-bridge-react @shopify/app-bridge-utilsHere's the complete React component for the login page:
import React, { useState } from 'react'; import { Page, Layout, Card, Form, FormLayout, TextField, Button, Stack, Link, TextStyle, Banner, Divider, Icon } from '@shopify/polaris'; import { Google, Facebook, Apple } from '@shopify/polaris-icons'; function SaasLoginPage() { const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [error, setError] = useState(null); const [loading, setLoading] = useState(false); const handleSubmit = (e) => { e.preventDefault(); setLoading(true); setError(null); // Simulate API call setTimeout(() => { setLoading(false); if (email === 'demo@example.com' && password === 'password') { // Successful login - redirect or set auth state console.log('Login successful'); } else { setError('Invalid email or password'); } }, 1000); }; const handleSocialLogin = (provider) => { setLoading(true); console.log(`Logging in with ${provider}`); // Implement your social login logic here setTimeout(() => setLoading(false), 1000); }; return ( <Page narrowWidth> <Layout> <Layout.Section> <Card sectioned> <div style={{ maxWidth: '400px', margin: '0 auto' }}> <div style={{ textAlign: 'center', marginBottom: '2rem' }}> <h1 style={{ fontSize: '2rem', fontWeight: '600' }}>Welcome Back</h1> <TextStyle variation="subdued"> Log in to your account to continue </TextStyle> </div> {error && ( <Banner title="Login failed" status="critical" onDismiss={() => setError(null)} > {error} </Banner> )} <Form onSubmit={handleSubmit}> <FormLayout> <TextField label="Email" type="email" value={email} onChange={setEmail} autoComplete="email" required /> <TextField label="Password" type="password" value={password} onChange={setPassword} autoComplete="current-password" required /> <Stack distribution="trailing"> <Link url="/recover">Forgot password?</Link> </Stack> <Button primary fullWidth submit loading={loading} > Log in </Button> </FormLayout> </Form> <div style={{ textAlign: 'center', margin: '1.5rem 0' }}> <TextStyle variation="subdued">or continue with</TextStyle> </div> <Stack distribution="equalSpacing"> <Button icon={<Icon source={Google} color="base" />} plain onClick={() => handleSocialLogin('Google')} /> <Button icon={<Icon source={Facebook} color="base" />} plain onClick={() => handleSocialLogin('Facebook')} /> <Button icon={<Icon source={Apple} color="base" />} plain onClick={() => handleSocialLogin('Apple')} /> </Stack> <Divider /> <div style={{ textAlign: 'center', marginTop: '1rem' }}> <TextStyle variation="subdued"> Don't have an account?{' '} <Link url="/signup">Sign up</Link> </TextStyle> </div> </div> </Card> </Layout.Section> </Layout> </Page> ); } export default SaasLoginPage;Key Features
- Clean Polaris Design: Follows Shopify's design system for consistency
- Form Validation: Basic validation for required fields
- Social Login Options: Google, Facebook, and Apple login buttons
- Password Recovery: Link to reset password
- Error Handling: Displays error messages for failed login attempts
- Responsive Layout: Works well on different screen sizes
- Loading States: Visual feedback during form submission
Customization Options
You can easily customize this login page by:
- Changing the logo: Add your company logo at the top
- Modifying colors: Adjust the theme colors to match your brand
- Adding more fields: Include additional fields like "Remember me" checkbox
- Adjusting layout: Change the spacing or section organization
- Adding CAPTCHA: Implement security measures if needed
Integration Notes
To integrate this with your actual authentication system:
- Replace the mock API call in
handleSubmitwith your real authentication logic - Implement proper error handling from your backend
- Set up proper redirect logic after successful login
- Configure the social login buttons with your actual provider credentials
This implementation provides a solid foundation that you can build upon to create a professional SAAS login experience using Shopify Polaris.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.