diff --git a/docs/src/pages/demos/tooltips/CustomizedTooltips.js b/docs/src/pages/demos/tooltips/CustomizedTooltips.js index 979a901c144c87..448e56c2283ea0 100644 --- a/docs/src/pages/demos/tooltips/CustomizedTooltips.js +++ b/docs/src/pages/demos/tooltips/CustomizedTooltips.js @@ -69,6 +69,9 @@ const styles = theme => ({ borderStyle: 'solid', }, }, + button: { + margin: theme.spacing.unit, + }, }); class CustomizedTooltips extends React.Component { @@ -88,10 +91,10 @@ class CustomizedTooltips extends React.Component { return (
- + - + - +
); diff --git a/docs/src/pages/demos/tooltips/VariableWidth.js b/docs/src/pages/demos/tooltips/VariableWidth.js new file mode 100644 index 00000000000000..f8fb7d30de8cde --- /dev/null +++ b/docs/src/pages/demos/tooltips/VariableWidth.js @@ -0,0 +1,45 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { withStyles } from '@material-ui/core/styles'; +import Button from '@material-ui/core/Button'; +import Tooltip from '@material-ui/core/Tooltip'; + +const styles = theme => ({ + button: { + margin: theme.spacing.unit, + }, + customWidth: { + maxWidth: 500, + }, + noMaxWidth: { + 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. +`; + +function VariableWidth({ classes }) { + return ( +
+ + + + + + + + + +
+ ); +} + +VariableWidth.propTypes = { + classes: PropTypes.object.isRequired, +}; + +export default withStyles(styles)(VariableWidth); diff --git a/docs/src/pages/demos/tooltips/tooltips.md b/docs/src/pages/demos/tooltips/tooltips.md index 59727cf1048860..67be01413ed8d8 100644 --- a/docs/src/pages/demos/tooltips/tooltips.md +++ b/docs/src/pages/demos/tooltips/tooltips.md @@ -55,3 +55,9 @@ By default disabled elements like `Button` do not trigger user interactions so a ## Customized Tooltips {{"demo": "pages/demos/tooltips/CustomizedTooltips.js"}} + +## Variable Width + +The `Tooltip` wraps long text by default to make it readable. + +{{"demo": "pages/demos/tooltips/VariableWidth.js"}} diff --git a/packages/material-ui/src/Tooltip/Tooltip.js b/packages/material-ui/src/Tooltip/Tooltip.js index 3128c5b0846e11..cbaefc7b5d5d96 100644 --- a/packages/material-ui/src/Tooltip/Tooltip.js +++ b/packages/material-ui/src/Tooltip/Tooltip.js @@ -24,6 +24,7 @@ export const styles = theme => ({ padding: '4px 8px', fontSize: theme.typography.pxToRem(10), lineHeight: `${theme.typography.round(14 / 10)}em`, + maxWidth: 300, }, /* Styles applied to the tooltip (label wrapper) element if the tooltip is opened by touch. */ touch: { diff --git a/pages/demos/tooltips.js b/pages/demos/tooltips.js index 7c10b8cc4547d3..a543abeb1fafb0 100644 --- a/pages/demos/tooltips.js +++ b/pages/demos/tooltips.js @@ -20,6 +20,13 @@ module.exports = require('fs') raw: preval` module.exports = require('fs') .readFileSync(require.resolve('docs/src/pages/demos/tooltips/PositionedTooltips'), 'utf8') +`, + }, + 'pages/demos/tooltips/VariableWidth.js': { + js: require('docs/src/pages/demos/tooltips/VariableWidth').default, + raw: preval` +module.exports = require('fs') + .readFileSync(require.resolve('docs/src/pages/demos/tooltips/VariableWidth'), 'utf8') `, }, 'pages/demos/tooltips/ControlledTooltips.js': {