A Tailwind CSS library that implements Utopia's fluid responsive design methodology, providing smooth, responsive typography and spacing without breakpoints.
npm install --save-dev @andreibratila/tailwind-utopia
or
npm install -g @andreibratila/tailwind-utopia
npx tailwind-utopia config
I recomend use prefix in configFile example: "fs-"
npx tailwind-utopia generate
with flags if you want to read de config file
npx tailwind-utopia generate configPath=./src/configs
example: global.css
@import "tailwindcss";
@import "./tailwind-utopia.css";
... other css files / configurations
<h1 class="text-fs-2xl mb-fs-l">
Fluid Typography
</h1>
The library uses a configuration file (tailwind-utopia.config.json) to define your fluid typography and spacing scales. You can generate a default configuration using:
bash npx tailwind-utopia config
The typography scale is defined by:
Example configuration:
json
{
"prefix": "",
"baseKey": "base",
"utopia": {
"minWidth": 320,
"minSize": 21,
"minScale": 1.2,
"maxWidth": 1140,
"maxSize": 24,
"maxScale": 1.25,
"fontSize": {
"xs": "inherit",
"sm": "inherit",
"base": 1.4,
"lg": 1.33,
"xl": 1.2,
"2xl": 1.11,
"3xl": 1,
"4xl": 1
},
"spacing": {
"3xs": 0.25,
"2xs": 0.5,
"xs": 0.75,
"sm": 1,
"md": 1.5,
"lg": 2,
"xl": 3,
"2xl": 4,
"3xl": 6
}
}
}
The spacing scale works similarly to typography, providing fluid values for margins, padding, and gaps:
!!! IMPORTANT!!! I recomend create prefix always example: "fs-"
<h1 class="text-{prefix(optional}sm">Large Fluid Heading</h1>
<p class="text-fs-sm">Body text that scales smoothly</p>
<small class="text-sm">Smaller text</small>
<div class="mb-{prefix(optional}xs">
<h2 class="mb-fs-xs">Title</h2>
<p class="mb-xs">Content</p>
</div>
The library includes a CLI with the following commands:
npx tailwind-utopia config
npx tailwind-utopia generate
npx tailwind-utopia --help
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License - see LICENSE for details.
Inspired by Utopia, a methodology for fluid responsive design and @domchristie/tailwind-utopia plugin, domchristie/tailwind-utopia.
Utopia: James Gilyead & Trys Mudford
Original Tailwind Utopia plugin: Chris Pymm & CWS Digital
Plugin I based my work on: Dom Christie
This project was created by Andrei Florian Brătila, andreiflorianbratila.com.
Special thanks to all contributors who helped improve this library. If you’d like to contribute, check out our CONTRIBUTING.md.
By contributing to this project, you agree that your code will be licensed under the MIT License.
Consider supporting this project by starring the repository or sponsoring via GitHub Sponsors.