Skip to content

How to register 'tw' and 'setup' globally ?? #82

Answered by tylerforesthauser
Cappuuuu asked this question in Q&A
Discussion options

You must be logged in to vote

Hey hey! I'd like to just jump in here too since I am also a Nuxt user who's aspiring to become a Twind user. I've thrown together a quick demo of one way you could go about using Twind anywhere in your Nuxt app.

https://codesandbox.io/s/nuxtjs-twind-s90bw

The approach is to create a tw instance in a plugin (~/plugins/twind.js) and it's here you can include your config. You then inject that instance into your Nuxt app for use virtually anywhere. I've elected to simply use a computed property so I could style directly in my template.

<template>
  <h1 :class="tw('text-4xl')">
    Hello
  </h1>
</template>

If it's of any use, please let me know.

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
1 reply
@Cappuuuu
Comment options

Comment options

You must be logged in to vote
5 replies
@sastan
Comment options

@tylerforesthauser
Comment options

@tylerforesthauser
Comment options

@sastan
Comment options

@Cappuuuu
Comment options

Answer selected by Cappuuuu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants