Skip to content

Commit 002f702

Browse files
authored
Merge pull request #8216 from marmelab/cssbaseline
Add CSSBaseline to the default layout for better UI
2 parents 14b7a46 + 7ac41ae commit 002f702

File tree

2 files changed

+37
-29
lines changed

2 files changed

+37
-29
lines changed

examples/simple/src/Layout.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from 'react';
22
import { memo } from 'react';
33
import { ReactQueryDevtools } from 'react-query/devtools';
44
import { AppBar, Layout, InspectorButton } from 'react-admin';
5-
import { CssBaseline, Typography } from '@mui/material';
5+
import { Typography } from '@mui/material';
66

77
const MyAppBar = memo(props => (
88
<AppBar {...props}>
@@ -13,7 +13,6 @@ const MyAppBar = memo(props => (
1313

1414
export default props => (
1515
<>
16-
<CssBaseline />
1716
<Layout {...props} appBar={MyAppBar} />
1817
<ReactQueryDevtools
1918
initialIsOpen={false}

packages/ra-ui-materialui/src/layout/Layout.tsx

+36-27
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import React, {
77
} from 'react';
88
import { ErrorBoundary } from 'react-error-boundary';
99
import clsx from 'clsx';
10+
import { ScopedCssBaseline } from '@mui/material';
1011
import { styled, SxProps } from '@mui/material/styles';
1112
import { CoreLayoutProps } from 'ra-core';
1213

@@ -39,34 +40,42 @@ export const Layout = (props: LayoutProps) => {
3940
};
4041

4142
return (
42-
<StyledLayout className={clsx('layout', className)} {...rest}>
43-
<SkipNavigationButton />
44-
<div className={LayoutClasses.appFrame}>
45-
<AppBar open={open} title={title} />
46-
<main className={LayoutClasses.contentWithSidebar}>
47-
<Sidebar>
48-
<Menu hasDashboard={!!dashboard} />
49-
</Sidebar>
50-
<div id="main-content" className={LayoutClasses.content}>
51-
<ErrorBoundary
52-
onError={handleError}
53-
fallbackRender={({ error, resetErrorBoundary }) => (
54-
<Error
55-
error={error}
56-
errorComponent={errorComponent}
57-
errorInfo={errorInfo}
58-
resetErrorBoundary={resetErrorBoundary}
59-
title={title}
60-
/>
61-
)}
43+
<ScopedCssBaseline enableColorScheme>
44+
<StyledLayout className={clsx('layout', className)} {...rest}>
45+
<SkipNavigationButton />
46+
<div className={LayoutClasses.appFrame}>
47+
<AppBar open={open} title={title} />
48+
<main className={LayoutClasses.contentWithSidebar}>
49+
<Sidebar>
50+
<Menu hasDashboard={!!dashboard} />
51+
</Sidebar>
52+
<div
53+
id="main-content"
54+
className={LayoutClasses.content}
6255
>
63-
{children}
64-
</ErrorBoundary>
65-
</div>
66-
</main>
67-
<Inspector />
68-
</div>
69-
</StyledLayout>
56+
<ErrorBoundary
57+
onError={handleError}
58+
fallbackRender={({
59+
error,
60+
resetErrorBoundary,
61+
}) => (
62+
<Error
63+
error={error}
64+
errorComponent={errorComponent}
65+
errorInfo={errorInfo}
66+
resetErrorBoundary={resetErrorBoundary}
67+
title={title}
68+
/>
69+
)}
70+
>
71+
{children}
72+
</ErrorBoundary>
73+
</div>
74+
</main>
75+
<Inspector />
76+
</div>
77+
</StyledLayout>
78+
</ScopedCssBaseline>
7079
);
7180
};
7281

0 commit comments

Comments
 (0)