import * as React from 'react';
import { styled, css, ThemeProvider, createTheme } from '@mui/material/styles';
const Box = styled('div')(({ theme }) => ({
color: theme.palette.primary.main,
}));
const SimpleBox = styled('div')``;
function SxTestSimpleBox() {
;
}
function SxTest() {
;
}
function WorksWithNoTheme() {
;
}
const StyledToolbar = styled('div')(({ theme }) => ({
...theme.mixins.toolbar,
}));
const StyledSpan = styled('span')(({ theme }) => ({
...theme.typography.body1,
}));
const Container = styled('div')<{ $heightLimit: boolean }>`
min-width: 0;
${({ $heightLimit }) =>
$heightLimit &&
css`
background: red;
height: 10vh;
`}
`;
// https://github.com/mui/material-ui/issues/28844
interface PropsFooVariant {
variant: 'foo';
}
interface PropsBarVariant {
variant: 'bar';
}
function Component(props: PropsFooVariant | PropsBarVariant) {
return
;
}
const StyledComponent = styled(Component)(({ theme }) => ({}));
const rendered = (
);
/**
* ===================================================================
*/
/**
* Test styleOverrides callback types
*/
interface ButtonProps {
startIcon?: React.ReactNode;
endIcon?: React.ReactNode;
color?: 'primary';
variant?: 'contained';
}
const ButtonRoot = styled('button', {
name: 'MuiButton',
slot: 'Root',
overridesResolver: (props, styles) => styles.root,
})<{ ownerState: ButtonProps }>({});
const ButtonIcon = styled('span', {
name: 'MuiButton',
slot: 'Icon',
overridesResolver: (props, styles) => styles.icon,
})<{ ownerState: ButtonProps }>({});
function Button({
children,
startIcon,
endIcon,
color = 'primary',
variant = 'contained',
...props
}: React.PropsWithChildren) {
const ownerState = { startIcon, endIcon, color, variant, ...props };
return (
{startIcon && {startIcon}}
{children}
{endIcon && {endIcon}}
);
}
{
const { color, variant } = ownerState;
const styles = [];
if (color === 'primary') {
styles.push({
width: 120,
height: 48,
});
}
if (variant === 'contained') {
styles.push(theme.typography.button);
}
return styles;
},
startIcon: ({ ownerState: { startIcon, endIcon } }) => [
startIcon && { marginRight: 8 },
endIcon && { marginLeft: 8 },
],
},
},
MuiSlider: {
styleOverrides: {
mark: (props) => ({
...(props['data-index'] === 0 && {}),
}),
thumb: ({ theme }) =>
theme.unstable_sx({
p: 1,
}),
track: ({ ownerState, theme }) => [
theme.unstable_sx({ height: 10 }),
ownerState.orientation === 'vertical' &&
theme.unstable_sx({
my: 2,
}),
],
},
},
},
})}
>
;