@solid-primitives/page-visibility
Version:
Primitive to track page visibility
30 lines (29 loc) • 791 B
TypeScript
import { Accessor } from "solid-js";
/**
* Creates a signal with a boolean value identifying the page visibility state.
*
* @example
* ```ts
* const visible = createPageVisibility();
*
* createEffect(() => {
* visible() // => boolean
* })
* ```
*/
export declare const createPageVisibility: () => Accessor<boolean>;
/**
* Returns a signal with a boolean value identifying the page visibility state.
*
* This is a [singleton root primitive](https://github.com/solidjs-community/solid-primitives/tree/main/packages/rootless#createSingletonRoot) except if during hydration.
*
* @example
* ```ts
* const visible = usePageVisibility();
*
* createEffect(() => {
* visible() // => boolean
* })
* ```
*/
export declare const usePageVisibility: () => Accessor<boolean>;