W
Wasp-lang21h ago
Sven

where can i edit login and signup pages?

kapa where can i edit login and signup page? i want to edit the button colors and main texts
5 Replies
kapa.ai
kapa.ai21h ago
Hi @Sven. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- In Wasp, you can customize the appearance of the login and signup forms by passing props to them. The props you can pass include appearance for customizing form colors, logo for the path to your logo, and socialLayout for the layout of the social buttons. To customize the colors, you can use Stitches (https://stitches.dev/) to style the Auth UI. You can override the default theme tokens to customize the styles. Here is an example of how you can do it:
// src/appearance.js
export const authAppearance = {
colors: {
brand: '#5969b8', // blue
brandAccent: '#de5998', // pink
submitButtonText: 'white',
},
}

// src/LoginPage.jsx
import { LoginForm } from 'wasp/client/auth'
import { authAppearance } from './appearance'

export function LoginPage() {
return (
<LoginForm
// Pass the appearance object to the form
appearance={authAppearance}
/>
)
}
// src/appearance.js
export const authAppearance = {
colors: {
brand: '#5969b8', // blue
brandAccent: '#de5998', // pink
submitButtonText: 'white',
},
}

// src/LoginPage.jsx
import { LoginForm } from 'wasp/client/auth'
import { authAppearance } from './appearance'

export function LoginPage() {
return (
<LoginForm
// Pass the appearance object to the form
appearance={authAppearance}
/>
)
}
You can define your appearance in a separate file and import it into your components. This way, you can easily manage the styles of your forms. For more details, you can refer to the Wasp documentation on Auth UI Customization (https://wasp-lang.dev/docs/auth/ui#customization-). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Sven, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
Sven
Sven21h ago
And the texts how could i edit the texts like "Log in to your account " @kapa.ai ?
kapa.ai
kapa.ai21h ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- Currently, Wasp does not provide a built-in way to customize the text content of the Auth UI components directly. The text content such as "Log in to your account" is currently hard-coded in the Wasp source code. However, you can create your own custom login and signup pages with your own text content. You can use the LoginForm and SignupForm components provided by Wasp and wrap them in your own components where you can add your own text content. Here is an example of how you can do it:
// src/pages/auth.jsx
import { LoginForm, SignupForm } from 'wasp/client/auth'
import { Link } from 'react-router-dom'

export function Login() {
return (
<Layout>
<h2>Welcome to Our Site</h2>
<LoginForm />
<br />
<span className="text-sm font-medium text-gray-900">
Don't have an account yet? <Link to="/signup">go to signup</Link>.
</span>
</Layout>
);
}

export function Signup() {
return (
<Layout>
<h2>Create Your Account</h2>
<SignupForm />
<br />
<span className="text-sm font-medium text-gray-900">
I already have an account (<Link to="/login">go to login</Link>).
</span>
</Layout>
);
}
// src/pages/auth.jsx
import { LoginForm, SignupForm } from 'wasp/client/auth'
import { Link } from 'react-router-dom'

export function Login() {
return (
<Layout>
<h2>Welcome to Our Site</h2>
<LoginForm />
<br />
<span className="text-sm font-medium text-gray-900">
Don't have an account yet? <Link to="/signup">go to signup</Link>.
</span>
</Layout>
);
}

export function Signup() {
return (
<Layout>
<h2>Create Your Account</h2>
<SignupForm />
<br />
<span className="text-sm font-medium text-gray-900">
I already have an account (<Link to="/login">go to login</Link>).
</span>
</Layout>
);
}
In this example, we added a <h2> element with custom text content above the LoginForm and SignupForm components. For more details on creating custom pages, you can refer to the Wasp documentation on creating client pages (https://wasp-lang.dev/docs/auth/username-and-pass#4-create-the-client-pages). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Sven, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
Sven
Sven21h ago
Hmm no i want to edit the main forms so the texts shown at the login page and signup page @kapa.ai
kapa.ai
kapa.ai21h ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- To customize the text content of the main login and signup forms in Wasp, you would need to create your own custom forms using the lower-level primitives provided by Wasp, such as the login and signup functions. This is because the text content in the default forms is currently hard-coded and cannot be directly customized. Here is an example of how you can create your own custom login form:
import { login } from 'wasp/client/auth'

export const LoginPage = () => {
const [username, setUsername] = useState('')
const [password, setPassword] = useState('')

const handleSubmit = async event => {
event.preventDefault()
try {
await login({ username, password })
// Redirect user to some page after successful login
} catch (error) {
console.log(error)
}
}

return (
<form onSubmit={handleSubmit}>
<h2>Welcome to Our Site</h2>
<label>
Username:
<input type="text" value={username} onChange={e => setUsername(e.target.value)} />
</label>
<label>
Password:
<input type="password" value={password} onChange={e => setPassword(e.target.value)} />
</label>
<input type="submit" value="Log in" />
</form>
)
}
import { login } from 'wasp/client/auth'

export const LoginPage = () => {
const [username, setUsername] = useState('')
const [password, setPassword] = useState('')

const handleSubmit = async event => {
event.preventDefault()
try {
await login({ username, password })
// Redirect user to some page after successful login
} catch (error) {
console.log(error)
}
}

return (
<form onSubmit={handleSubmit}>
<h2>Welcome to Our Site</h2>
<label>
Username:
<input type="text" value={username} onChange={e => setUsername(e.target.value)} />
</label>
<label>
Password:
<input type="password" value={password} onChange={e => setPassword(e.target.value)} />
</label>
<input type="submit" value="Log in" />
</form>
)
}
In this example, we created a custom form with our own text content and used the login function from Wasp to handle the login process. For more details on using the login and signup functions, you can refer to the Wasp documentation on using the signup and login actions (https://wasp-lang.dev/docs/auth/username-and-pass#1-using-the-signup-and-login-actions). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Sven, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
Want results from more Discord servers?
Add your server