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
42 lines
1.2 KiB
JavaScript
42 lines
1.2 KiB
JavaScript
import { styled } from '@mui/material/styles';
|
|
import Button from '@mui/material/Button';
|
|
import Tooltip, { tooltipClasses } from '@mui/material/Tooltip';
|
|
|
|
const CustomWidthTooltip = styled(({ className, ...props }) => (
|
|
<Tooltip {...props} classes={{ popper: className }} />
|
|
))({
|
|
[`& .${tooltipClasses.tooltip}`]: {
|
|
maxWidth: 500,
|
|
},
|
|
});
|
|
|
|
const NoMaxWidthTooltip = styled(({ className, ...props }) => (
|
|
<Tooltip {...props} classes={{ popper: className }} />
|
|
))({
|
|
[`& .${tooltipClasses.tooltip}`]: {
|
|
maxWidth: 'none',
|
|
},
|
|
});
|
|
|
|
const longText = `
|
|
Aliquam eget finibus ante, non facilisis lectus. Sed vitae dignissim est, vel aliquam tellus.
|
|
Praesent non nunc mollis, fermentum neque at, semper arcu.
|
|
Nullam eget est sed sem iaculis gravida eget vitae justo.
|
|
`;
|
|
|
|
export default function VariableWidth() {
|
|
return (
|
|
<div>
|
|
<Tooltip title={longText}>
|
|
<Button sx={{ m: 1 }}>Default Width [300px]</Button>
|
|
</Tooltip>
|
|
<CustomWidthTooltip title={longText}>
|
|
<Button sx={{ m: 1 }}>Custom Width [500px]</Button>
|
|
</CustomWidthTooltip>
|
|
<NoMaxWidthTooltip title={longText}>
|
|
<Button sx={{ m: 1 }}>No wrapping</Button>
|
|
</NoMaxWidthTooltip>
|
|
</div>
|
|
);
|
|
}
|