import { extendTheme, styled, TypographySystem, FontSize } from '@mui/joy/styles'; import Box from '@mui/joy/Box'; import Tooltip from '@mui/joy/Tooltip'; import Typography from '@mui/joy/Typography'; const defaultTheme = extendTheme(); const Table = styled('table')(({ theme }) => ({ borderCollapse: 'separate', borderSpacing: 0, display: 'block', width: 'max-content', overflow: 'auto', th: { textAlign: 'left', padding: 12, position: 'sticky', top: 0, zIndex: 1, ...theme.variants.soft.neutral, }, td: { verticalAlign: 'top', padding: '8px 12px', '& > *': { padding: '8px 12px', margin: '-8px -12px', }, }, tr: { '&:hover': { backgroundColor: theme.vars.palette.background.level1, }, '&:first-of-type': { '& td': { paddingTop: 6 }, }, }, })); const extractFromVar = (value: string, field: string) => (value || '').replace(`var(--joy-${field}-`, '').replace(')', ''); export default function TypographyThemeViewer() { const levels = Object.keys(defaultTheme.typography) as Array< keyof TypographySystem >; const renderSwatch = (colorScheme: 'light' | 'dark', token: string) => token ? ( ) : null; return ( {levels.map((level) => ( {(['fontWeight', 'lineHeight'] as const).map((field) => ( ))} ))}
Level Color Font size Font weight Line height
Preview} size="sm" arrow variant="outlined" placement="bottom-start" sx={{ pointerEvents: 'none' }} > {level} (light) (dark) } sx={{ pointerEvents: 'none' }} > {defaultTheme.typography[level].color || '-'} {defaultTheme.typography[level].fontSize || '-'} )[ extractFromVar( defaultTheme.typography[level][field] as string, field, ) ] || '' } sx={{ pointerEvents: 'none' }} > {defaultTheme.typography[level][field] || '-'}
); }