
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Handle CSS style functions with no worries.
npm i -S css-func
Examples on how it can be used
const cssfunc = require('css-func');
// get dom element
const element = document.getElementById('#element');
// different ways to specify function parameters
cssfunc(element, 'transform').add('translate', '10px'); // "translate(10px)"
cssfunc(element, 'transform').add('translate', ['10px']); // "translate(10px)"
cssfunc(element, 'transform').add('translate', ['10px', '20px']); // "translate(10px, 20px)"
cssfunc(element, 'transform').add('rotate', '20deg'); // "rotate(20deg)"
console.log(element.style.transform); // "translate(10px, 20px) rotate(20deg)"
Custom variable that holds the cssfunc
instance
const filters = cssfunc(element, 'filter');
filters.add('blur', '10px');
filters.add('grayscale', '100%');
filters.update('blur', '20px');
filters.delete('blur');
filters.exists('blur'); // false
filters.get(); // "grayscale(100%)"
Gets the property from element
cssfunc(element, 'transform').get(); // "translate(10px, 20px) scale(1.1)"
string
Element property valueAdds or updates a function
Name | Type | Description | |
---|---|---|---|
fproperty | string | CSS function name | |
value | string array | CSS function parameters | |
autoUpdate=true | boolean | True to automatically update function if aleady presentTrue to automatically add new function if not present | Optional |
cssfunc(element, 'transform').add('rotate', '10px');
cssfunc(element, 'transform').add('translate', ['10px', '20px']);
cssfunc(element, 'transform').add('translateX', ['10px']);
boolean
True if a function was added or updatedUpdates or adds a function
Name | Type | Description | |
---|---|---|---|
fproperty | string | CSS function name | |
value | string array | CSS function parameters | |
autoAdd=true | boolean | True to automatically add new function if not present | Optional |
cssfunc(element, 'transform').update('rotate');
boolean
True if a function was updated or addedDelete functoin from element style property
Name | Type | Description | |
---|---|---|---|
fproperty | string | CSS function name |
cssfunc(element, 'transform').delete('rotate');
boolean
True if there was a function to deleteReturns true if function exists
Name | Type | Description | |
---|---|---|---|
fproperty | string | CSS function name |
cssfunc(element, 'transform').exists('rotate');
boolean
True if function existsFAQs
Handle CSS style functions with no worries
We found that css-func 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
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.