solid-click-outside
v0.0.1
Published
A SolidJS hook to detect clicks outside of an element
Downloads
19
Readme
solid-click-outside
A SolidJS hook to detect clicks outside of an element
Quick start
Install it:
npm i solid-click-outside
# or
yarn add solid-click-outside
# or
pnpm add solid-click-outside
Use it:
import useClickOutside from 'solid-click-outside'
const App = () => {
const [target, setTarget] = createSignal<HTMLElement | undefined>();
useClickOutside(target, () => {
console.log('clicked outside')
})
return (
<div ref={setTarget}>
Click outside this box. Open console to see the message.
</div>
)
}