@@ -18,6 +18,7 @@ import { stackblitzPrefillConfig } from '../../../previewer/codePreviewer';
18
18
19
19
- [ Tooltip] ( #Tooltip )
20
20
- [ Overview] ( #overview )
21
+ - [ Usage] ( #usage )
21
22
- [ Toggletips vs Tooltips] ( #toggletips-vs-tooltips )
22
23
- [ Customizing the content of a tooltip] ( #customizing-the-content-of-a-tooltip )
23
24
- [ Tooltip alignment] ( #tooltip-alignment )
@@ -31,18 +32,41 @@ import { stackblitzPrefillConfig } from '../../../previewer/codePreviewer';
31
32
32
33
You can use the ` Tooltip ` component as a wrapper to display a popup for an
33
34
interactive element that you provide. If you are trying to place interactive
34
- content inside of the ` Tooltip ` itself, consider using ` Toggletip ` instead. You
35
- can provide the interactive element as a child to ` Tooltip ` , for example:
35
+ content inside of the ` Tooltip ` itself, consider using ` Toggletip ` instead.
36
+
37
+ ### Usage
38
+
39
+ ` Tooltip ` accepts a single child for its ` children ` prop. It is important that
40
+ the child is an interactive element, for example:
36
41
37
42
``` jsx
38
43
< Tooltip label= " Close" >
39
44
< button type= " button" > X < / button>
40
45
< / Tooltip>
41
46
```
42
47
43
- ` Tooltip ` accepts a single child for its ` children ` prop. It is important that
44
- the component you provide renders an interactive element. In addition, you can
45
- specify the contents of the popup through the ` label ` or ` description ` prop.
48
+ When used with a component, props need to be spread on the child component.
49
+
50
+ ``` jsx
51
+ export default function App () {
52
+ return (
53
+ < Tooltip label= " Close" >
54
+ < CustomTrigger / >
55
+ < / Tooltip>
56
+ );
57
+ }
58
+
59
+ function CustomTrigger (props ) {
60
+ return (
61
+ < button type= " button" {... props}>
62
+ X
63
+ < / button>
64
+ );
65
+ }
66
+ ```
67
+
68
+ You can specify the contents of the popup through the ` label ` or ` description `
69
+ prop.
46
70
47
71
<Canvas
48
72
of = { TooltipStories .Default }
0 commit comments