Skip to main content

Tooltip

Quick start

Here's a quick start guide to get started with the Tooltip component

Importing Component

import { Tooltip } from "@hover-design/react";

Code Snippets and Examples

Basic Tooltip
<div className="App">
<Tooltip withArrow label="Basic Tooltip">
<Button>Click To Open </Button>
</Tooltip>
</div>
Controlled Tooltip
const [isOpened, setIsOpened] = useState(false);
<div className="App">
<Tooltip
position="right"
withArrow
isOpened={isOpened}
label="Controlled Tooltip"
>
<Button
onMouseEnter={() => setIsOpened(true)}
onMouseLeave={() => setIsOpened(false)}
>
Click To Open
</Button>
</Tooltip>
</div>;
MultiLine Tooltip
<div className="App">
<Tooltip multiLine withArrow label="This is a multiLine Tooltip">
<Button>Click To Open </Button>
</Tooltip>
</div>
Target Width
<div className="App">
<Tooltip
width="target"
multiLine
withArrow
label="Width matches the target Width"
>
<Button>Click To Open </Button>
</Tooltip>
</div>

Props Reference

AttributesValuesDefault ValueOptional ?
position "bottom" | "left" | "right" | "top" | "bottom-end"| "bottom-start"| "left-end" | "left-start" | "right-end" | "right-start" | "top-end" | "top-start"bottomYes
labelJSX.Element No
isOpenedboolean
controlled value
falseYes
offsetstring
distance between Tooltip and Target element
4pxYes
borderRadiusstring4pxYes
widthstringfit-labelYes
withArrowbooleanfalseYes
arrowSizestring7pxYes
onChange(isOpened)=>void()=>{}Yes
zIndexstring1Yes
colorstring#2C2E33Yes
multiLinebooleanfalseYes
labelColorstringwhiteYes

Keyboard Controls

KeyAction
Space | EnterToggle Opened State
TabNavigate