Skip to content

Commit

Permalink
Use applyStyles array syntax everywhere on docs
Browse files Browse the repository at this point in the history
  • Loading branch information
DiegoAndai committed Dec 20, 2024
1 parent 46ac404 commit 649d41d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 23 deletions.
13 changes: 8 additions & 5 deletions docs/data/material/customization/css-theme-variables/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,15 @@ The example below shows how to customize the Card component for dark mode:
import Card from '@mui/material/Card';

<Card
sx={(theme) => ({
backgroundColor: theme.vars.palette.background.default,
...theme.applyStyles('dark', {
backgroundColor: theme.vars.palette.grey[50],
sx={[
(theme) => ({
backgroundColor: theme.vars.palette.background.default,
}),
})}
(theme) =>
theme.applyStyles('dark', {
backgroundColor: theme.vars.palette.grey[50],
}),
]}
/>;
```

Expand Down
39 changes: 21 additions & 18 deletions docs/data/material/customization/dark-mode/dark-mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,20 +186,22 @@ With the `styled` function:
```jsx
import { styled } from '@mui/material/styles';

const MyComponent = styled('div')(({ theme }) => ({
color: '#fff',
backgroundColor: theme.palette.primary.main,
...theme.applyStyles('dark', {
const MyComponent = styled('div')(({ theme }) => [
{
color: '#fff',
backgroundColor: theme.palette.primary.main,
'&:hover': {
boxShadow: theme.shadows[3],
backgroundColor: theme.palette.primary.dark,
},
},
theme.applyStyles('dark', {
backgroundColor: theme.palette.secondary.main,
}),
'&:hover': {
boxShadow: theme.shadows[3],
backgroundColor: theme.palette.primary.dark,
...theme.applyStyles('dark', {
'&:hover': {
backgroundColor: theme.palette.secondary.dark,
}),
},
}));
},
}),
]);
```

With the `sx` prop:
Expand All @@ -212,17 +214,18 @@ import Button from '@mui/material/Button';
(theme) => ({
color: '#fff',
backgroundColor: theme.palette.primary.main,
...theme.applyStyles('dark', {
backgroundColor: theme.palette.secondary.main,
}),
'&:hover': {
boxShadow: theme.shadows[3],
backgroundColor: theme.palette.primary.dark,
...theme.applyStyles('dark', {
backgroundColor: theme.palette.secondary.dark,
}),
},
}),
(theme) =>
theme.applyStyles('dark', {
backgroundColor: theme.palette.secondary.main,
'&:hover': {
backgroundColor: theme.palette.secondary.dark,
},
}),
]}
>
Submit
Expand Down

0 comments on commit 649d41d

Please sign in to comment.