Skip to content

Commit 7ef0989

Browse files
committed
docs(README): update authentication component instructions and add theming details for better clarity and usability
1 parent be85a85 commit 7ef0989

1 file changed

Lines changed: 23 additions & 13 deletions

File tree

README.md

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,6 @@ pnpm add react-admin-auth
2121
**Peer dependencies:**
2222
You must have `react`, `react-dom`, `react-admin`, `react-router-dom`, and `@mui/material` installed in your project.
2323

24-
## Import the CSS
25-
26-
To get the default styles, you must import the library CSS in your main entry file (e.g., `index.js` or `App.js`):
27-
28-
```js
29-
import 'react-admin-auth/dist/style.css';
30-
```
31-
3224
## Components
3325

3426
- `Auth`: Main authentication component (handles login, signup, SSO, etc.)
@@ -44,15 +36,19 @@ import 'react-admin-auth/dist/style.css';
4436

4537
### 1. Add Auth Routes to React-admin
4638

47-
Import the `routes` array and add it to your React-admin `<Admin>` component using the `customRoutes` prop:
39+
Add the `<Auth>` component as your loginPage.
40+
Import the `routes` array and add it to your React-admin `<Admin>` component using the `customRoutes` prop.
41+
Import the library CSS in your main entry file (e.g., `index.js` or `App.js`):
4842

4943
```jsx
5044
import { Admin } from "react-admin";
51-
import { routes as authRoutes } from "react-admin-auth";
45+
import { Auth, routes as authRoutes } from "react-admin-auth";
46+
import 'react-admin-auth/dist/style.css';
5247

5348
export const App = () => (
5449
<Admin
5550
// ...other props
51+
loginPage={Auth}
5652
customRoutes={authRoutes}
5753
>
5854
{/* resources */}
@@ -62,8 +58,9 @@ export const App = () => (
6258

6359
This will add the following routes :
6460

65-
- `/accept_invitation`
61+
- `/login`
6662
- `/signup`
63+
- `/accept_invitation`
6764
- `/sso`
6865
- `/forgot_password`
6966
- `/reset_password`
@@ -111,10 +108,20 @@ See the source code for each component for available props.
111108

112109
These components expect a compatible `authProvider` to be set up in your React-admin app, supporting methods like `login`, `logout`, `recoverPassword`, `resetPassword`, etc.
113110

111+
## Theme
112+
113+
All authentication components share a common layout (`AuthLayout`) that can be themed using two variables:
114+
115+
- `background`: Sets the background image, color, or gradient for the layout.
116+
- `logo`: Sets the logo displayed at the top of the authentication screens.
114117

115-
## Styling
118+
You can provide these variables to customize the look and feel of your authentication pages. For a practical example of how to use these theme variables, see the demo app included in this repository:
116119

117-
The package uses Material-UI and SCSS modules. You can override styles by targeting the generated class names, using custom CSS, or copying the components for further customization.
120+
[`/demo/src/theme.js`](./demo/src/theme.js)
121+
122+
The demo shows how to define and apply a custom background and logo to the authentication layout.
123+
124+
You can also pass a `className` prop to all components to further customize them.
118125

119126
## Internationalization (i18n)
120127

@@ -131,6 +138,9 @@ This allows you to fully localize all texts, labels, errors, and button messages
131138

132139
For a practical example of i18n integration and translation keys, see the demo app included in this repository. The demo provides a working setup with translations you can use as a reference for your own project.
133140

141+
You can find an example locale file here:
142+
[`/demo/src/i18n/en.json`](./demo/src/i18n/en.json)
143+
134144
## License
135145

136146
GPL-3.0-only

0 commit comments

Comments
 (0)