Giter VIP home page Giter VIP logo

Comments (4)

jan-dh avatar jan-dh commented on May 31, 2024

Haven't tried tailwind 2.x but I'm guessing the theme variable is already declared in the tailwind config object. You can name the theme import whatever you want since it's a default export, for example:

import myTheme from './theme`

and then use it like this:

theme: {
   colors: {
      ...myTheme.colors
}

from figma-tailwindcss.

jan-dh avatar jan-dh commented on May 31, 2024

Going to close this since this isn't really an issue with the plugin. If you have any other questions, feel free to reach out to me.

from figma-tailwindcss.

moracabanas avatar moracabanas commented on May 31, 2024

I know this is isn't really an issue with the plugin but I am unable to extend tailwind.config.js with the generated theme.js so every time I make changes on Figma I only have to paste the new file.

What is working

You hard copy and paste the content of const theme = { <your theme config> } in tailwind.config.js as it follows:

module.exports = {
  purge: {
   . . .
  },
  darkMode: false, // or 'media' or 'class'
  theme: {
    // i.e.
    extend: {
      colors: {
        Green: '#60dcb0',
        Orange: '#feb881',
        Blue: '#5ecad8',
        Pink: '#f66295',
        Grey: '#6f6f6f',
        Hover: '#f8b16f',
        Normal: '#f38219',
        Active: '#9f5108',
        'Light-Green': '#f2fffb',
        'Light-Orange': '#fffbf2',
        'Light-Blue': '#f2feff',
        'Light-Pink': '#fff2f8',
        'Light-grey': '#f2f6f7',
        'BG-grey': '#f5f5f5',
      },
      boxShadow: {
        'Glow-Green': '0px 34px 40px -15px rgba(17,205,138,0.3)',
        'Glow-Orange': '0px 34px 40px -15px rgba(250,165,38,0.3)',
        'Glow-Blue': '0px 34px 40px -15px rgba(18,178,200,0.3)',
        'Glow-Pink': '0px 34px 40px -15px rgba(238,72,129,0.2)',
      },
      borderRadius: {
        none: '0',
        xs: '0.125rem',
        sm: '0.3125rem',
        default: '0.625rem',
        lg: '1.875rem',
      },
    },
  },
  variants: {
    extend: {},
  },
  plugins: [],
}

What is not working

  • Trying to import or require a module and assign it to tailwind config theme: property
const MyTheme = require('./theme')
module.exports = {
  purge: {
   . . .
  },
  darkMode: false, // or 'media' or 'class'
  theme: MyTheme,
  variants: {
    extend: {},
  },
  plugins: [],
}
  • Imports like import myTheme from './theme' are NOT allowed in taiwind.config.js

image

Thanks you for your work and your support

from figma-tailwindcss.

jan-dh avatar jan-dh commented on May 31, 2024

@moracabanas

if you remove the export statement from the generated file you can import it in your tailwind config like so:

const myTheme = require('./theme');

the importsyntax gives some errors but it does work.

Once you have the imported myTheme variable (don't use theme since that's a key already existing in your tailwind config), you have to do it per key. For example with the spread operator (adding your values to some defaults):

 fontFamily: {
      sans: [
        'system-ui',
         ....
      ],
      serif: ['Georgia', 'Cambria', '"Times New Roman"', 'Times', 'serif'],
      mono: ['Menlo', 'Monaco', 'Consolas', '"Liberation Mono"', '"Courier New"', 'monospace'],
      ...myTheme.fontFamily
    },

That's a nice way to use TailwindCSS's default values (you can output a tailwind config with all the values in it using npx tailwindcss init --full) and extend them with your own from the theme file.

from figma-tailwindcss.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.