A collection of zero-dependency hooks for SolidJS forked directly from Mantine Hooks.
Install it:
npm i bagon-hooks
# or
yarn add bagon-hooks
# or
pnpm add bagon-hooks
# or
bun add bagon-hooksUse it:
import { useHotkeys } from 'bagon-hooks';We want to achieve as 1:1 as possible with Mantine's original hooks. So you can always refer to their original docs. There are a few improvements and renaming because SolidJS has its own conventions. But just take note:
- We removed Solid's convention of
usevscreateas it's too confusing for familiarity with Mantine. So every hook in Bagon is prefixed withuse. - The only renaming we did was
state->signal. - Refer to Mantine's original docs for deeper examples and usecases.
- Refer to Bagon Hooks's docs for actual SolidJS examples.
- π³ Tree-shakable
- ποΈ TypeScript support
- π΅ For SolidJS
- π¦ Zero-dependencies (except Solid)
Based on the @mantine/hooks library.
-
use-callback-ref(Not needed, only used internally by mantine for preventing re-renders on a function) - use-click-outside
- use-clipboard
- use-collapse
- use-horizontal-collapse
- use-color-scheme
- use-counter
- use-debounced-callback
-
use-debounced-stateuse-debounced-signal - use-debounced-value
- use-did-update
- use-disclosure (β¨ Improved, slightly better than mantine thanks to
setfor passing to stuff likeonOpenChange) - use-document-title
- use-document-visibility
- use-drag
- use-event-listener
- use-eye-dropper (β¨ improved, state management is inside the hook)
- use-favicon (β¨ improved, more flexible, better control)
- use-fetch
- use-file-dialog
- use-floating-window
- use-focus-return
- use-focus-trap
- use-focus-within
-
use-force-update(Not needed β Solid has fine-grained reactivity; no force re-render) - use-fullscreen
- use-hash
- use-headroom
- use-hotkeys
- use-hover
- use-id (Added, but note that there is
createUniqueIdin Solid) - use-idle (Added, but note that there is
createIdleTimerthe official solid-primitives as well) - use-in-viewport
- use-input-state
- use-intersection (Added, but note that there is
createIntersectionObserverin the official solid-primitives as well) - use-interval
-
use-is-first-render(Every component function in SolidJS runs only once! Every component is first render only π) -
use-isomorphic-effect(Solid'screateEffectis technically already isomorphic because it doesn't error on SSR. Also, it also only runs on client-side.) - use-list-state
- use-local-storage
- use-local-storage-store (β¨ Improved, more similar to 'createStore' API).
-
use-logger(Omit β debug helper; prefer Solid DevTools) - use-long-press
- use-map
- use-mask
- use-media-query
-
use-merged-ref(Not needed β Solid refs compose differently; merge manually if required) - use-mounted
- use-mouse
- use-move
- use-mutation-observer
- use-network
- use-orientation
- use-os
- use-page-leave
- use-pagination
- use-previous
- use-queue
- use-radial-move
- use-reduced-motion
- use-resize-observer
- use-roving-index
- use-scroll-direction
- use-scroll-into-view
- use-scroll-spy β¨ (
scrollHostscoping +scrollTo(index)that wonβt scroll ancestors) - use-scroller
- use-selection
- use-session-storage
-
use-set-state(Not needed β use createStore from solid-js/store) - use-set
-
use-shallow-effect(Not needed β Solid effects track precisely; no shallow-compare deps) - use-splitter
- use-state-history
- use-text-selection
- use-throttled-callback
- use-throttled-state
- use-throttled-value
- use-timeout
- use-toggle
- use-uncontrolled
- use-validated-state
- use-viewport-size
-
use-window-event(Not needed β use createEffect + addEventListener (or useEventListener)) - use-window-scroll
- utils (clamp, random-id, range)
- use-keyboard (β¨ Runs even on single keys as opposed useHotkeys that only runs on combinations, so more general usecases)
- use-disclosure-data (β¨ Improved, an alternative to use-disclosure for data-driven disclosures. I use it)
- Docs Website (Powered by mdx + tailwind prose)
- Examples
- Tests?
This library is far from done. If you have time implementing the roadmap, feel free to submit a pull request. We always appreciate collaborators. If you find anything outdated, please make an issue. If you like this project, consider giving it a star! βοΈ
This project is licensed under the MIT License
- Mantine Hooks - amazing library for components and hooks, but currently not in SolidJS so we forked that part only.