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

@stylable/runtime

Package Overview
Dependencies
Maintainers
5
Versions
195
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stylable/runtime

[![npm version](https://img.shields.io/npm/v/@stylable/runtime.svg)](https://www.npmjs.com/package/@stylable/runtime)

  • 0.1.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.5K
increased by62.17%
Maintainers
5
Weekly downloads
 
Created
Source

@stylable/runtime

npm version

@stylable/runtime provides the utility that is used to create the stylesheet functions that apply classNames and states to the DOM. It also exposes an optional DOM renderer that is responsible for loading CSS in its correct order.

End-users will usually not add this package directly as a dependency themselves, and would instead receive it as a dependency of their chosen integration (e.g. @stylable/webpack-plugin).

Usage

@stylable/runtime exposes two methods, Stylesheet and Renderer.

Stylesheet

The stylesheet function is returned when importing a Stylable stylesheet. It is used for creating the DOM-attributes required for CSS to be applied.

style(className: string, states?: StateMap, props: InheritedAttributes)
ArgumentTypeDescriptionRequired
classNamestringclassName to be namespacedtrue
statesStateMapobject containing states and their valuesfalse
inheritedAttributesInheritedAttributesprops passed to the root node from the parent component (automatically passing through className and data-* attributes)false
import style from './local.st.css';

props = {
    className: "app1211903207--root",
    "data-app1211903207-propstate": true
}

style('root');
// returns "{
//     "className": "local1211372639--root"
// }"

style('root', {localState: true});
// returns "{
//     "data-local1211372639-localstate": true,
//     "className": "local1211372639--root"
// }"

style('root', {localState: true}, props);
// returns "{
//     "data-local1211372639-localstate": true,
//     "data-app1211903207-propstate": true,
//     "className": "local1211372639--root app1211903207--root"
// }"

// The stylesheet function also exposes a map of classNames and their namespaced values.
style.root;
// returns "local1211372639--root"

Renderer

Responsible for managing CSS files, linking to the document and maintaining their correct order in your application.

License

Copyright (c) 2017 Wix.com Ltd. All Rights Reserved. Use of this source code is governed by a BSD license.

FAQs

Package last updated on 07 Aug 2018

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