-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
README.md
70 lines (43 loc) · 2.19 KB
/
README.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Tooltip
Tooltip is a React component to render floating help text relative to a node when it receives focus or when the user places the mouse cursor atop it. If the tooltip exceeds the bounds of the page in the direction it opens, its position will be flipped automatically.
Accessibility note: the tooltip text is hidden from screen readers and assistive technologies that understand ARIA. To make it accessible, use an `aria-label` attribute on the same element the tooltip is applied to, preferably using the same text used for the tooltip.
## Usage
Render a Tooltip, passing as a child the element to which it should anchor:
```jsx
import { Tooltip } from '@wordpress/components';
const MyTooltip = () => (
<Tooltip text="More information">
<div>Hover for more information</div>
</Tooltip>
);
```
## Props
The component accepts the following props:
### position
The direction in which the tooltip should open relative to its parent node. Specify y- and x-axis as a space-separated string. Supports `"top"`, `"bottom"` y axis, and `"left"`, `"center"`, `"right"` x axis.
- Type: `String`
- Required: No
- Default: `"top center"`
### children
The element to which the tooltip should anchor.
**NOTE:** You must pass only a single child. Tooltip renders itself as a clone of `children` with a [`Popover`](/packages/components/src/popover/README.md) added as an additional child.
- Type: `Element`
- Required: Yes
### text
The tooltip text to show on focus or hover.
- Type: `String`
- Required: No
### shortcut (web only)
- Type: `string` or `object`
- Required: No
If shortcut is a string, it is expecting the display text. If shortcut is an object, it will accept the properties of `display` (string) and `ariaLabel` (string).
### delay (web only)
Time in milliseconds to wait before showing tooltip after the tooltip's visibility is toggled. This prop is currently only available for the web platforms.
- Type: `Number`
- Required: No
- Default: 700
### visible (native only)
Whether the tooltip should be displayed on initial render. This prop is currently only available for the native mobile app built with React Native.
- Type: `Boolean`
- Required: No
- Default: `false`