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

@appjumpstart/vue-styletron

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@appjumpstart/vue-styletron

Use the Styletron CSS-in-JS library with Vue.js

  • 5.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
increased by250%
Maintainers
1
Weekly downloads
 
Created
Source

vue-styletron

Use the Styletron CSS-in-JS library with Vue.js

npm page Join the community on Spectrum

About

This is a very small amount of code to make Styletron easier to use within Vue.js components.

Installation

npm install @appjumpstart/vue-styletron --save

Usage

Client:

import VueStyletron from '@appjumpstart/vue-styletron'

// Use VueStyletron as a Vue plugin.
Vue.use(new VueStyletron())

Server (optional, for SSR):

const VueStyletron = require('@appjumpstart/vue-styletron/server')

// Create the VueStyletron instance.
const vueStyletron = new VueStyletron()

// Use VueStyletron as a Vue plugin.
Vue.use(vueStyletron)

// Use a Vue.js renderer to render your Vue.js app to a HTML string.
// https://ssr.vuejs.org/guide/bundle-renderer.html
let html = renderer.renderToString(context)

// Insert the stylesheet that Styletron generated when the app was rendered.
html = vueStyletron.insertStyles(html)

// This is just an example of sending an HTML response with Express.
res.type('text/html').send(html)

NOTE: You'll also need to insert a tag into your HTML template which defaults to {styles} but can be configured as the 3rd parameter to insertStyles.

Component:

<template>
  <div :class="`${styles.hello} mr-5`">
    Hello!
  </div>
</template>

<script>
export default {
  styles: { hello: { fontSize: '48px', textAlign: 'center' } }
}
</script>

Output:

<!DOCTYPE html>
<html>
  <head>
    <title>Test Template</title>
    <style class="_styletron_hydrate_">.ae{font-size:48px}.af{text-align:center}</style>
  </head>
  <body>
    <div data-server-rendered="true" class="ae af mr-5">
      Hello!
    </div>
  </body>
</html>

Server-Side Rendering (SSR)

Note: If you are using webpack-node-externals in the Webpack config make sure to add '@appjumpstart/vue-styletron' to the whitelist.

 

AppJumpstart

Keywords

FAQs

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