unocss-preset-columns
v2.0.0
Published
A dead-simple uno preset that adds a column unit to unocss.
Readme
Unocss Preset columns
A dead-simple uno preset that adds a new unit to unocss, the "c" unit, that is equal to the size of a column.
For example, if your design has 14 columns, px-1c will generate the following styles:
.px-1c {
padding-left: 7.1428571429vw; /* 1/14 * 100vw */
padding-right: 7.1428571429vw;
}The following features are supported:
widthwithw-Xcheightwithh-Xcmax-widthwithmax-w-Xcmax-heightwithmax-h-Xcpadding-leftwithpl-Xcpadding-topwithpt-Xcpadding-rightwithpr-Xcpadding-bottomwithpb-Xcpadding-left", "padding-rightwithpx-Xcpadding-top", "padding-bottomwithpy-Xcpaddingwithp-Xcmargin-leftwithml-Xcmargin-topwithmt-Xcmargin-rightwithmr-Xcmargin-bottomwithmb-Xcmargin-left", "margin-rightwithmx-Xcmargin-top", "margin-bottomwithmy-Xcmarginwithm-Xcleftwithleft-Xctopwithtop-Xcrightwithright-Xcbottomwithbottom-Xcleft", "right", "top", "bottomwithinset-Xcflex-basiswithbasis-Xcgapwithgap-Xccolumn-gapwithgap-x-Xcrow-gapwithgap-y-Xctext-indentwithindent-Xc
Usage
Install the package
npm
npm i -D unocss-preset-columnspnpm
pnpm i -D unocss-preset-columnsIn uno.config.ts
import { presetColumns } from "unocss-preset-columns";
export default defineConfig({
// ...
presets: [
// ...
presetColumns({
// The number of columns in your design (default to 14)
colsNum: 14
}),
],
// ...
});