BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/diceui/base/use-mobile

use-mobile

diceui-base/use-mobile
FreeHook

diceui/base publishes no description for this item.

Install it

npx shadcn@latest add https://raw.githubusercontent.com/sadmann7/diceui/HEAD/docs/public/r/styles/base-vega/use-mobile.json

Source

hooks/use-mobile.tsraw.githubusercontent.com/sadmann7/diceui/HEAD/docs/public/r/styles/base-vega/use-mobile.json
1import * as React from "react";
2
3export function useIsMobile(mobileBreakpoint = 768) {
4 const [isMobile, setIsMobile] = React.useState<boolean | undefined>(
5 undefined,
6 );
7
8 React.useEffect(() => {
9 const mql = window.matchMedia(`(max-width: ${mobileBreakpoint - 1}px)`);
10 const onChange = () => {
11 setIsMobile(window.innerWidth < mobileBreakpoint);
12 };
13 mql.addEventListener("change", onChange);
14 setIsMobile(window.innerWidth < mobileBreakpoint);
15 return () => mql.removeEventListener("change", onChange);
16 }, [mobileBreakpoint]);
17
18 return !!isMobile;
19}

Files it writes

  • hooks/use-mobile.ts

Facts

Registry
diceui/base
Type
registry:hook
Access
Free
Files written
1
Licence
the repository states none
First indexed
2026-08-09
Last confirmed
yesterday

Go to the source

www.diceui.com sadmann7/diceui on GitHub Raw registry item This item as JSON

More from diceui/base

All 192 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
use-as-refuse-as-refdiceui/baseHooksFreeno deps
use-isomorphic-layout-effectuse-isomorphic-layout-effectdiceui/baseHooksFreeno deps
use-lazy-refuse-lazy-refdiceui/baseHooksFreeno deps
BlockDex

Built by

Kynth Studios

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 Studios

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 Studios

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