useBreakpoint
A reactive composable for tracking active Tailwind CSS breakpoints and conditionally rendering content based on screen size.
Install: pnpm add-composable useBreakpoint
Conditional rendering
Render different components based on the device type.
API
current(ComputedRef<'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl'>): The current active breakpoint.isMobile(ComputedRef<boolean>): True if screen is smaller than md (768px).isTablet(ComputedRef<boolean>): True if screen is md or larger, but smaller than lg.isDesktop(ComputedRef<boolean>): True if screen is lg (1024px) or larger.atLeast((bp: Breakpoint) => Readonly<Ref<boolean>>): The viewport is at least this wide (min-width), like Tailwind md:. The breakpoint itself counts.smallerThan((bp: Breakpoint) => Readonly<Ref<boolean>>): The viewport is narrower than this breakpoint, like Tailwind max-md:.greaterThan((bp: Breakpoint) => Readonly<Ref<boolean>>): Deprecated alias of atLeast: it was always a min-width query, so the name was wrong.