You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/Admin.md
+7-5Lines changed: 7 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -425,7 +425,7 @@ const App = () => (
425
425
426
426
## `darkTheme`
427
427
428
-
If you want to support light and dark mode, you can provide a `darkTheme` in addition to the `theme` prop. The `darkTheme` will be used when the user's browser is in dark mode, or when the user manually switches to dark mode using [the `<ToggleThemeButton>` component](./ToggleThemeButton.md).
428
+
If you want to support both light and dark mode, you can provide a `darkTheme` in addition to the `theme` prop. The `darkTheme` will be used when the user's browser is in dark mode, or when the user manually switches to dark mode using [the `<ToggleThemeButton>` component](./ToggleThemeButton.md).
429
429
430
430

431
431
@@ -776,16 +776,16 @@ Check the [Preferences documentation](./Store.md) for more details.
776
776
777
777
## `theme`
778
778
779
-
Material UI supports [theming](https://mui.com/material-ui/customization/theming/). This lets you customize the look and feel of an admin by overriding fonts, colors, and spacing. You can provide a custom Material UI theme by using the `theme` prop:
779
+
Material UI supports [theming](https://mui.com/material-ui/customization/theming/). This lets you customize the look and feel of an admin by overriding fonts, colors, and spacing. You can provide a custom Material UI theme by using the `theme` prop.
780
+
781
+
For instance, to use a dark theme by default:
780
782
781
783
```jsx
782
784
import { defaultTheme } from'react-admin';
783
785
784
786
consttheme= {
785
787
...defaultTheme,
786
-
palette: {
787
-
mode:'dark', // Switching the dark mode on is a single property value change.
788
-
},
788
+
palette: { mode:'dark' },
789
789
};
790
790
791
791
constApp= () => (
@@ -797,6 +797,8 @@ const App = () => (
797
797
798
798

799
799
800
+
If you want to support both a light and a dark theme, check out [the `<Admin darkTheme>` prop](#darktheme).
801
+
800
802
For more details on predefined themes and custom themes, refer to [the Theming chapter](./Theming.md#global-theme-overrides) of the react-admin documentation.
Copy file name to clipboardExpand all lines: docs/Theming.md
+53-23Lines changed: 53 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -243,7 +243,7 @@ Note that you don't need to call `createTheme` yourself. React-admin will do it
243
243
244
244
Again, to guess the name of the subclass to use (like `.RaDatagrid-headerCell` above) for customizing a component, you can use the developer tools of your browser, or check the react-admin documentation for individual components (e.g. the [Datagrid CSS documentation](./Datagrid.md#sx-css-api)).
245
245
246
-
You can use this technique to override not only styles, but also default for components. That's how react-admin applies the `filled` variant to all `TextField` components. So for instance, to change the variant to `outlined`, create a custom theme as follows:
246
+
You can use this technique to override not only styles, but also defaults for components. That's how react-admin applies the `filled` variant to all `TextField` components. So for instance, to change the variant to `outlined`, create a custom theme as follows:
247
247
248
248
```jsx
249
249
import { defaultTheme } from'react-admin';
@@ -367,58 +367,88 @@ const App = () => (
367
367
368
368
## Letting Users Choose The Theme
369
369
370
-
The `<ToggleThemeButton>` component lets users switch from light to dark mode, and persists that choice by leveraging the [store](./Store.md).
370
+
It's a common practice to support both a light theme and a dark theme in an application, and let users choose which one they prefer.
371
+
372
+
React-admin's `<Admin>` component accepts a `darkTheme` mode in addition to the `theme` prop.
With this setup, the default application theme will depend on the user's system settings. If the user has chosen a dark mode in their OS, react-admin will use the dark theme. Otherwise, it will use the light theme.
392
+
393
+
In addition, you can let users switch from one theme to the other: [the `<ToggleThemeButton>` component](./ToggleThemeButton.md) lets users switch from light to dark mode, and persists that choice by leveraging the [store](./Store.md).
React-admin provides the `useTheme` hook to read and update the theme programmatically. It uses the same syntax as `useState`.
402
-
Its used internally by `ToggleThemeButton` component.
440
+
React-admin provides the `useTheme` hook to read and update the theme programmatically. It uses the same syntax as `useState`. Its used internally by [the `<ToggleThemeButton>` component](./ToggleThemeButton.md).
0 commit comments