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

postcss-mixins

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-mixins

PostCSS plugin for mixins

  • 5.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
522K
increased by7.86%
Maintainers
1
Weekly downloads
 
Created

What is postcss-mixins?

The postcss-mixins package allows you to define and use mixins in your CSS, which can help you avoid code repetition and make your stylesheets more maintainable. Mixins are reusable chunks of code that you can include in other rulesets.

What are postcss-mixins's main functionalities?

Defining and Using Mixins

You can define a mixin using the @mixin directive and then include it in other rulesets using the @include directive. This helps in reusing common styles across different selectors.

/* Define a mixin */
@mixin border-radius($radius) {
  border-radius: $radius;
}

/* Use the mixin */
.button {
  @include border-radius(5px);
}

Parameterizing Mixins

Mixins can accept parameters, allowing you to customize the output of the mixin for different use cases. This makes your mixins more flexible and powerful.

/* Define a mixin with parameters */
@mixin box-shadow($x, $y, $blur, $color) {
  box-shadow: $x $y $blur $color;
}

/* Use the mixin with different parameters */
.card {
  @include box-shadow(2px, 2px, 5px, rgba(0, 0, 0, 0.3));
}

.modal {
  @include box-shadow(0, 4px, 10px, rgba(0, 0, 0, 0.5));
}

Conditional Logic in Mixins

You can include conditional logic within your mixins to handle different scenarios. This example shows how to create a responsive mixin that adjusts a property based on a breakpoint.

/* Define a mixin with conditional logic */
@mixin responsive($property, $value, $breakpoint) {
  #{$property}: $value;
  @media (min-width: $breakpoint) {
    #{$property}: calc($value * 1.5);
  }
}

/* Use the mixin */
.container {
  @include responsive(width, 100px, 768px);
}

Other packages similar to postcss-mixins

Keywords

FAQs

Package last updated on 12 Aug 2016

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