solid-tippy
v1.0.0
Published
SolidJS bindings for Tippy.js
Maintainers
Readme
solid-tippy
SolidJS bindings for Tippy.js
Install
This version supports Solid 2.0. Solid 1 users stay on [email protected], which is kept on the solid-1 branch.
npm i tippy.js solid-tippyyarn add tippy.js solid-tippypnpm add tippy.js solid-tippyUsage
import { createSignal } from 'solid-js';
import { tippy, useTippy } from 'solid-tippy';
// As a ref directive
<button
ref={tippy(() => ({
props: {
content: 'This is a tooltip.',
},
}))}
>
Example
</button>;
// As a hook
const [anchor, setAnchor] = createSignal<HTMLElement>();
useTippy(anchor, {
props: {
content: 'This is a tooltip.',
},
});
<button
ref={(element) => {
setAnchor(() => element);
}}
>
Example
</button>;tippy replaces the use:tippy directive of Solid 1, because Solid 2 removed use: in favor of ref. Call it in a component body, not inside an effect.
Options
disabled: Disables the Tippy instance whentrue.hidden: Hides the Tippy instance whentrueand shows it whenfalse. When it is not set, the instance opens and closes on its own triggers.props: Props to be passed to the Tippy instance when creating or updating it. You can read more about it here.
tippy and tippyHeadless take the options as a function, so they track the signals it reads. useTippy and useTippyHeadless take a plain object. To make it reactive, pass an object with getters or a store.
Headless mode
You may use tippyHeadless or useTippyHeadless instead of tippy and useTippy for Headless Tippy instances.
License
MIT © lxsmnsyc
