Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs] Use slot variants over theme.variants #42614

Merged
merged 14 commits into from
Jul 24, 2024

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,49 @@ import * as React from 'react';
import { createTheme, ThemeProvider } from '@mui/material/styles';
import Button from '@mui/material/Button';

const defaultTheme = createTheme();

const theme = createTheme({
const customTheme = createTheme({
components: {
MuiButton: {
variants: [
{
props: { variant: 'dashed' },
style: {
textTransform: 'none',
border: `2px dashed ${defaultTheme.palette.primary.main}`,
color: defaultTheme.palette.primary.main,
},
},
{
props: { variant: 'dashed', color: 'secondary' },
style: {
border: `2px dashed ${defaultTheme.palette.secondary.main}`,
color: defaultTheme.palette.secondary.main,
},
},
{
props: { variant: 'dashed', size: 'large' },
style: {
borderWidth: 4,
},
},
{
props: { variant: 'dashed', color: 'secondary', size: 'large' },
style: {
fontSize: 18,
},
styleOverrides: {
root: {
variants: [
{
props: { variant: 'dashed' },
style: ({ theme }) => ({
textTransform: 'none',
border: `2px dashed ${theme.palette.primary.main}`,
color: theme.palette.primary.main,
}),
},
{
props: { variant: 'dashed', color: 'secondary' },
style: ({ theme }) => ({
border: `2px dashed ${theme.palette.secondary.main}`,
color: theme.palette.secondary.main,
}),
},
{
props: { variant: 'dashed', size: 'large' },
style: {
borderWidth: 4,
},
},
{
props: { variant: 'dashed', color: 'secondary', size: 'large' },
style: {
fontSize: 18,
},
},
],
},
],
},
},
},
});

export default function GlobalThemeVariants() {
return (
<ThemeProvider theme={theme}>
<ThemeProvider theme={customTheme}>
<Button variant="dashed" sx={{ m: 1 }}>
Dashed
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,47 +8,49 @@ declare module '@mui/material/Button' {
}
}

const defaultTheme = createTheme();

const theme = createTheme({
const customTheme = createTheme({
components: {
MuiButton: {
variants: [
{
props: { variant: 'dashed' },
style: {
textTransform: 'none',
border: `2px dashed ${defaultTheme.palette.primary.main}`,
color: defaultTheme.palette.primary.main,
},
},
{
props: { variant: 'dashed', color: 'secondary' },
style: {
border: `2px dashed ${defaultTheme.palette.secondary.main}`,
color: defaultTheme.palette.secondary.main,
},
},
{
props: { variant: 'dashed', size: 'large' },
style: {
borderWidth: 4,
},
},
{
props: { variant: 'dashed', color: 'secondary', size: 'large' },
style: {
fontSize: 18,
},
styleOverrides: {
root: {
variants: [
{
props: { variant: 'dashed' },
style: ({ theme }) => ({
textTransform: 'none',
border: `2px dashed ${theme.palette.primary.main}`,
color: theme.palette.primary.main,
}),
},
{
props: { variant: 'dashed', color: 'secondary' },
style: ({ theme }) => ({
border: `2px dashed ${theme.palette.secondary.main}`,
color: theme.palette.secondary.main,
}),
},
{
props: { variant: 'dashed', size: 'large' },
style: {
borderWidth: 4,
},
},
{
props: { variant: 'dashed', color: 'secondary', size: 'large' },
style: {
fontSize: 18,
},
},
],
},
],
},
},
},
});

export default function GlobalThemeVariants() {
return (
<ThemeProvider theme={theme}>
<ThemeProvider theme={customTheme}>
<Button variant="dashed" sx={{ m: 1 }}>
Dashed
</Button>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<ThemeProvider theme={theme}>
<ThemeProvider theme={customTheme}>
<Button variant="dashed" sx={{ m: 1 }}>
Dashed
</Button>
Expand Down
Loading
Loading