Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

254
Views
Importing tokens from npm in Tailwind CSS config

I'm checking out the Theme Configuration in Tailwind CSS. It looks really powerful, but I'm having trouble using my design tokens within the config.

I have my tokens distributed via npm, but don't know how I can include them in my tailwind.config.js. Is there any way to include them like this? Should I use a different approach?

// What I'm trying to achieve
import DesignTokens from "@my-design-system/tokens";

module.exports = {
  content: ["./src/**/*.{js,jsx,ts,tsx}"],
  theme: {
    extend: {},
    colors: {
      blue: DesignTokens.COLOR_BLUE_700,
    },
  },
  plugins: [],
};

Error I get

SyntaxError: Cannot use import statement outside a module

Any info will be greatly appreciated.

Thanks

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

As stated in the comments, using the import is mixing module formats.

I got it working with the following configuration.

// I have tokens available in many different formats thanks to Style Dictionary. Here we use JSON.
const DesignTokens = require("@my-design-system/tokens.json");

module.exports = {
  content: ["./src/**/*.{js,jsx,ts,tsx}"],
  theme: {
    extend: {},
    colors: {
      blue: {
        700: DesignTokens["color-blue-700"],
      },
    },
  },
  plugins: [],
};
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!