Some checks failed
No response / noResponse (push) Has been cancelled
CI / Continuous releases (push) Has been cancelled
CI / test-dev (macos-latest) (push) Has been cancelled
CI / test-dev (ubuntu-latest) (push) Has been cancelled
CI / test-dev (windows-latest) (push) Has been cancelled
Maintenance / main (push) Has been cancelled
Scorecards supply-chain security / Scorecards analysis (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
40 lines
903 B
TypeScript
40 lines
903 B
TypeScript
import * as React from 'react';
|
|
import ListItem from '@mui/material/ListItem';
|
|
import FormLabel from '@mui/material/FormLabel';
|
|
import { SxProps, Theme } from '@mui/material/styles';
|
|
|
|
interface ListHeaderProps {
|
|
children: React.ReactNode;
|
|
sx?: SxProps<Theme>;
|
|
}
|
|
|
|
function ListHeader({ sx = [], children }: ListHeaderProps) {
|
|
return (
|
|
<ListItem
|
|
sx={[
|
|
{
|
|
width: 'auto',
|
|
textDecoration: 'underline',
|
|
},
|
|
// You cannot spread `sx` directly because `SxProps` (typeof sx) can be an array.
|
|
...(Array.isArray(sx) ? sx : [sx]),
|
|
]}
|
|
>
|
|
<FormLabel sx={{ color: 'inherit' }}>{children}</FormLabel>
|
|
</ListItem>
|
|
);
|
|
}
|
|
|
|
export default function PassingSxProp() {
|
|
return (
|
|
<ListHeader
|
|
sx={(theme) => ({
|
|
color: 'info.main',
|
|
...theme.typography.overline,
|
|
})}
|
|
>
|
|
Header
|
|
</ListHeader>
|
|
);
|
|
}
|