Installation
npx shadcn@latest add @craftdotui/use-is-mobile
Usage
import { useIsMobile } from "@/hooks/use-is-mobile";
function ResponsiveComponent() {
const isMobile = useIsMobile();
return <div>{isMobile ? <MobileView /> : <DesktopView />}</div>;
}
API Reference
useIsMobile
A hook that detects whether the current viewport width is below the mobile breakpoint (768px).