ComponentformZero dependencies
Hooks
SSR-safe React hooks: media query, localStorage, intersection, click-outside, copy, hotkey, and debounce.
Preview
Live Preview
Installation
Tokens guide →Add to your project via CLI (zero dependencies, code you own):
npx bigbullui add hooksOr install the full npm package:
npm install bigbulluiUsage
tsx4 lines
import { useCopy } from "@/components/ui/lib/hooks"; const { copied, copy } = useCopy();<button onClick={() => copy("BB-2026")}>{copied ? "Copied!" : "Copy"}</button>Source code
lib/hooks.tsZero third-party dependencies (only React + standard DOM APIs). Copy directly into your project:
tslib/hooks.ts311 lines
"use client"; import * as React from "react"; export function useMediaQuery(query: string): boolean { const subscribe = React.useCallback( (onStoreChange: () => void) => { if (typeof window === "undefined" || typeof window.matchMedia !== "function") { return () => {}; } const match = window.matchMedia(query); match.addEventListener("change", onStoreChange); return () => match.removeEventListener("change", onStoreChange); }, [query], ); const getSnapshot = React.useCallback( () =>Props
| Prop | Type | Description |
|---|---|---|
| useCopy | () => { copied: boolean; copy: (text: string) => void } | Clipboard copy with copied flag. |
| useLocalStorage | <T>(key: string, initial: T) => [T, setter] | Persisted state hook. |
| useMediaQuery | (query: string) => boolean | SSR-safe media query match. |
| useDebounce | <T>(value: T, delay: number) => T | Debounced value hook. |
| useHotkey | (combo, handler) => void | Keyboard shortcut hook. |
| useIntersection | (options?) => ref + visible | IntersectionObserver hook. |
| useClickOutside | (ref, handler) => void | Outside-click dismissal hook. |