
Product
Introducing Socket Scanning for VS Code Marketplace Extensions
Socket now scans VS Code extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.
use-css-var
Advanced tools
React hook that will allow you to control randomly generated CSS variable.
React hook that will allow you to control randomly generated CSS variable.
package is already shipped with types for TypeScript
yarn add use-css-var
or
npm i --save use-css-var
Simple example with styled components:
import React, { useState, useCallback } from 'react';
import styled from 'styled-components';
import { useCssVar } from 'use-css-var';
const Box = styled.div<{ colorVar: string }>`
width: 20px;
height: 20px;
background-color: var(--${({ colorVar }) => colorVar});
`;
const Example = () => {
const [isRed, setIsRed] = useState(true);
const colorVar = useCssVar(isRed ? 'red' : 'blue');
const handleClick = useCallback(() => setIsRed(prev => !prev), []);
return <Box colorVar={colorVar} onClick={handleClick} />;
}
Check out another example with lots of state changes in example app: https://github.com/michal-wrzosek/react-component-lib/blob/master/example/src/App.tsx
Live demo: https://michal-wrzosek.github.io/use-css-var/
This package is still in an experimental phase and contribution is very welcomed.
This package was bootstrapped with react-component-lib
FAQs
React hook that will allow you to control randomly generated CSS variable.
The npm package use-css-var receives a total of 3 weekly downloads. As such, use-css-var popularity was classified as not popular.
We found that use-css-var 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.

Product
Socket now scans VS Code extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.

Research
/Security News
Socket uncovered two malicious VS Code themes in a GlassWorm-linked cluster with thousands of installs across VS Code Marketplace and Open VSX.

Security News
/Company News
Capital One is partnering with Socket to proactively secure its open source supply chain.