Socket
Socket
Sign inDemoInstall

stylus

Package Overview
Dependencies
22
Maintainers
5
Versions
182
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    stylus

Robust, expressive, and feature-rich CSS superset


Version published
Maintainers
5
Install size
1.96 MB
Created

Package description

What is stylus?

Stylus is a robust, expressive, and feature-rich CSS preprocessor that provides a powerful and efficient way to write CSS. It supports both an indented syntax and regular CSS style. Stylus helps in writing clean and manageable stylesheets, allowing the use of variables, mixins, functions, and many other techniques that make CSS more maintainable and extendable.

What are stylus's main functionalities?

Variables

Variables in Stylus allow you to store values that can be reused throughout your stylesheet. This example defines a variable 'main-color' and applies it to the body's text color.

main-color = #333
body
  color main-color

Mixins

Mixins in Stylus are a way to create reusable sets of properties. This mixin 'border-radius' applies the border radius across different browser prefixes and is used in a button.

border-radius(radius)
  -webkit-border-radius radius
  -moz-border-radius radius
  border-radius radius

button
  border-radius(5px)

Nesting

Nesting allows you to nest your CSS selectors in a way that follows the same visual hierarchy of your HTML. This example shows how to style a navigation bar using nesting.

nav
  ul
    margin 0
    padding 0
    list-style none
  li
    display inline-block
  a
    display block
    padding 6px 12px
    text-decoration none

Functions

Functions in Stylus can be defined to perform operations and can be used throughout the stylesheet. This example defines a simple 'add' function to calculate the sum of two values, used here to set padding.

add(a, b)
  a + b

div
  padding add(10px, 5px)

Other packages similar to stylus

Readme

Source

Stylus logo

Build Status Maintenance npm version npm Join the community on github discussion

Stylus is a revolutionary new language, providing an efficient, dynamic, and expressive way to generate CSS. Supporting both an indented syntax and regular CSS style.

Installation

$ npm install stylus -g

Basic Usage

Watch and compile a stylus file from command line with

stylus -w style.styl -o style.css

You can also try all stylus features on stylus-lang.com, build something with stylus on codepen or RunKit

IDE/Editor Support

IDE/Editorbuilt-in supportguideplugin support
WebStorm✅  bug reportUsing stylus with webstormN/A
VSCodeN/AStylus(maintainer: @iChenLei @d4rkr00t)
Sublime 2/3N/AStylus(maintainer: @billymoon)
AtomN/AStylus(maintainer: @matthojo)
VimN/Avim-stylus(maintainer: @iloginow)

Missing your favorite IDE/Editor support ? Please report to us via stylus issues

Modern bundler/task-runner Support

Bundlerbuilt-in supportguideplugin support
webpackUsing stylus with webpackstylus-loader
viteUsing stylus with viteN/A
parcelUsing stylus with parcel v1 | v2N/A
fuse-boxUsing stylus with fuse-boxN/A
snowpackSnowpack plugins guidesnowpack-plugin-stylus
gulpN/Agulp-stylus
gruntN/Agrunt-contrib-stylus
rollupN/Arollup-plugin-stylus-compiler

Missing your favorite modern bundler/task-runner support ? Please report to us via stylus issues

Example

border-radius()
  -webkit-border-radius: arguments
  -moz-border-radius: arguments
  border-radius: arguments

body a
  font: 12px/1.4 "Lucida Grande", Arial, sans-serif
  background: black
  color: #ccc

form input
  padding: 5px
  border: 1px solid
  border-radius: 5px

compiles to:

body a {
  font: 12px/1.4 "Lucida Grande", Arial, sans-serif;
  background: #000;
  color: #ccc;
}
form input {
  padding: 5px;
  border: 1px solid;
  -webkit-border-radius: 5px;
  -moz-border-radius: 5px;
  border-radius: 5px;
}

the following is equivalent to the indented version of Stylus source, using the CSS syntax instead:

border-radius() {
  -webkit-border-radius: arguments
  -moz-border-radius: arguments
  border-radius: arguments
}

body a {
  font: 12px/1.4 "Lucida Grande", Arial, sans-serif;
  background: black;
  color: #ccc;
}

form input {
  padding: 5px;
  border: 1px solid;
  border-radius: 5px;
}

Features

Stylus has many features. Detailed documentation links follow:

Community modules

Stylus cheatsheet

Authors

More Information

Code of Conduct

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

License

(The MIT License)

Copyright (c) Automattic <developer.wordpress.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Keywords

FAQs

Last updated on 04 Sep 2021

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc