Skip to content

dotamir/solid-click-outside

Repository files navigation

solid-click-outside

pnpm

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>
  )
}

About

A SolidJS hook to detect clicks outside of an element

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published