2020and popover library powered by Popper.js. This is a lightweight wrapper that
2121lets you use it declaratively in React.
2222
23+ <!--
2324## 💎 Examples
2425
2526### Tooltips
@@ -30,6 +31,7 @@ lets you use it declaratively in React.
3031### Popovers
3132
3233- [Accessible Emoji Reaction Picker](https://codesandbox.io/s/1vzvoo9mwl)
34+ -->
3335
3436## 🚀 Installation
3537
@@ -47,12 +49,14 @@ Requires React 16.8+
4749
4850## 🖲 Usage
4951
50- Wrap the ` <Tippy /> ` component around the element, supplying the tooltip's
51- content as the ` content ` prop. It can take a string or a tree of React elements.
52+ Import the ` Tippy ` component and the core CSS. Wrap the ` <Tippy /> ` component
53+ around the element, supplying the tooltip's content as the ` content ` prop. It
54+ can take a string or a tree of React elements.
5255
5356``` jsx
5457import React from ' react'
5558import Tippy from ' @tippy.js/react'
59+ import ' tippy.js/dist/tippy.css'
5660
5761const StringContent = () => (
5862 < Tippy content= " Hello" >
@@ -101,22 +105,17 @@ element as a workaround.
101105
102106``` jsx
103107< Tippy content= " Tooltip" >
104- < span>
105- < LegacyComponent> Unfortunately < / LegacyComponent>
108+ < span tabindex = " 0 " >
109+ < LegacyComponent> Content < / LegacyComponent>
106110 < / span>
107111< / Tippy>
108112```
109113
110- > Although Tippy will add ` tabindex ` for you on the ` <span> ` which allows it to
111- > receive focus, it may affect accessibility with regards to screenreaders,
112- > since ` <span> ` is not traditionally focusable (unlike a ` <button> ` for
113- > example).
114-
115114## 🧬 Props
116115
117- All of the native Tippy.js options can be passed as props .
116+ All of the native Tippy.js props can be passed to the component .
118117
119- Visit [ All Options ] ( https://atomiks.github.io/tippyjs/all-options / ) to view the
118+ Visit [ All Props ] ( https://atomiks.github.io/tippyjs/all-props / ) to view the
120119complete table.
121120
122121``` jsx
@@ -132,9 +131,9 @@ complete table.
132131< / Tippy>
133132```
134133
135- In addition, there are 4 more props added specifically for the React component.
134+ In addition, there are 3 more props added specifically for the React component.
136135
137- ### ` className?: string ` (v2.1)
136+ ### ` className?: string `
138137
139138A React alternative to the ` theme ` prop. The className gets added to the tooltip
140139element's class list as expected, without adding ` -theme ` as a suffix.
@@ -205,28 +204,28 @@ function App() {
205204> ** Note** : You should also set the ` hideOnClick ` prop to ` false ` if you don't
206205> want the tippy to hide when the user clicks on the document somewhere.
207206
208- ### ` onCreate?: (instance: Instance) => void `
209-
210- Callback invoked when the tippy instance has been created. Use this when you
211- need to store the tippy instance on the component.
207+ ### Plugins
212208
213- This should only be done for advanced (imperative) manipulation of the tippy
214- instance – in most cases using props should suffice.
209+ Tippy.js splits certain props into separate pieces of code called plugins to
210+ enable treeshaking, so that users who don't need the prop's functionality are
211+ not burdened with the cost of it.
215212
216213``` jsx
214+ import Tippy from ' @tippy.js/react'
215+ import { followCursor } from ' tippy.js'
216+ import ' tippy.js/dist/tippy.css'
217+
217218function App () {
218- const tippyInstance = useRef ()
219219 return (
220- < Tippy
221- content= " Tooltip"
222- onCreate= {instance => (tippyInstance .current = instance)}
223- >
220+ < Tippy content= " Tooltip" followCursor= {true } plugins= {[followCursor]}>
224221 < button / >
225222 < / Tippy>
226223 )
227224}
228225```
229226
227+ [ Read more about plugins here] ( https://atomiks.github.io/tippyjs/plugins/ ) .
228+
230229### Default props
231230
232231You can create a new component file that exports a wrapper component that has
@@ -264,7 +263,6 @@ export function Tooltip(props) {
264263export function Popover (props ) {
265264 return (
266265 < Tippy
267- animateFill= {false }
268266 interactive= {true }
269267 interactiveBorder= {10 }
270268 animation= " scale"
@@ -295,24 +293,25 @@ You can nest the components like so:
295293< / Tippy>
296294```
297295
298- ## 📚 ` <TippyGroup /> `
296+ ## 📚 ` <TippySingleton /> `
299297
300- Wraps the [ ` tippy.group() ` ] ( https://atomiks.github.io/tippyjs/misc/#groups )
298+ Wraps the
299+ [ ` createSingleton() ` ] ( https://atomiks.github.io/tippyjs/addons/#singleton )
301300method.
302301
303302``` jsx
304- import Tippy , { TippyGroup } from ' @tippy.js/react'
303+ import Tippy , { TippySingleton } from ' @tippy.js/react'
305304
306305function App () {
307306 return (
308- < TippyGroup delay= {1000 }>
307+ < TippySingleton delay= {1000 }>
309308 < Tippy content= " a" >
310309 < button / >
311310 < / Tippy>
312311 < Tippy content= " b" >
313312 < button / >
314313 < / Tippy>
315- < / TippyGroup >
314+ < / TippySingleton >
316315 )
317316}
318317```
@@ -322,7 +321,7 @@ function App() {
322321<img src =" https://img.shields.io/bundlephobia/minzip/@tippy.js/react.svg?color=%2373bd4b&style=for-the-badge " alt =" Bundle size " >
323322
324323- ` popper.js ` ≈ 7 kB
325- - ` tippy.js ` ≈ 7 .5 kB (including CSS)
324+ - ` tippy.js ` ≈ 5 .5 kB (including CSS)
326325- ` @tippy.js/react ` ≈ 1 kB
327326
328327If you're using Popper.js for other parts of your app, the added cost becomes
0 commit comments