Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including tailwind-config with all npm packages installed. Try it out:

var tailwindConfig = require("tailwind-config")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

tailwind-config v0.1.2

Easily get values from your resolved tailwindcss config.

Tailwind Config

Easily get values from your resolved Tailwind CSS config.

import tailwind from 'tailwind-config'

const config = tailwind.config('./tailwind.config') // '#000'


I often like to import values from my Tailwind CSS config file to keep things consistent.

Before tailwindcss@1.0.0, you could easily just import your config file from within your project. After 1.0, your config is merged with the default config in the tailwindcss package.

This package merges your config with the default config, just like Tailwind does, so you can easily get those values.


Make sure you have either npm or yarn installed.

npm install tailwind-config
# or
yarn add tailwind-config


Get the theme object

import tailwind from 'tailwind-config'
/* or */
const tailwind = require('tailwind-config')

/* get the theme object */
const theme = tailwind.theme('./relative/path/to/your/tailwind.config')

/* get the value of a specific color */[100] // '#fff5f5'

/* use object descructuring */
const { screens, spacing } = tailwind.theme('./relative/path/to/your/tailwind.config') // '768px'
spacing['12'] // '3rem'

Make sure to replace ./relative/path/to/your/tailwind.config with the actual relative path to your tailwind config. Alternatively you can pass an object, or pass nothing to just use the default config.

What is object destructuring?

Get the whole config


const theme = config.theme
const plugins = config.plugins
/* ...etc */

Helper functions

Functions exist for each of the top level keys on the config object, as well as the config object itself:


For a list of all the values on the config object, see the Tailwind github repo.

Import just the function you want

import { separator } from 'tailwind-config'
/* or */
const { separator } = require('tailwind-config')

separator('./relative/path/to/your/tailwind.config') // ':'

Pass the path to your config file or the config object itself

const config = tailwind.config('./relative/path/to/your/tailwind.config')
/* or */
import config from '../tailwind.config'
const resolvedConfig = tailwind.config(config)


For any bugs you may experience, please open an issue.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free