Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
@unocss/postcss
Advanced tools
This package is in an experimental state right now. It doesn't follow semver, and may introduce breaking changes in patch versions.
PostCSS plugin for UnoCSS. Supports @apply
、@screen
and theme()
directives.
npm i -D @unocss/postcss
// postcss.config.cjs
module.exports = {
plugins: {
'@unocss/postcss': {
// Optional
content: ['**/*.{html,js,ts,jsx,tsx,vue,svelte,astro}'],
},
},
}
// uno.config.js
import { defineConfig, presetUno } from 'unocss'
export default defineConfig({
presets: [
presetUno(),
],
})
/* style.css */
@unocss;
@unocss
@unocss
at-rule is a placeholder. It will be replaced by the generated CSS.
You can also inject each layer individually:
/* style.css */
@unocss preflights;
@unocss default;
/*
Fallback layer. It's always recommended to include.
Only unused layers will be injected here.
*/
@unocss;
If you want to include all layers no matter whether they are previously included or not, you can use @unocss all
. This is useful if you want to include generated CSS in multiple files.
@unocss all;
@apply
.custom-div {
@apply text-center my-0 font-medium;
}
Will be transformed to:
.custom-div {
margin-top: 0rem;
margin-bottom: 0rem;
text-align: center;
font-weight: 500;
}
@screen
The @screen
directive allows you to create media queries that reference your breakpoints by name comes from theme.breakpoints
.
.grid {
--uno: grid grid-cols-2;
}
@screen xs {
.grid {
--uno: grid-cols-1;
}
}
@screen sm {
.grid {
--uno: grid-cols-3;
}
}
/* ... */
...
Will be transformed to:
.grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (min-width: 320px) {
.grid {
grid-template-columns: repeat(1, minmax(0, 1fr));
}
}
@media (min-width: 640px) {
.grid {
grid-template-columns: repeat(3, minmax(0, 1fr));
}
}
/* ... */
@screen
also supports lt
、at
variants
@screen lt
.grid {
--uno: grid grid-cols-2;
}
@screen lt-xs {
.grid {
--uno: grid-cols-1;
}
}
@screen lt-sm {
.grid {
--uno: grid-cols-3;
}
}
/* ... */
Will be transformed to:
.grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (max-width: 319.9px) {
.grid {
grid-template-columns: repeat(1, minmax(0, 1fr));
}
}
@media (max-width: 639.9px) {
.grid {
grid-template-columns: repeat(3, minmax(0, 1fr));
}
}
/* ... */
@screen at
.grid {
--uno: grid grid-cols-2;
}
@screen at-xs {
.grid {
--uno: grid-cols-1;
}
}
@screen at-xl {
.grid {
--uno: grid-cols-3;
}
}
@screen at-xxl {
.grid {
--uno: grid-cols-4;
}
}
/* ... */
Will be transformed to:
.grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (min-width: 320px) and (max-width: 639.9px) {
.grid {
grid-template-columns: repeat(1, minmax(0, 1fr));
}
}
@media (min-width: 1280px) and (max-width: 1535.9px) {
.grid {
grid-template-columns: repeat(3, minmax(0, 1fr));
}
}
@media (min-width: 1536px) {
.grid {
grid-template-columns: repeat(4, minmax(0, 1fr));
}
}
/* ... */
theme()
Use the theme()
function to access your theme config values using dot notation.
.btn-blue {
background-color: theme('colors.blue.500');
}
Will be compiled to:
.btn-blue {
background-color: #3b82f6;
}
FAQs
PostCSS plugin for UnoCSS
The npm package @unocss/postcss receives a total of 145,220 weekly downloads. As such, @unocss/postcss popularity was classified as popular.
We found that @unocss/postcss demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 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
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.