packages/grafana-ui/src/components/Toggletip/Toggletip.mdx
import { ArgTypes } from '@storybook/addon-docs/blocks'; import { Toggletip } from './Toggletip';
Toggletips, similar to Tooltips, provide contextual support for users when needed. They are hidden by default, a UI trigger or text link are clicked to set them to their visible state. Toggletips, unlike tooltips, are persistent until a user takes action to dismiss them by clicking on the required "X" (close) trigger. Toggletips are capable of containing varying types of complex content including interactive components, buttons, and dropdowns.
Toggletips reveal supplemental content when a user clicks a button or another UI element and remains actively open until a user dismisses it.
Toggletips are able to house various types of content. Below is a potential list:
There are currently 2 themes available for the Toggletip.
This is the default theme, usually used in forms to show more information.
Tooltip with a red background.
Toggletips are revealed by clicking rather than by hovering and focusing. It is important for them to prompt screen readers to announce the information after the click event.
Toggletips are intended to house interactive elements within them. UI elements such as buttons, text links, dropdowns, etc. are able to be fully interacted with inside of the toggletip.
In the instance that a toggletip requires scrolling of content (e.g. with a dropdown) the header and the footer of the toggletip remain fixed with the body enabling scroll.
Toggletips have two states.
function onClose() {
// code to execute when the toggletip is closed
}
return (
<Toggletip
content="Toggletip body"
title="This is the title of the Toggletip"
footer="Toggletip footer text"
closeButton={true}
onClose={onClose}
>
<IconButton name="question-circle" tooltip="IconButton containing a Toggletip" />
</Toggletip>
);