Code Monkey home page Code Monkey logo

Comments (5)

ben-rogerson avatar ben-rogerson commented on May 18, 2024 2

If you're using them in a styled block then it's a little more complex.
You'd need to import the config and grab the screen sizes and work with them manually.
I understand this isn't ideal so I'll provide a similar function in the near future.

For now, something like this should work:

// tailwind.helpers.js
import _get from 'lodash/get';
import resolveConfig from 'tailwindcss/resolveConfig';
import tailwindConfig from '~./../../tailwind.config.js';
const { theme } = resolveConfig(tailwindConfig);

const SCREEN = _get(theme, 'borderColor.screens');

export { SCREEN };

from twin.macro.

bennettrogers avatar bennettrogers commented on May 18, 2024 1

Thanks for replying so quickly.

I'm trying to use the @screen directive so that I can have a block of responsive CSS that can use styles that aren't directly supported in Tailwind (e.g. grid template areas).

I just gave your above suggestion a try, but I'm running into a problem that I've seen before: the module.exports vs export default conflict referenced in this Tailwind issue.

I'll mess with it a bit more, but if I can't get this to work I may just fall back to using Tailwind separate SCSS files for cases where I need to use Tailwind directives.

Thanks again!

from twin.macro.

ben-rogerson avatar ben-rogerson commented on May 18, 2024 1

I've run into that issue before and think I fixed it with the advice on that issue.

Adding sourceType: 'unambiguous' to my Babel config fixed this by allowing me to import a module.exports.

from twin.macro.

ben-rogerson avatar ben-rogerson commented on May 18, 2024

Hey Benett, thanks for giving the new package a trial.

If you've added your custom breakpoints to the config then you can use them with tailwind classes as normal:

tw.div`grid grid-cols-1 desktop:grid-cols-4`
// tailwind.config.js
module.exports = {
    theme: {
        screens: {
            tablet: '640px',
            laptop: '1024px',
            desktop: '1280px'
        },
    }
}

from twin.macro.

ben-rogerson avatar ben-rogerson commented on May 18, 2024

Take a look at the Theme component in the CRA + Emotion + Tailwind Twin Starter that exposes the tailwind config via the theme prop.

from twin.macro.

Related Issues (20)

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.