BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/optics/use-has-primary-touch

Use has primary touch

optics/use-has-primary-touch
FreeUtility

Hook utility: use-has-primary-touch

See it running

Open the demo on optics

optics.agusmayol.com.ar/components/use-has-primary-touch
Open
This registry sends X-Frame-Options, so its page cannot be embedded here. The link is the same page the frame would have shown.

Install it

npx shadcn@latest add https://optics.agusmayol.com.ar/r/use-has-primary-touch.json

Source

registry/optics/hooks/use-has-primary-touch.jsxoptics.agusmayol.com.ar/r/use-has-primary-touch.json
1import { useEffect, useState } from "react";
2
3export function useTouchPrimary() {
4 const [isTouchPrimary, setIsTouchPrimary] = useState(false);
5
6 useEffect(() => {
7 if (typeof window === "undefined") return;
8
9 const controller = new AbortController();
10 const { signal } = controller;
11
12 const handleTouch = () => {
13 const hasTouch = "ontouchstart" in window || navigator.maxTouchPoints > 0;
14 const prefersTouch = window.matchMedia("(pointer: coarse)").matches;
15 setIsTouchPrimary(hasTouch && prefersTouch);
16 };
17
18 const mq = window.matchMedia("(pointer: coarse)");
19 mq.addEventListener("change", handleTouch, { signal });
20 window.addEventListener("pointerdown", handleTouch, { signal });
21
22 handleTouch();
23
24 return () => controller.abort();
25 }, []);
26
27 return isTouchPrimary;
28}

Files it writes

  • registry/optics/hooks/use-has-primary-touch.jsx

Facts

Registry
optics
Type
registry:lib
Access
Free
Files written
1
Licence
MIT
First indexed
2026-08-01
Last confirmed
today

Go to the source

Docs on optics optics.agusmayol.com.ar AgusMayol/optics on GitHub Raw registry item This item as JSON

More from optics

All 79 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Cursor Rule: Back Endcursor-rule-back-endopticsUtilitiesFreeno deps
Cursor Rule: Bulk Processingcursor-rule-bulk-processingopticsUtilitiesFreeno deps
Cursor Rule: Commits Conventioncursor-rule-commits-conventionopticsUtilitiesFreeno deps
Cursor Rule: Front Endcursor-rule-front-endopticsUtilitiesFreeno deps
Cursor Rule: Generalcursor-rule-generalopticsUtilitiesFreeno deps
Cursor Rule: React Optimizationcursor-rule-react-optimizationopticsUtilitiesFreeno deps
Cursor Rule: Web Interface Guidelinescursor-rule-web-interface-guidelinesopticsUtilitiesFreeno deps
Get strict contextget-strict-contextopticsUtilitiesFreeno deps
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex