The CSS multi-column layout allows easy definition of multiple columns of text - just like in newspapers. This Tailwind CSS plugin adds utilities for you to use all multi-column properties.
Compatibility: Tailwind CSS ^1.8.3, ^2.X. and ^3.X
For a quick start you can use the following link to start with all utilities. Please don't use this link in youre production environment. For a good developer experience install the plugin and add it to your tailwind.config.js - see Installation.
<link href="https://cdn.jsdelivr.net/gh/markusantonwolf/tailwind-css-plugin-multi-columns/dist/multi-columns.min.css" rel="stylesheet">
# Install using npm
npm install --save-dev @markusantonwolf/tailwind-css-plugin-multi-columns
# Install using yarn
yarn add -D @markusantonwolf/tailwind-css-plugin-multi-columns
// tailwind.config.js
module.exports = {
// ...
plugins: [
require('@markusantonwolf/tailwind-css-plugin-multi-columns')
]
}
The Tailwind CSS Multi Column plugin generates new utilities .column
and .rule
in the same way .border
and .gap
utilities are generated in Tailwind CSS.
By Default the Multi Column Plugin uses your theme and colors so you don't have to redefine your settings - don't copy yourself. Configurated variants apply for columns and column rules - default variant is "responsive". To change rendered variants add the plugin information to the config or add it directly to the required plugin:
// tailwind.config.js
module.exports = {
// ...
theme: {
multiColumns: {
span: {
test: "inherit", // your multi column config
},
},
},
// ...
variants: {
multiColumns: ["responsive", "dark"]
},
// ...
plugins: [
require('@markusantonwolf/tailwind-css-plugin-multi-columns'),
]
}
// tailwind.config.js
module.exports = {
// ...
plugins: [
require('@markusantonwolf/tailwind-css-plugin-multi-columns')({
span: {
test: "inherit", // your multi column config
},
variants: ["responsive", "dark"],
}),
]
}
Learn more about how to configure Tailwind CSS: More configurations. You can find all available variants in the Tailwind CSS documentation: Tailwind CSS - Configuring Variants.
<div class="column-2 column-gap-12 rule rule-dashed rule-gray-500">
<!-- Content -->
</div>
<div class="sm:column-2 xl:column-3 sm:column-gap-12 xl:column-gap-24 rule xl:rule-2 rule-dashed rule-gray-900 rule-opacity-50">
<!-- Content -->
</div>
<div class="md:column-2 xl:column-3 2xl:column-4 column-gap-12 xl:rule-2 rule-dotted rule-gray-300">
<!-- Content -->
</div>
With this Tailwind CSS Plugin you can easily the following multi-column properties:
- column-count
- column-gap
- column-rule-style
- column-rule-width
- column-rule-color
- column-rule
- column-span
- column-width
You can find a list of all generated utilities here - All Multi Column utilities
In the following example you can see all available options (default values) for the Multi Column plugin. The params variants
, styles
and columns
are replacing the configuration and the other params will get merged with your Tailwind CSS theme.
// tailwind.config.js
module.exports = {
// ...
theme: {
multiColumns: {
styles: ["dotted", "solid", "dashed"],
columns: ["2", "3", "4", "5", "6", "7", "8", "9"],
span: [], // merges definitions
gaps: [], // merges definitions
spacing: [], // merges definitions
colors: [], // merges definitions
borderWidth: [], // merges definitions
opacity: [], // merges definitions
},
},
// ...
variants: {
multiColumns: ["responsive", "dark"]
},
// ...
plugins: [
require('@markusantonwolf/tailwind-css-plugin-multi-columns'),
]
}
Tailwind CSS Plugin Filter utilities is released under the MIT license & supports modern environments.
© 2021 Markus A. Wolf https://www.markusantonwolf.com