Preset Clamp
UnoCSS preset for viewport-scaled responsive utility classes for CSS number properties, enabling a fluid clamp-based scaling approach.
Installation
Since our @manyone packages are private on npmjs you must authenticate to install it with npm login
.
If you’re not part of the Manyone organisation on npmjs.com, reach out to Caroline, Patrik or Lau.
Configuration
Usage
To get an overview of all clampable properties, please refer to the source code.
Basic usage
The classes are named using the following pattern: clamp-{property}-{min}-{max}
.
Values are defined as unoss units (default: 1 unit = 4px).
With viewport bounds
Optionally you can specify the minimum and maximum viewport width in pixels using the following pattern:
clamp-{property}-{min}-{max}-{minView}-{maxView}
Options
minView
- Type:
number
- Default:
320
Minimum viewport width in pixels.
maxView
- Type:
number
- Default:
1440
Maximum viewport width in pixels.
rootFontSize
- Type:
number
- Default:
16
Root font size in pixels.
endless
- Type:
boolean
- Default:
true
Allow scaling beyond maximum value. Everything then keeps scaling up above max-view size based on the scale factor.
scaleFactor
- Type:
number
- Default:
0.8
Scaling factor above the maximum viewport. When set to 1, the scaling will continue with the same rate as it did within the viewport bounds. When set to 0.8, the scaling will slow down by 20% compared to the speed it scaled within the viewport bounds.