A lightweight, framework-agnostic component that helps you visualize your screen size and breakpoints during development. While it's optimized for TailwindCSS, it can be customized to work with any CSS framework or vanilla CSS!
Using npm:
npm install tailwind-screen-size
Using yarn:
yarn add tailwind-screen-size
Using pnpm:
pnpm add tailwind-screen-size
Using bun:
bun add tailwind-screen-size
Add the following to your tailwind.config.js
or tailwind.config.ts
:
content: [
"./node_modules/tailwind-screen-size/**/*.{js,ts,jsx,tsx,vue,svelte}",
];
Add the following to your styles.css
:
@source "./node_modules/tailwind-screen-size/**/*.{js,ts,jsx,tsx,vue,svelte}";
Note: This package is compatible with Tailwind CSS 4.0.
import { TailwindScreenSize } from "tailwind-screen-size/react";
function App() {
return (
<div>
<TailwindScreenSize />
{/* Your app content */}
</div>
);
}
⚠️ Note: The Svelte implementation is currently in beta and may have some instability. However, it works seamlessly with both Svelte 4 and Svelte 5 (runes) out of the box!
<script>
import { TailwindScreenSize } from "tailwind-screen-size/svelte";
</script>
<div>
<TailwindScreenSize />
<!-- Your app content -->
</div>
Prop | Type | Default | Description |
---|---|---|---|
position |
'top-left' | 'top-right' | 'top-center' | 'bottom-left' | 'bottom-right' | 'bottom-center' |
'bottom-right' |
Position of the screen size indicator |
theme |
See Available Themes | 'dark' |
Visual theme of the indicator |
show |
boolean |
undefined |
Force show/hide the indicator. By default, only shows in development |
breakpoints |
Array<{ screenTitle: string; minWidth: number }> |
See Default Breakpoints | Custom breakpoints configuration |
showDefaultBreakpoints |
boolean |
true |
Whether to show the default Tailwind breakpoints |
hideNoTailwindCSSWarning |
boolean |
false |
Hide the "No TailwindCSS" warning |
className |
string |
'' |
Additional classes for the entire component |
containerClassName |
string |
'' |
Additional classes for the container |
textClassName |
string |
'' |
Additional classes for the dimension text |
dividerClassName |
string |
'' |
Additional classes for the divider |
breakpointClassName |
string |
'' |
Additional classes for the breakpoint indicators |
<TailwindScreenSize
// Position: 'top-left' | 'top-right' | 'top-center' | 'bottom-left' | 'bottom-right' | 'bottom-center'
position="bottom-right"
// Theme: See Available Themes section
theme="blue"
// Control visibility (defaults to development only)
show={true}
// Custom breakpoints
breakpoints={[
{ screenTitle: "mobile", minWidth: 320 },
{ screenTitle: "tablet", minWidth: 768 },
{ screenTitle: "desktop", minWidth: 1024 },
]}
// Show/hide default Tailwind breakpoints
showDefaultBreakpoints={false}
// Hide "No TailwindCSS" warning
hideNoTailwindCSSWarning={false}
// Custom classes (works with any CSS framework or vanilla CSS)
className="custom-container-class"
containerClassName="custom-container-class"
textClassName="custom-text-class"
dividerClassName="custom-divider-class"
breakpointClassName="custom-breakpoint-class"
/>
dark
- Dark background with light textlight
- Light background with dark textglass
- Frosted glass effect with backdrop blurminimal
- Transparent background with adaptive colorsAll Tailwind colors are available as themes:
slate
- Sophisticated graygray
- Pure grayzinc
- Neutral grayneutral
- True neutralstone
- Warm grayred
- Error, danger, passionorange
- Energy, creativityamber
- Warning, warmthyellow
- Attention, optimismlime
- Fresh, naturalgreen
- Success, growthemerald
- Rich, prosperityteal
- Calm, sophisticationcyan
- Technology, claritysky
- Openness, freedomblue
- Trust, depthindigo
- Wisdom, integrityviolet
- Luxury, mysterypurple
- Royalty, creativityfuchsia
- Energy, excitementpink
- Playful, femininerose
- Love, beautyconst defaultBreakpoints = [
{ screenTitle: "XS", minWidth: 0 },
{ screenTitle: "SM", minWidth: 640 },
{ screenTitle: "MD", minWidth: 768 },
{ screenTitle: "LG", minWidth: 1024 },
{ screenTitle: "XL", minWidth: 1280 },
{ screenTitle: "2XL", minWidth: 1536 },
];
By default, the component only shows in development mode (process.env.NODE_ENV === "development"
). You can override this behavior with the show
prop:
// Always show in any environment
<TailwindScreenSize show={true} />
// Never show
<TailwindScreenSize show={false} />
MIT