Tooltip
import Tooltip from "@intility/bifrost-react/Tooltip";
Basic Tooltip
Also see <Dropdown>
Default behaviour is to automatically only display the tooltip on hover.
<Tooltip content="Good job hovering!">
<span>Hover me</span>
</Tooltip>
<Tooltip content="Good job hovering!">
<span>Hover me</span>
</Tooltip>
To make it accessible for keyboard users, make sure to use a focusable element
like <Button>
.
<Tooltip content="The muffin man?!">
<Button>Do you know?</Button>
</Tooltip>
<Tooltip
state="neutral"
content={
<div>
That you lost the game?
<Icon icon={faHeartCrack} marginLeft />
</div>
}
>
<Button variant="filled">Did you know?</Button>
</Tooltip>
<Tooltip content="The muffin man?!">
<Button>Do you know?</Button>
</Tooltip>
<Tooltip
state="neutral"
content={
<div>
That you lost the game?
<Icon icon={faHeartCrack} marginLeft />
</div>
}
>
<Button variant="filled">Did you know?</Button>
</Tooltip>
Compact Tooltip
Use variant='compact'
for smaller tooltip
<Tooltip content="Good job hovering!" variant="compact">
<span>Hover me</span>
</Tooltip>
<Tooltip content="Good job hovering!" variant="compact">
<span>Hover me</span>
</Tooltip>
Visible state
Show/hide the tooltip with visible
boolean prop.
Placement
The placement
prop allows you to set a preferred placement ("top"
is
default, see Floating UI docs for all
options).
States
Other than the default state
, there is also a more subtle 'neutral'
.
<Tooltip content="Neutral tooltip" state="neutral">
<span>Hover me</span>
</Tooltip>
<Tooltip content="Neutral tooltip" state="neutral">
<span>Hover me</span>
</Tooltip>