Components
Floating labels providing context.
Version: | 14.18.2 •View source•Changelog•Report issue | |
---|---|---|
Install: | yarn add @thumbtack/thumbprint-react | |
Import: | import { Tooltip } from '@thumbtack/thumbprint-react'; |
Hover, click, or focus on the tooltip to open it.
Screen readers will announce the Tooltip
component text
when the button receives focus.
Hover, click, or focus on the tooltip to open rich tooltip with link inside tooltip content.
The theme
prop makes it possible to use tooltips on dark backgrounds.
Tooltips can also be used with the Link
and ThemedLink
components.
children
A function that renders JSX and receives an object with ref
, onMouseEnter
, onFocus
,
onMouseLeave
, onBlur
, onClick
, and ariaLabel
. All of these props must be added to
the component within the render prop.
(args: ChildrenPropTypes) => JSX.Element
text
Plain text that will appear within the tooltip. Links and formatted content are not allowed.
string
cta
Tooltip cta in form of text button/link for rich tooltip
This prop can be one of the following 2 types:
{
type: 'link';
href: string;
text: string;
onClick?: () => void;
}
{
type: 'button';
onClick: () => void;
text: string;
}
theme
Controls the look of the tooltip.
This prop can be one of the following 2 types:
'light'
'dark'
'dark'
position
Determines where the tooltip will attempt to position itself relative to the children
. The
tooltip will reposition itself to fit within the contianer.
This prop can be one of the following 2 types:
'top'
'bottom'
'top'
closeDelayLength
Number in milliseconds that determines how long to wait before closing the tooltip when the
onMouseLeave
event fires. A small delay prevents the tooltip from closing if the user
moves their cursor from the button to the tooltip. This value should only be set to 0
when
two or more tooltip components are used near each other.
This prop can be one of the following 2 types:
0
200
200
container
By default tooltips will render right before the </body>
tag.
Setting the container
to inline
causes the tooltip to remain where it was added to the
DOM.
This option is helpful to work around z-index and positioning issues.
This prop can be one of the following 2 types:
'inline'
'body'
'body'
zIndex
Adds a z-index
to the tooltip. Before using this prop, try to use container="inline"
.
number
persistTooltipOnClick
Persist tooltip and not hide on click
boolean