All Projects → jrowlingson → Stencil Tailwind

jrowlingson / Stencil Tailwind

Licence: mit
TailwindCSS plugin for Stencil

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Stencil Tailwind

Tailwindcss Figma Plugin
Figma Plugin for TailwindCSS
Stars: ✭ 165 (+534.62%)
Mutual labels:  plugin, tailwindcss
Tailwindcss Aspect Ratio
Aspect Ratio Plugin for tailwindcss framework
Stars: ✭ 243 (+834.62%)
Mutual labels:  plugin, tailwindcss
stencil-tailwind-plugin
Plugin for using tailwindcss with StencilJS
Stars: ✭ 17 (-34.62%)
Mutual labels:  stencil, tailwindcss
Vagrant Parallels
Vagrant Parallels Provider
Stars: ✭ 893 (+3334.62%)
Mutual labels:  plugin
Stencil Postcss
Autoprefixer plugin for Stencil
Stars: ✭ 19 (-26.92%)
Mutual labels:  stencil
Maizzle
Official Maizzle starter project.
Stars: ✭ 921 (+3442.31%)
Mutual labels:  tailwindcss
Genesis Simple Hook Guide
WordPress plugin that displays names of all Genesis hooks on the current page dynamically.
Stars: ✭ 25 (-3.85%)
Mutual labels:  plugin
Tailwind Clj
Clojure library for processing tailwind utility classes
Stars: ✭ 17 (-34.62%)
Mutual labels:  tailwindcss
Hxd Plugin
Handy HxD plugin for various conversions like base64
Stars: ✭ 24 (-7.69%)
Mutual labels:  plugin
Gridsome Starter Liebling
Grisome starter based on Ghost Liebling and tailwindcss.
Stars: ✭ 23 (-11.54%)
Mutual labels:  tailwindcss
Tabler Icons Viewer
An app to search & copy icons from the Tabler icons pack - a free to use library of over 500 high quality icons 😍
Stars: ✭ 23 (-11.54%)
Mutual labels:  tailwindcss
Intellij jahia plugin
Jahia's definitions.cnd files syntax highlighting, code completion, and other amazing stuff
Stars: ✭ 19 (-26.92%)
Mutual labels:  plugin
Nice Anim
An animate on scroll Web Component built with StencilJS
Stars: ✭ 23 (-11.54%)
Mutual labels:  stencil
Egghead Next
The frontend for egghead.io.
Stars: ✭ 896 (+3346.15%)
Mutual labels:  tailwindcss
Totem Danmaku
totem-danmaku is a plugin that provides danmaku support for Totem Player. totem弹幕为Gnome下的totem播放器提供弹幕支持
Stars: ✭ 24 (-7.69%)
Mutual labels:  plugin
Runconfigurationasaction
Provides a way to use IntelliJ run configurations as buttons
Stars: ✭ 17 (-34.62%)
Mutual labels:  plugin
Confiscate
Discover duplication glitches, abusive staff giving items, x-ray or simply poor server economy.
Stars: ✭ 23 (-11.54%)
Mutual labels:  plugin
Kafka Connect Elasticsearch Source
Kafka Connect Elasticsearch Source
Stars: ✭ 22 (-15.38%)
Mutual labels:  plugin
Wdl Ol
Enhanced version of Cockos' iPlug - A simple-to-use C++ framework for developing cross platform audio plugins and targeting multiple plugin APIs with the same code. VST / VST3 / Audiounit / RTAS / AAX (Native) formats supported. NOTE: THIS IS OBSOLETE, PLEASE SEE IPLUG2:
Stars: ✭ 906 (+3384.62%)
Mutual labels:  plugin
Figmiro Plugin
Figma Integration with Miro (Plugin)
Stars: ✭ 23 (-11.54%)
Mutual labels:  plugin

stencil-tailwind

This package is used in order to integrate with tailwindcss. It provides simple functionality for supporting a utility-first workflow within the Shadow DOM.

Note, this plugin specificially adds support for inline utilities (idiomatic Tailwind). If you find that this is not a requirement for your project you can opt to include Tailwind via @stencil/postcss. This will allow you to use the @apply directive and theme() function within your component's stylesheet. You can get started with the following configuration:

import { Config } from '@stencil/core'
import postcss from '@stencil/postcss'
import tailwind from 'tailwindcss'

export const config: Config = {
  plugins: [
    postcss({
      plugins: [ tailwind() ]
    })
  ]
}

Installation

First, npm install within the project:

npm install stencil-tailwind --save-dev

Next, within the project's stencil.config.js file, import the plugin and add it to the config's plugins config:

stencil.config.ts

import { Config } from '@stencil/core'
import tailwind from 'stencil-tailwind'

export const config: Config = {
  plugins: [
    tailwind()
  ]
}

Note, hot module reloading (hmr) is not yet supported. For local development, you'll need to update reloadStratgy to use the pageReload option:

export const config: Config = {
  devServer: {
    reloadStrategy: 'pageReload'
  }
}

Create your Tailwind config file (optional)

While Tailwind provides a sensible default configuration, it is often desirable to further customize your theme. This default configuration can be used as a starting point for such customizations. To customize your Tailwind installation, you will first need to generate a config file for your project using the included Tailwind CLI utility when you install the stencil-tailwind npm package.

npx tailwindcss init

This will generate a tailwind.config.js file at the root of your project.

Usage

Inline utilities

Utility classes can be used directly within JSX; they will be included in the component's shadow tree.

class MyComponent {
  render() {
    return (
      <div class="p-4 bg-red">
        <p class="text-sm text-white">This is JSX!</p>
      </div>
    );
  }
}

@Styles

Utilities can be conditionally applied using the Styles decorator. This decorator provides a simple wrapper for the classnames npm package.

class MyComponent {
  render() {
    return (
      <button class={this.classNames()}>
        Hello World
      </button>
    );
  }

  @Styles()
  private classNames = () => ({
    'p-4': true,
    'shadow hover:shadow-md': this.floating,
    'rounded-full': this.round
  })
}

Directives

Use the @apply directive to inline any existing utility classes into your external component stylesheet files. This is useful when you want to apply utilities to the shadow host.

:host {
  @apply font-bold py-2 px-4 rounded;
}

DSL (advanced)

A simple, declarative, runtime DSL can be used to provide sugar for conditionally applied utilties based on a Prop value. All classes will be included in the shadow tree at build time.

class MyComponent {

  /** specify the size of the button, defaults to m */
  @Prop({ reflect: true }) size: "s" | "m" | "l" = "m";

  render() {
    return (
      <button class="<px-4 py-3 text-sm> l<px-6 py-4 text-lg> s<px-3 py-2 text-xs>">
        Hello World
      </button>
    );
  }

}

The DSL is described by the following grammer:

class-containerprefix < class-list >

class-listclass-list class

class-listclass

classstring

prefixstring | ''

Options

The following plugin options may be configured:

stencil.config.ts

import tailwindcss from 'tailwindcss'

export const config: Config = {
  plugins: [
    tailwind({
      tailwind: tailwindcss('tailwind.config.js'),
      inputFile: './src/styles/app.css',
      includeTailwindCss: false
    })
  ]
}
  • tailwind: (optional) your own configuration file and version of TailwindCSS to be used.
  • inputFile: (optional) a stylesheet filepath to be used in place of the default.
  • includeTailwindCss: (optional) include global tailwind.css in the bundle (default: true)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].