Skip to content

Latest commit

 

History

History
37 lines (27 loc) · 692 Bytes

README.md

File metadata and controls

37 lines (27 loc) · 692 Bytes

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