Skip to content

Commit 0e4ba98

Browse files
authored
Merge pull request #10463 from smeng9/deprecate-mui-v6-system-props
[Doc] Deprecate mui v6 system props
2 parents 8fc2ddc + 58089aa commit 0e4ba98

23 files changed

+162
-114
lines changed

docs/AppBar.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ export const MyAppBar = () => (
118118

119119
If you omit `<TitlePortal>`, `<AppBar>` will no longer display the page title. This can be done on purpose, e.g. if you want to render something completely different in the AppBar, like a company logo and a search engine:
120120

121+
{% raw %}
121122
```jsx
122123
// in src/MyAppBar.js
123124
import { AppBar } from 'react-admin';
@@ -128,13 +129,14 @@ import { Logo } from './Logo';
128129

129130
const MyAppBar = () => (
130131
<AppBar>
131-
<Box component="span" flex={1} />
132+
<Box component="span" sx={{ flex: 1 }} />
132133
<Logo />
133-
<Box component="span" flex={1} />
134+
<Box component="span" sx={{ flex: 1 }} />
134135
<Search />
135136
</AppBar>
136137
);
137138
```
139+
{% endraw %}
138140

139141
## `color`
140142

@@ -450,6 +452,7 @@ export const MyAppbar = () => (
450452

451453
If react-admin's `<AppBar>` component doesn't meet your needs, you can build your own component using Material UI's `<AppBar>`. Here is an example:
452454

455+
{% raw %}
453456
```jsx
454457
// in src/MyAppBar.js
455458
import { AppBar, Toolbar, Box } from '@mui/material';
@@ -459,12 +462,13 @@ export const MyAppBar = () => (
459462
<AppBar position="static">
460463
<Toolbar>
461464
<TitlePortal />
462-
<Box flex="1" />
465+
<Box sx={{ flex: "1" }} />
463466
<RefreshIconButton />
464467
</Toolbar>
465468
</AppBar>
466469
);
467470
```
471+
{% endraw %}
468472

469473
Then, use your custom app bar in a custom `<Layout>` component:
470474

docs/Architecture.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,13 +345,13 @@ const ContactShowContent = () => {
345345
const { record, isPending } = useShowContext<Contact>();
346346
if (isPending || !record) return null;
347347
return (
348-
<Box mt={2} display="flex">
349-
<Box flex="1">
348+
<Box sx={{ mt: 2, display: "flex" }}>
349+
<Box sx={{ flex: "1" }}>
350350
<Card>
351351
<CardContent>
352-
<Box display="flex">
352+
<Box sx={{ display: "flex" }}>
353353
<Avatar />
354-
<Box ml={2} flex="1">
354+
<Box sx={{ ml: 2, flex: "1" }}>
355355
<Typography variant="h5">
356356
{record.first_name} {record.last_name}
357357
</Typography>

docs/BoxStackGrid.md

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -37,28 +37,6 @@ const MyComponent = () => (
3737
```
3838
{% endraw %}
3939

40-
`<Box>` supports all the CSS properties as props, so you can write the same component as follows:
41-
42-
{% raw %}
43-
```jsx
44-
const MyComponent = () => (
45-
<Box
46-
width={300}
47-
height={300}
48-
bgcolor="primary.main"
49-
sx={{
50-
'&:hover': {
51-
backgroundColor: 'primary.dark',
52-
opacity: [0.9, 0.8, 0.7],
53-
},
54-
}}
55-
>
56-
// ...
57-
</Box>
58-
);
59-
```
60-
{% endraw %}
61-
6240
You can render any component with `<Box>`, not only a `<div>`. For instance, to render a `<span>` with custom styles:
6341

6442
{% raw %}

docs/Breadcrumb.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ const MyBreadcrumb = () => (
344344

345345
Here is another example, showing how to use a React component as label:
346346

347+
{% raw %}
347348
```jsx
348349
import { Breadcrumb } from '@react-admin/ra-navigation';
349350
import { Typography, Stack } from '@mui/material';
@@ -356,7 +357,11 @@ const IconAndLabel = ({
356357
label: string;
357358
icon: React.ReactNode;
358359
}) => (
359-
<Stack direction="row" alignItems="center" spacing={1}>
360+
<Stack
361+
direction="row"
362+
spacing={1}
363+
sx={{ alignItems: "center" }}
364+
>
360365
{icon}
361366
<Typography variant="body2">{label}</Typography>
362367
</Stack>
@@ -388,6 +393,7 @@ const MyBreadcrumb = () => (
388393
</Breadcrumb>
389394
);
390395
```
396+
{% endraw %}
391397

392398
`<Breadcrumb>` contains shortcut components for defining several `<Breadcrumb.Item>` children in a row: `<Breadcrumb.ResourceItem>`and `<Breadcrumb.ResourceItems>`.
393399

@@ -530,6 +536,7 @@ const MyBreadcrumbCustomHome = () => (
530536

531537
Just like with `<Breadcrumb.Item>`, you can also use a React component as label:
532538

539+
{% raw %}
533540
```tsx
534541
import { Breadcrumb } from '@react-admin/ra-navigation';
535542
import { Box, Stack } from '@mui/material';
@@ -540,7 +547,11 @@ const MyBreadcrumbCustomHome = () => (
540547
<Breadcrumb>
541548
<Breadcrumb.DashboardItem
542549
label={
543-
<Stack direction="row" alignItems="center" spacing={1}>
550+
<Stack
551+
direction="row"
552+
spacing={1}
553+
sx={{ alignItems: "center" }}
554+
>
544555
<CabinIcon />
545556
<Box sx={visuallyHidden}>Dashboard</Box>
546557
</Stack>
@@ -552,6 +563,7 @@ const MyBreadcrumbCustomHome = () => (
552563
</Breadcrumb>
553564
);
554565
```
566+
{% endraw %}
555567

556568
**Tip:** It's a good practice to include a visually hidden placeholder ('Dashboard' in this example) for screen readers when using an icon as label.
557569

docs/Configurable.md

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,19 @@ const TextBlockEditor = () => {
6060
```
6161
The inner component reads the preferences using the same `usePreference` hook:
6262

63+
{% raw %}
6364
```jsx
6465
const TextBlock = ({ title, content }) => {
6566
const [color] = usePreference('color', '#ffffff');
6667
return (
67-
<Box bgcolor={color}>
68+
<Box sx={{ bgcolor: color }}>
6869
<Typography variant="h6">{title}</Typography>
6970
<Typography>{content}</Typography>
7071
</Box>
7172
);
7273
};
7374
```
75+
{% endraw %}
7476

7577
Then, use the configurable component in your app:
7678

@@ -226,31 +228,34 @@ import { Box } from '@mui/material';
226228
import { AppBar, Menu, Sidebar, Inspector } from 'react-admin';
227229

228230
const MyLayout = ({ children, dashboard }) => (
229-
<Box
230-
display="flex"
231-
flexDirection="column"
232-
zIndex={1}
233-
minHeight="100vh"
234-
backgroundColor="theme.palette.background.default"
235-
position="relative"
231+
<Box
232+
sx={{
233+
display: "flex",
234+
flexDirection: "column",
235+
zIndex: 1,
236+
minHeight: "100vh",
237+
backgroundColor: "theme.palette.background.default",
238+
position: "relative"
239+
}}
236240
>
237241
<Box
238-
display="flex"
239-
flexDirection="column"
240242
overflowX="auto"
243+
sx={{ display: "flex", flexDirection: "column" }}
241244
>
242245
<AppBar />
243-
<Box display="flex" flexGrow={1}>
246+
<Box sx={{ display: "flex", flexGrow: 1 }}>
244247
<Sidebar>
245248
<Menu hasDashboard={!!dashboard} />
246249
</Sidebar>
247250
<Box
248-
display="flex"
249-
flexDirection="column"
250-
flexGrow={2}
251-
p={3}
252-
marginTop="4em"
253-
paddingLeft={5}
251+
sx={{
252+
display: "flex",
253+
flexDirection: "column",
254+
flexGrow: 2,
255+
p: 3,
256+
marginTop: "4em",
257+
paddingLeft: 5
258+
}}
254259
>
255260
{children}
256261
</Box>

docs/DatagridAG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1533,7 +1533,7 @@ const CreatePostDialog = () => {
15331533
<Dialog open onClose={onCancel}>
15341534
<form onSubmit={handleSubmit}>
15351535
<DialogContent>
1536-
<Stack gap={4}>
1536+
<Stack sx={{ gap: 4 }}>
15371537
<MUITextField
15381538
name="title"
15391539
value={title}

docs/FilterButton.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ It's an internal component that you should only need if you build a custom List
1919

2020
`<FilterButton>` expects an array of filter inputs as `filters` prop:
2121

22+
{% raw %}
2223
```jsx
2324
import {
2425
CreateButton,
@@ -39,7 +40,7 @@ const postFilters = [
3940
];
4041

4142
const ListToolbar = () => (
42-
<Stack direction="row" justifyContent="space-between">
43+
<Stack direction="row" sx={{ justifyContent: "space-between" }}>
4344
<FilterForm filters={postFilters} />
4445
<div>
4546
<FilterButton filters={postFilters} />
@@ -60,14 +61,16 @@ const PostList = () => (
6061
</ListBase>
6162
)
6263
```
64+
{% endraw %}
6365

6466
## `disableSaveQuery`
6567

6668
By default, the filter button lets users save a group of filters for later reuse. You can set the `disableSaveQuery` prop in the filter button to disable this feature.
6769

70+
{% raw %}
6871
```jsx
6972
const ListToolbar = () => (
70-
<Stack direction="row" justifyContent="space-between">
73+
<Stack direction="row" sx={{ justifyContent: "space-between" }}>
7174
<FilterForm filters={postFilters} />
7275
<div>
7376
<FilterButton filters={postFilters} disableSaveQuery />
@@ -76,3 +79,4 @@ const ListToolbar = () => (
7679
</Stack>
7780
)
7881
```
82+
{% endraw %}

docs/FilterForm.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ It's an internal component that you should only need if you build a custom List
1919

2020
`<FilterForm>` expects an array of filter inputs as `filters` prop:
2121

22+
{% raw %}
2223
```jsx
2324
import {
2425
CreateButton,
@@ -39,7 +40,7 @@ const postFilters = [
3940
];
4041

4142
const ListToolbar = () => (
42-
<Stack direction="row" justifyContent="space-between">
43+
<Stack direction="row" sx={{ justifyContent: "space-between" }}>
4344
<FilterForm filters={postFilters} />
4445
<div>
4546
<FilterButton filters={postFilters} />
@@ -60,3 +61,4 @@ const PostList = () => (
6061
</ListBase>
6162
)
6263
```
64+
{% endraw %}

docs/FilteringTutorial.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -521,8 +521,8 @@ import { FilterLiveForm, TextInput, NullableBooleanInput } from 'react-admin';
521521

522522
const PostFilterForm = () => (
523523
<FilterLiveForm>
524-
<Box display="flex" alignItems="flex-end" mb={1}>
525-
<Box component="span" mr={2}>
524+
<Box sx={{ display: "flex", alignItems: "flex-end", mb: 1 }}>
525+
<Box component="span" sx={{ mr: 2 }}>
526526
{/* Full-text search filter. We don't use <SearchFilter> to force a large form input */}
527527
<TextInput
528528
resettable
@@ -538,7 +538,7 @@ const PostFilterForm = () => (
538538
}}
539539
/>
540540
</Box>
541-
<Box component="span" mr={2}>
541+
<Box component="span" sx={{ mr: 2 }}>
542542
{/* Commentable filter */}
543543
<NullableBooleanInput
544544
helperText={false}
@@ -592,8 +592,8 @@ const PostFilterForm = () => {
592592
return (
593593
<FormProvider {...form}>
594594
<form onSubmit={form.handleSubmit(onSubmit)}>
595-
<Box display="flex" alignItems="flex-end" mb={1}>
596-
<Box component="span" mr={2}>
595+
<Box sx={{ display: "flex", alignItems: "flex-end", mb: 1 }}>
596+
<Box component="span" sx={{ mr: 2 }}>
597597
{/* Full-text search filter. We don't use <SearchFilter> to force a large form input */}
598598
<TextInput
599599
resettable
@@ -609,19 +609,19 @@ const PostFilterForm = () => {
609609
}}
610610
/>
611611
</Box>
612-
<Box component="span" mr={2}>
612+
<Box component="span" sx={{ mr: 2 }}>
613613
{/* Commentable filter */}
614614
<NullableBooleanInput
615615
helperText={false}
616616
source="commentable"
617617
/>
618618
</Box>
619-
<Box component="span" mr={2} mb={1.5}>
619+
<Box component="span" sx={{ mr: 2, mb: 1.5 }}>
620620
<Button variant="outlined" color="primary" type="submit">
621621
Filter
622622
</Button>
623623
</Box>
624-
<Box component="span" mb={1.5}>
624+
<Box component="span" sx={{ mb: 1.5 }}>
625625
<Button variant="outlined" onClick={resetFilter}>
626626
Close
627627
</Button>
@@ -639,12 +639,13 @@ const PostFilterForm = () => {
639639

640640
To finish, create a `<ListAction>` component and pass it to the `<List>` component using the `actions` prop:
641641

642+
{% raw %}
642643
```jsx
643644
import { TopToolbar, ExportButton } from 'react-admin';
644645
import { Box } from '@mui/material';
645646

646647
const ListActions = () => (
647-
<Box width="100%">
648+
<Box sx={{ width: "100%" }}>
648649
<TopToolbar>
649650
<PostFilterButton />
650651
<ExportButton />
@@ -659,6 +660,7 @@ export const PostList = () => (
659660
</List>
660661
);
661662
```
663+
{% endraw %}
662664

663665
**Tip**: No need to pass any `filters` to the list anymore, as the `<PostFilterForm>` component will display them.
664666

docs/ImageField.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ For instance, to specify a size for the image:
9393

9494
{% raw %}
9595
```jsx
96-
<ImageField
96+
<ImageField
9797
source="thumbnail"
9898
sx={{ '& img': { maxWidth: 50, maxHeight: 50, objectFit: 'contain' } }}
9999
/>

0 commit comments

Comments
 (0)