
Security News
How Enterprise Security Is Adapting to AI-Accelerated Threats
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.
@digitaliseringsbyran/tailwindcss-screens-in-dom
Advanced tools
Expose the active tailwind screen to the DOM.
Expose the active tailwind screen (like sm, md) in body:before, allowing you to use the value in Javascript. Read more
$ npm install @digitaliseringsbyran/tailwindcss-screens-in-dom --save-dev
Add the plugin to the plugins array in your tailwind config.
plugins: [
// ...
require('@digitaliseringsbyran/tailwindcss-screens-in-dom')()
]
You can pass an object to override the default settings.
// Default options
plugins: [
require('@digitaliseringsbyran/tailwindcss-screens-in-dom')({
noScreen: 'xs' // Viewports below the smallest defined screen.
})
]
Accessing the value in plain Javascript is explained here.
A example hook that returns the active screen as a string:
import { useState, useEffect } from 'react'
export default () => {
const isClient = typeof window === 'object'
function getScreen() {
return window
.getComputedStyle(document.querySelector('body'), ':before')
.getPropertyValue('content')
.replace(/"|'/g, '')
}
const initialState = isClient ? getScreen() : ''
const [screen, setScreen] = useState(initialState)
useEffect(() => {
if (!isClient) {
return false
}
function handleResize() {
setScreen(getScreen())
}
window.addEventListener('resize', handleResize)
return () => window.removeEventListener('resize', handleResize)
}, [])
return screen
}
import React from 'react'
import useTailwindBreakpoint from './useTailwindBreakpoint'
const ActiveScreen => {
const screen = useTailwindBreakpoint()
return (
<span>{screen}</span>
)
}
export default ActiveScreen
FAQs
Expose the active tailwind screen to the DOM.
We found that @digitaliseringsbyran/tailwindcss-screens-in-dom demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.