Socket
Socket
Sign inDemoInstall

@vanilla-extract/recipes

Package Overview
Dependencies
Maintainers
4
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vanilla-extract/recipes

Create multi-variant styles with a type-safe runtime API, heavily inspired by https://stitches.dev


Version published
Weekly downloads
119K
decreased by-0.94%
Maintainers
4
Weekly downloads
 
Created

What is @vanilla-extract/recipes?

@vanilla-extract/recipes is a package that provides a way to define and manage design tokens and styles in a type-safe manner. It allows you to create reusable style recipes that can be easily shared and maintained across your application.

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

Creating a Recipe

This feature allows you to create a recipe for a button component with different variants for color and size. The `recipe` function helps in defining base styles and variants, making it easy to manage and reuse styles.

const buttonRecipe = recipe({
  base: {
    padding: '10px 20px',
    borderRadius: '5px',
    border: 'none',
    cursor: 'pointer'
  },
  variants: {
    color: {
      primary: { backgroundColor: 'blue', color: 'white' },
      secondary: { backgroundColor: 'gray', color: 'black' }
    },
    size: {
      small: { fontSize: '12px' },
      large: { fontSize: '18px' }
    }
  },
  defaultVariants: {
    color: 'primary',
    size: 'small'
  }
});

Using a Recipe

This feature demonstrates how to use a recipe in a React component. The `buttonRecipe` function is called with the desired variants to apply the appropriate styles to the button.

import { buttonRecipe } from './styles.css';

const Button = ({ color, size, children }) => {
  return (
    <button className={buttonRecipe({ color, size })}>
      {children}
    </button>
  );
};

Other packages similar to @vanilla-extract/recipes

FAQs

Package last updated on 16 Jan 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