In this tutorial, we will create mantine login form page in react mantine core. We will see sign in form, mantine login form with image using react mantine.
Install & Setup Vite + React + Typescript + Mantine UI
How to Use Mantine in Next.JS 13
React Mantine Login Page Example
1. react mantine login form page using TextInput, PasswordInput, Checkbox, Anchor, Paper, Title, Text, Container, Group, Button component.
import {
TextInput,
PasswordInput,
Checkbox,
Anchor,
Paper,
Title,
Text,
Container,
Group,
Button,
} from "@mantine/core";
export default function Login() {
return (
<Container size={420} my={40}>
<Title
align="center"
sx={(theme) => ({
fontFamily: `Greycliff CF, ${theme.fontFamily}`,
fontWeight: 900,
})}
>
Welcome back!
</Title>
<Text color="dimmed" size="sm" align="center" mt={5}>
Do not have an account yet?{" "}
<Anchor<"a">
href="#"
size="sm"
onClick={(event) => event.preventDefault()}
>
Create account
</Anchor>
</Text>
<Paper withBorder shadow="md" p={30} mt={30} radius="md">
<TextInput label="Email" placeholder="[email protected]" required />
<PasswordInput
label="Password"
placeholder="Your password"
required
mt="md"
/>
<Group position="apart" mt="lg">
<Checkbox label="Remember me" sx={{ lineHeight: 1 }} />
<Anchor<"a">
onClick={(event) => event.preventDefault()}
href="#"
size="sm"
>
Forgot password?
</Anchor>
</Group>
<Button fullWidth mt="xl">
Sign in
</Button>
</Paper>
</Container>
);
}
2. react mantine login form page with Image.
import {
Paper,
createStyles,
TextInput,
PasswordInput,
Checkbox,
Button,
Title,
Text,
Anchor,
} from "@mantine/core";
const useStyles = createStyles((theme) => ({
wrapper: {
minHeight: 900,
backgroundSize: "cover",
backgroundImage:
"url(https://images.unsplash.com/photo-1484242857719-4b9144542727?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=1280&q=80)",
},
form: {
borderRight: `1px solid ${
theme.colorScheme === "dark" ? theme.colors.dark[7] : theme.colors.gray[3]
}`,
minHeight: 900,
maxWidth: 450,
paddingTop: 80,
[`@media (max-width: ${theme.breakpoints.sm}px)`]: {
maxWidth: "100%",
},
},
title: {
color: theme.colorScheme === "dark" ? theme.white : theme.black,
fontFamily: `Greycliff CF, ${theme.fontFamily}`,
},
logo: {
color: theme.colorScheme === "dark" ? theme.white : theme.black,
width: 120,
display: "block",
marginLeft: "auto",
marginRight: "auto",
},
}));
export default function App() {
const { classes } = useStyles();
return (
<div className={classes.wrapper}>
<Paper className={classes.form} radius={0} p={30}>
<Title
order={2}
className={classes.title}
align="center"
mt="md"
mb={50}
>
Welcome back to Mantine!
</Title>
<TextInput
label="Email address"
placeholder="[email protected]"
size="md"
/>
<PasswordInput
label="Password"
placeholder="Your password"
mt="md"
size="md"
/>
<Checkbox label="Keep me logged in" mt="xl" size="md" />
<Button fullWidth mt="xl" size="md">
Login
</Button>
<Text align="center" mt="md">
Don't have an account?{" "}
<Anchor<"a">
href="#"
weight={700}
onClick={(event) => event.preventDefault()}
>
Register
</Anchor>
</Text>
</Paper>
</div>
);
}