Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
postcss-utilities
Advanced tools
PostCSS plugin to add a collection of mixins, shortcuts, helpers and tools for your CSS
postcss-utilities is a PostCSS plugin that includes the most commonly used mixins, shortcuts and helpers. It's as easy as specifying @util utility-name
in your stylesheet, and postcss-utilities will handle the rest for you.
PostCSS has a lot of plugins and some of them use non-standard CSS properties to work as mixins or helpers. This is not a best way for a PostCSS plugin, because developers will not understand what is the source of this property.
"This plugin saves us from many tiny plugins with unknown properties" ‒@ai proposal postcss/issues/645
There are lot of Sass Mixins Libraries (over 65!), but postcss-utilities makes the difference. All mixins and helpers are built with JavaScript and you can add to your workflow with ease, as simple as adding autoprefixer or many others useful PostCSS plugins.
You can forget about copy mixins from project to project and focus on write your project specific mixins and use this plugin for the most generic helpers.
IMPORTANT: The list of utilities is open for suggestions.
.cfx {
@util clearfix;
}
.rounded-top {
@util border-top-radius(4px);
}
@util no-hover {
.box {
background-color: #666;
}
}
.cfx:after {
content: '';
display: block;
clear: both;
}
.rounded-top {
border-top-left-radius: 4px;
border-top-right-radius: 4px;
}
.no-hover .box {
background-color: #666;
}
Using PostCSS CLI you can do the following:
Install postcss-cli
and the plugin on your project directory:
npm install postcss-cli postcss-utilities --save-dev
Add a postcss
script to your package.json
:
"scripts": {
"postcss": "postcss input.css -u postcss-utilities -o output.css"
}
After this, you can run npm run postcss
and transform your input.css
into output.css
.
styled-jsx allows you to use full, scoped and component-friendly CSS in your JSX (rendered on the server or the client) and you can add @util
rules with postcss-utilities
.
npm install --save styled-jsx styled-jsx-plugin-postcss postcss-utilities
Add postcss
config in your package.json
:
"postcss": {
"plugins": {
"postcss-utilities": {}
}
}
Add styled-jsx/babel
to plugins in your babel configuration:
{
"plugins": [
"styled-jsx/babel"
]
}
Then write @util
rules in your code:
export default () => (
<div>
<p>only this paragraph will get the style :)</p>
<style jsx>{`
p {
color: red;
@util center;
}
`}</style>
</div>
)
postcss([ require('postcss-utilities')({ /* options*/ }) ])
See PostCSS docs for examples of your environment.
Type: string
Default: .no-hover
To use with no-hover
utility
Type: string
Default: .no-js
To use with no-js
utility
Type: boolean
Default: false
Set true
to use clearfix
method IE8 compatible
Type: string
Default: transform
Values: ['transform'|'flexbox']
To use with center
utility
Type: string
Default: indent
Values: ['indent'|'font']
To use with text-hide
utility
The list of utilities is open for suggestions.
FAQs
PostCSS plugin to add a collection of mixins, shortcuts, helpers and tools for your CSS
We found that postcss-utilities demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.