Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@vanilla-extract/css

Package Overview
Dependencies
Maintainers
0
Versions
127
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vanilla-extract/css

Zero-runtime Stylesheets-in-TypeScript

  • 1.17.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
704K
decreased by-12.25%
Maintainers
0
Weekly downloads
 
Created

What is @vanilla-extract/css?

@vanilla-extract/css is a zero-runtime CSS-in-TypeScript library. It allows you to write type-safe, themeable, and modular CSS using TypeScript. The library compiles your styles to static CSS at build time, ensuring no runtime overhead.

What are @vanilla-extract/css's main functionalities?

Creating Styles

This feature allows you to create CSS styles using TypeScript. The `style` function is used to define a class with various CSS properties.

import { style } from '@vanilla-extract/css';

const buttonStyle = style({
  backgroundColor: 'blue',
  color: 'white',
  padding: '10px 20px',
  borderRadius: '5px',
  ':hover': {
    backgroundColor: 'darkblue'
  }
});

Theming

Theming allows you to create and use design tokens in your styles. The `createTheme` function generates a theme class and variables that can be used in your styles.

import { createTheme, style } from '@vanilla-extract/css';

const [themeClass, vars] = createTheme({
  color: {
    primary: 'blue',
    secondary: 'green'
  },
  font: {
    body: 'Arial, sans-serif'
  }
});

const themedStyle = style({
  backgroundColor: vars.color.primary,
  color: vars.color.secondary,
  fontFamily: vars.font.body
});

Composition

Composition allows you to combine multiple styles into one. The `composeStyles` function is used to merge multiple style classes into a single class.

import { style, composeStyles } from '@vanilla-extract/css';

const baseStyle = style({
  padding: '10px',
  borderRadius: '5px'
});

const primaryButton = style({
  backgroundColor: 'blue',
  color: 'white'
});

const composedStyle = composeStyles(baseStyle, primaryButton);

Other packages similar to @vanilla-extract/css

FAQs

Package last updated on 20 Dec 2024

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