Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tooltip] Add some docs for disabled elements #12265

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions docs/src/pages/demos/tooltips/DisabledTooltips.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';
import Button from '@material-ui/core/Button';
import Tooltip from '@material-ui/core/Tooltip';

function DisabledTooltips() {
return (
<Tooltip title="You don't have permission to do this">
<span>
<Button disabled>A Disabled Button</Button>
</span>
</Tooltip>
);
}

export default DisabledTooltips;
6 changes: 6 additions & 0 deletions docs/src/pages/demos/tooltips/tooltips.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ On mobile, the tooltip is displayed when the user longpresses the element and hi

{{"demo": "pages/demos/tooltips/DelayTooltips.js"}}

## Disabled Elements

By default disabled elements like `Button` do not trigger user interactions so a `Tooltip` will not activate on normal events like hover. To accomodate disabled elements, add a simple wrapper element like a `span`.

{{"demo": "pages/demos/tooltips/DisabledTooltips.js"}}

## Customized Tooltips

{{"demo": "pages/demos/tooltips/CustomizedTooltips.js"}}
7 changes: 7 additions & 0 deletions pages/demos/tooltips.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ module.exports = require('fs')
raw: preval`
module.exports = require('fs')
.readFileSync(require.resolve('docs/src/pages/demos/tooltips/CustomizedTooltips'), 'utf8')
`,
},
'pages/demos/tooltips/DisabledTooltips.js': {
js: require('docs/src/pages/demos/tooltips/DisabledTooltips').default,
raw: preval`
module.exports = require('fs')
.readFileSync(require.resolve('docs/src/pages/demos/tooltips/DisabledTooltips'), 'utf8')
`,
},
}}
Expand Down