Skip to content
This repository was archived by the owner on Nov 9, 2024. It is now read-only.

Commit 704e691

Browse files
committed
docs: add headless useSingleton usage
1 parent 74a0dc8 commit 704e691

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,35 @@ function App() {
370370
const [source, target] = useSingleton({disabled: true});
371371
```
372372

373+
### Headless singleton
374+
375+
The `render` prop takes the singleton content as a second parameter:
376+
377+
```jsx
378+
import Tippy, {useSingleton} from '@tippyjs/react/headless';
379+
380+
function App() {
381+
const [source, target] = useSingleton();
382+
383+
return (
384+
<>
385+
<Tippy
386+
singleton={source}
387+
render={(attrs, content) => <div {...attrs}>{content}</div>}
388+
delay={500}
389+
/>
390+
391+
<Tippy content="Hello" singleton={target}>
392+
<button>Reference</button>
393+
</Tippy>
394+
<Tippy content="Bye" singleton={target}>
395+
<button>Reference</button>
396+
</Tippy>
397+
</>
398+
);
399+
}
400+
```
401+
373402
## 📦 Bundle size
374403

375404
- `@popperjs/core` ≈ 6 kB

0 commit comments

Comments
 (0)