Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds new column utilities to Tailwind CSS. By default, these utilities come in two different scales — a count scale and a width scale. Both of these scales are valid values for the
columns
shorthand property.Count scale
The count utilities set the number of columns that should be created, and the column width is automatically adjusted to accommodate that number.
columns-auto
columns: auto
columns-1
columns: 1
columns-2
columns: 2
columns-3
columns: 3
columns-4
columns: 4
columns-5
columns: 5
columns-6
columns: 6
columns-7
columns: 7
columns-8
columns: 8
columns-9
columns: 9
columns-10
columns: 10
columns-11
columns: 11
columns-12
columns: 12
You can use the responsive helpers to adjust the number of columns based on the screen size:
Width scale
The width utilities set the ideal column width, with the number of columns (the count) automatically adjusting to accommodate that value. This "t-shirt" scale is the same as the
max-width
scale, with the addition of2xs
and3xs
, since smaller columns may be desirable.columns-auto
columns: auto
columns-3xs
columns: 16rem
columns-2xs
columns: 18rem
columns-xs
columns: 20rem
columns-sm
columns: 24rem
columns-md
columns: 28rem
columns-lg
columns: 32rem
columns-xl
columns: 36rem
columns-2xl
columns: 42rem
columns-3xl
columns: 48rem
columns-4xl
columns: 56rem
columns-5xl
columns: 64rem
columns-6xl
columns: 72rem
columns-7xl
columns: 80rem
Using the width scale is actually really nice, since the number of columns automatically adjusts based on the width available. Meaning you don't need to use any responsive helpers!
Customizing
The available utilities can be customized under the
theme.columns
section of yourtailwind.config.js
file.These utilities also support arbitrary values, so if you need to use another value that doesn't make sense to include in your Tailwind config, you can do this using the square bracket notation:
Column gaps
To specify the width between columns, you can use the existing gap-x utilities in Tailwind.
Future considerations
There are number of additional CSS properties available within the column spec that this PR does not address. This includes things like column span, fill, and rule. While these might be interesting utilities to add some day, their use-case is much less common, so we've decided to leave them out for now.