š± A tiny utility to detect responsive breakpoints in any modern JavaScript framework (React, Vue, Svelte, etc.).
npm install responsive-detect
or
yarn add responsive-detect
import { useBreakpoint } from 'responsive-detect'
const breakpoints = {
mobile: 0,
tablet: 768,
desktop: 1024
}
export default function App() {
const current = useBreakpoint(breakpoints)
return (
<div>
<h1>Current: {current}</h1>
</div>
)
}
<script setup lang="ts">
import { useBreakpoint } from 'responsive-detect'
const breakpoints = {
mobile: 0,
tablet: 768,
desktop: 1024
}
const current = useBreakpoint(breakpoints)
</script>
<template>
<div>Current: {{ current }}</div>
</template>
<script lang="ts">
import { useBreakpoint } from 'responsive-detect'
const breakpoints = {
mobile: 0,
tablet: 768,
desktop: 1024
}
const current = useBreakpoint(breakpoints)
</script>
<h1>Current: {$current}</h1>
Here are example projects demonstrating the usage of responsive-detect
in different frameworks:
You can clone the examples or add the responsive-detect
package to your existing project to test responsiveness.
useBreakpoint(breakpoints)
A lightweight utility hook that returns the current active breakpoint.
Name | Type | Description |
---|---|---|
breakpoints | Record<string, number> |
Object with named breakpoints in pixels |
A reactive value with the current breakpoint label (e.g., "mobile", "tablet", "desktop").
MIT Ā© 2025 Santosh Shebannavar