Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[container] Get ride of the extra added XS breakpoint. #1675

Closed
damsfx opened this issue May 24, 2023 · 2 comments
Closed

[container] Get ride of the extra added XS breakpoint. #1675

damsfx opened this issue May 24, 2023 · 2 comments

Comments

@damsfx
Copy link

damsfx commented May 24, 2023

Is there a way to completely remove the extra screen definition added for XS ?
This breakpoints break default Tailwind CSS container fluid width.

An example for screen width of 432px :

Default Tailwind Elements
image image

The only way I have found so far is to use :

@layer utilities {
    .container {
        @media screen and (max-width: 640px) {
            @apply max-w-none;
        }
    }
}

Tailwind Elements config

The Tailwind docs said :

Adding smaller breakpoints
If you want to add an additional small breakpoint, you can’t use extend because the small breakpoint would be added to the end of the breakpoint list, and breakpoints need to be sorted from smallest to largest in order to work as expected with a min-width breakpoint system.

This is not the case in Tailwind Elements.

const plugin = require("tailwindcss/plugin");

module.exports = plugin(() => {}, {
  theme: {
    extend: {
      screens: {
        xs: "320px",
      },
      ...
    }
  }
}

It would be better for Tailwind Elements to respect this rule to avoid side effects.

const plugin = require("tailwindcss/plugin");
const defaultTheme = require('tailwindcss/defaultTheme')

module.exports = plugin(() => { }, {
  theme: {
    screens: {
      'xs': '320px',
      ...defaultTheme.screens,
    },
    extend: {
      // screens: {
      //   xs: "320px",
      // },
      ...
    }
  }
}
@juujisai
Copy link
Contributor

juujisai commented Jun 5, 2023

I think something like this could work, but if any component is using the "xs" breakpoint, the styling could break

const plugin = require("tw-elements/dist/plugin.cjs");
plugin.config.theme.extend.screens = {};

/** @type {import('tailwindcss').Config} */
module.exports = {
 ...
  plugins: [plugin],
 ...
};

As of the xs beeing inside the extend object, moving it outside didn't change anything for me. I have added a new issue to our project list to check this more in detail.

Best Regards!

@damsfx
Copy link
Author

damsfx commented Jun 5, 2023

As of the xs beeing inside the extend object, moving it outside didn't change anything for me.

By redefining the breakpoints, including the new one (xs) and all the other breakpoints already defined, we retain the order: xs > sm > md > lg > xl > 2xl
By using extend, you lose mobile first order, the new breakpoint is added after default ones: sm > md > lg > xl > 2xl > xs.

Meanwhile, thank you for your time and your answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants