New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@shopify/css-utilities

Package Overview
Dependencies
Maintainers
19
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@shopify/css-utilities

A set of CSS styling-related utilities

  • 1.1.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
19K
increased by6.16%
Maintainers
19
Weekly downloads
 
Created
Source

@shopify/css-utilities

Build Status Build Status License: MIT npm version npm bundle size (minified + gzip)

A set of CSS styling-related utilities.

Installation

$ yarn add @shopify/css-utilities

Both classNames and variationName are helper functions that are use to generate class names.

classNames

Is a straight export of classnames. It returns a classNames string that are conditionally joined together.

variationName

Is a utility that returns a camelCase string combining the name and value passed in.

Usage

Given this CSS file for a Square React component:

.Square {
  color: transparent;
}

.sizeSmall {
  height: 20px
  width: 20px
}

.sizeLarge {
  height: 44px
  width: 44px
}

.colorWhite {
  background-color: white;
}

.colorBlack {
  background-color: black;
}

The following can be use to generate different class names for the component based on its props:

interface Props {
  size: 'small' | 'large';
  color: 'white' | 'black';
}

function Square({size, color}: Props) {
  const className = classNames(
    styles.Square,
    styles[variationName('color', color)],
    styles[variationName('size', size)],
  );

  return <div className={className} />;
}

FAQs

Package last updated on 13 Apr 2021

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc