Skip to content

Using @screen breakpoints #186

Closed Answered by ben-rogerson
botoxparty asked this question in Q&A
Discussion options

You must be logged in to vote

I've been meaning to publish a half-decent answer on this so thanks for asking the question.

Here are some Twin alternatives to the @screen directive for vanilla Tailwind:

Use @screen in a plugin

This gives you direct access to the screen values from your config.
A potential downside is that you need to write the plugin using vanilla css:

// tailwind.config.js
module.exports = {
  // ...
  plugins: [
    paddings
  ],
}

function paddings({ addComponents, theme }) {
  addComponents({
    '.custom-paddings': {
      '@screen md': {
        'padding-left': theme`padding.3`,
        'padding-right': theme`padding.3`,
      },
      '@screen lg': {
        'padding-left': theme`padding.6`,

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by botoxparty
Comment options

You must be logged in to vote
1 reply
@ben-rogerson
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants