
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
@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
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.