@@ -40,31 +40,76 @@ The `place` prop and the `data-tooltip-place` attribute accept the following val
40
40
41
41
``` jsx
42
42
import { Tooltip } from ' react-tooltip' ;
43
+ const PLACES = [' top' , ' top-start' , ' top-end' , ' right' , ' right-start' , ' right-end' , ' bottom' , ' bottom-start' , ' bottom-end' , ' left' , ' left-start' , ' left-end' ]
43
44
44
45
< a id= " my-tooltip-anchor" > ◕‿‿◕< / a>
45
- < Tooltip anchorSelect= " #my-tooltip-anchor" content= " Hello world from the top!" place= " top" / >
46
- < Tooltip anchorSelect= " #my-tooltip-anchor" content= " Hello world from the right!" place= " right" / >
47
- < Tooltip anchorSelect= " #my-tooltip-anchor" content= " Hello world from the bottom!" place= " bottom" / >
48
- < Tooltip anchorSelect= " #my-tooltip-anchor" content= " Hello world from the left!" place= " left" / >
46
+ {PLACES .map (place => (
47
+ < Tooltip
48
+ key= {place}
49
+ anchorSelect= " #my-tooltip-anchor"
50
+ content= {` Hello world from the ${ place} !` }
51
+ place= {place}
52
+ / >
53
+ ))}
49
54
```
50
55
51
- <TooltipAnchor id = " my-tooltip-anchor" >◕‿‿◕</TooltipAnchor >
52
- <Tooltip anchorSelect = " #my-tooltip-anchor" content = " Hello world from the top!" place = " top" />
53
- <Tooltip anchorSelect = " #my-tooltip-anchor" content = " Hello world from the right!" place = " right" />
54
- <Tooltip anchorSelect = " #my-tooltip-anchor" content = " Hello world from the bottom!" place = " bottom" />
55
- <Tooltip anchorSelect = " #my-tooltip-anchor" content = " Hello world from the left!" place = " left" />
56
+ export const PlacementExampleAttributes = () => {
57
+ const PLACES1 = [' top' , ' right' , ' bottom' , ' left' ];
58
+ const PLACES2 = [' top-start' , ' right-start' , ' bottom-start' , ' left-start' ];
59
+ const PLACES3 = [' top-end' , ' right-end' , ' bottom-end' , ' left-end' ];
60
+
61
+ return (
62
+ <>
63
+ <div style = { {display: ' flex' , gap: ' 16px' }} >
64
+ <TooltipAnchor id = " my-tooltip-anchor1" >◕‿‿◕</TooltipAnchor >
65
+ <TooltipAnchor id = " my-tooltip-anchor2" >◕‿‿◕</TooltipAnchor >
66
+ <TooltipAnchor id = " my-tooltip-anchor3" >◕‿‿◕</TooltipAnchor >
67
+ </div >
68
+ <div >
69
+ { PLACES1 .map (place => (
70
+ <Tooltip
71
+ key = { place }
72
+ anchorSelect = " #my-tooltip-anchor1"
73
+ content = { ` Hello world from the ${place }! ` }
74
+ place = { place }
75
+ />
76
+ ))}
77
+ { PLACES2 .map (place => (
78
+ <Tooltip
79
+ key = { place }
80
+ anchorSelect = " #my-tooltip-anchor2"
81
+ content = { ` Hello world from the ${place }! ` }
82
+ place = { place }
83
+ />
84
+ ))}
85
+ { PLACES3 .map (place => (
86
+ <Tooltip
87
+ key = { place }
88
+ anchorSelect = " #my-tooltip-anchor3"
89
+ content = { ` Hello world from the ${place }! ` }
90
+ place = { place }
91
+ />
92
+ ))}
93
+ </div >
94
+ </>
95
+ )
96
+ }
97
+
98
+ <PlacementExampleAttributes />
99
+
100
+
56
101
57
102
### Using ` place ` prop
58
103
59
104
``` jsx
60
105
import { Tooltip } from ' react-tooltip' ;
61
106
62
- const PLACES = [' top' , ' right' , ' bottom' , ' left' ]
107
+ const PLACES = [' top' , ' top-start ' , ' top-end ' , ' right' , ' right-start ' , ' right-end ' , ' bottom' , ' bottom-start ' , ' bottom-end ' , ' left' , ' left-start ' , ' left-end ' ]
63
108
const [place , setPlace ] = useState (0 )
64
109
65
110
< a
66
111
data- tooltip- id= " my-tooltip"
67
- onClick= {() => setPlace (p => (p + 1 ) % 4 )}
112
+ onClick= {() => setPlace (p => (p + 1 ) % 12 )}
68
113
>
69
114
◕‿‿◕
70
115
< / a>
@@ -76,14 +121,14 @@ const [place, setPlace] = useState(0)
76
121
```
77
122
78
123
export const PlacementExample = () => {
79
- const PLACES = [' top' , ' right' , ' bottom' , ' left' ]
124
+ const PLACES = [' top' , ' top-start ' , ' top-end ' , ' right' , ' right-start ' , ' right-end ' , ' bottom' , ' bottom-start ' , ' bottom-end ' , ' left' , ' left-start ' , ' left-end ' ];
80
125
const [place, setPlace] = useState (0 )
81
126
82
127
return (
83
128
<>
84
129
<TooltipAnchor
85
130
data-tooltip-id = " my-tooltip"
86
- onClick = { () => setPlace (p => (p + 1 ) % 4 )}
131
+ onClick = { () => setPlace (p => (p + 1 ) % 12 )}
87
132
>
88
133
◕‿‿◕
89
134
</TooltipAnchor >
0 commit comments