solid-presence
TypeScript icon, indicating that this package has built-in type declarations

0.1.6 • Public • Published

SolidJS utility that manages the presence of an element in the DOM while being aware of pending animations.

Usage

The utility returns a boolean called present which indicates if the element should be present in the DOM or not.

The state variable can be used to get the current state of the presence. Valid states are present, hiding or hidden.

import createPresence from 'solid-presence'
const DialogContent: Component<{
  open?: boolean
}> = (props) => {
  const [dialogRef, setDialogRef] = createSignal<HTMLElement | null>(null)

  const { present } = createPresence({
    show: () => props.open,
    element: dialogRef,
  })

  return (
    <Show when={present()}>
      <div ref={setDialogRef}>Dialog</div>
    </Show>
  )
}

Further Reading

This utility is from the maintainers of corvu, a collection of unstyled, accessible and customizable UI primitives for SolidJS. It is also documented in the corvu docs under Presence.

Package Sidebar

Install

npm i solid-presence

Weekly Downloads

1,812

Version

0.1.6

License

MIT

Unpacked Size

7.33 kB

Total Files

5

Last publish

Collaborators

  • giyomoon