Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@backto/theme-json-to-tailwind-config

Package Overview
Dependencies
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@backto/theme-json-to-tailwind-config

A Tailwind plugin that automatically syncs WordPress theme.json spacing values with your Tailwind configuration

latest
npmnpm
Version
0.1.1
Version published
Maintainers
0
Created
Source

@backto/theme-json-to-tailwind-config

A Tailwind CSS plugin that automatically synchronizes spacing values from your WordPress theme.json file with your Tailwind configuration.

npm version

Features

  • 🔄 Automatic synchronization between theme.json and Tailwind config
  • 🎯 Zero configuration needed
  • 🚀 Seamless integration with WordPress block editor
  • ⚡️ Lightweight with no dependencies

Installation

npm install @backto/theme-json-to-tailwind-config

Setup

In your tailwind.config.js:

js
const themeJson = require('./PATH_TO_YOUR_THEME/theme.json');
import themeJsonToTailwind from '@backto/theme-json-to-tailwind-config';

module.exports = {
    content: [
    // your content configuration
    ],
    plugins: [
        themeJsonToTailwind({
            themeJson: themeJson,
        })
    ]
}

Usage

WordPress Theme.json Configuration

Define your spacing values in your theme.json:

{
    "settings": {
        "spacing": {
            "spacingSizes": [
                {
                    "name": "Extra small",
                    "slug": "xs",
                    "size": "1.25rem"
                },
                {
                    "name": "Small",
                    "slug": "sm",
                    "size": "2rem"
                }
            ]
        }
    }
}

Using in Your Templates

The plugin automatically generates Tailwind utility classes based on your theme.json spacing values:

<div class="mt-xs">...</div>
<div class="mb-sm">...</div>

This will generate the following CSS:

.mt-xs {
    margin-top: 1.25rem;
}
.mb-sm {
    margin-bottom: 2rem;
}

How It Works

The plugin:

  • Reads the spacingSizes array from your theme.json
  • Converts the values into Tailwind-compatible spacing units
  • Extends Tailwind's spacing configuration with your custom values

Requirements

  • Tailwind CSS v3.0.0 or higher (peer dependency)
  • WordPress 5.8+ (for theme.json support)
  • Node.js 18 or higher

API Reference

Plugin Options

OptionTypeRequiredDescription
themeJsonObjectYesYour WordPress theme.json configuration object

Keywords

tailwindcss

FAQs

Package last updated on 13 Jan 2025

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