@apexshift/tailwindcss-fluid-typography 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/CONTRIBUTING.md +58 -0
- package/LICENSE +21 -0
- package/README.md +98 -0
- package/SECURITY.md +44 -0
- package/index.mjs +71 -0
- package/package.json +36 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
All notable changes to this project will be documented in this file.
|
|
3
|
+
|
|
4
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
5
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
## [0.0.1] - 2026-02-12
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
- Initial release
|
|
11
|
+
- Fluid typography utilities using automatic `clamp()` preferred value calculation
|
|
12
|
+
- Configurable min/max viewport, root font size, class prefix, and size scale
|
|
13
|
+
- ESM-only module (`index.mjs`)
|
|
14
|
+
- Plugin options + theme extension support
|
|
15
|
+
- Responsive variants included by default
|
|
16
|
+
|
|
17
|
+
### Notes
|
|
18
|
+
- Tested with Tailwind CSS v3.4+ and v4.0+
|
|
19
|
+
- Designed for projects using `html { font-size: 62.5%; }` (10px root), but works with any root size
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
Thank you for considering contributing to **tailwindcss-fluid-typography**!
|
|
3
|
+
We welcome bug reports, feature suggestions, documentation improvements, and pull requests.
|
|
4
|
+
|
|
5
|
+
## Code of Conduct
|
|
6
|
+
|
|
7
|
+
This project follows the [Contributor Covenant Code of Conduct](https://www.contributor-covenant.org/version/2/1/code_of_conduct/).
|
|
8
|
+
By participating, you are expected to uphold this code.
|
|
9
|
+
|
|
10
|
+
## How to Contribute
|
|
11
|
+
|
|
12
|
+
### 1. Reporting Bugs / Requesting Features
|
|
13
|
+
|
|
14
|
+
- Open an issue on GitHub: [Issues](https://github.com/apexshift/tailwindcss-fluid-typography.git/issues)
|
|
15
|
+
- Use a clear and descriptive title
|
|
16
|
+
- Provide as much detail as possible (Tailwind version, Node version, minimal reproduction steps, screenshots if helpful)
|
|
17
|
+
|
|
18
|
+
### 2. Submitting Pull Requests
|
|
19
|
+
|
|
20
|
+
1. Fork the repository
|
|
21
|
+
2. Create a feature branch: `git checkout -b feature/amazing-change`
|
|
22
|
+
3. Make your changes
|
|
23
|
+
4. Ensure the plugin still works with Tailwind v3 and v4
|
|
24
|
+
5. Test locally (see Development section below)
|
|
25
|
+
6. Commit with a clear message: `feat: add fluid spacing utilities`
|
|
26
|
+
7. Push to your fork and open a pull request
|
|
27
|
+
|
|
28
|
+
We will review your PR as soon as possible.
|
|
29
|
+
|
|
30
|
+
### Development Setup
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
git clone https://github.com/yourusername/tailwindcss-fluid-typography.git
|
|
34
|
+
cd tailwindcss-fluid-typography
|
|
35
|
+
npm install
|
|
36
|
+
|
|
37
|
+
# Link locally for testing
|
|
38
|
+
npm link
|
|
39
|
+
|
|
40
|
+
# In a separate test project:
|
|
41
|
+
npm link tailwindcss-fluid-typography
|
|
42
|
+
npm run dev
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Style Guide
|
|
46
|
+
- Use ESM(`import`/`export`)
|
|
47
|
+
- Keep code readable and well commented
|
|
48
|
+
- Update README.md and/or CHANGELOG.md when appropriate
|
|
49
|
+
- Add tests if you introduce new behavior (future goal)
|
|
50
|
+
|
|
51
|
+
### Commit Messages
|
|
52
|
+
Follow [Conventional Commits](https://www.conventionalcommits.org/):
|
|
53
|
+
- `feat:` new feature
|
|
54
|
+
- `fix:` bug fix
|
|
55
|
+
- `docs:` documentation changes
|
|
56
|
+
- `chore:` maintenance
|
|
57
|
+
|
|
58
|
+
Thank you again – every contribution helps!
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 [Apex Shift Ltd]
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# tailwindcss-fluid-typography
|
|
2
|
+
A Tailwind CSS plugin that generates fluid typography utilities using `clamp()` with automatically calculated preferred values.
|
|
3
|
+
|
|
4
|
+
Instead of manually writing `clamp(…)` expressions everywhere, define min/max font sizes once — the plugin computes the linear interpolation for smooth scaling across viewports.
|
|
5
|
+
|
|
6
|
+
Works great with Tailwind v3 and v4.
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
- Automatic calculation of the preferred value in `clamp(min, preferred, max)`
|
|
10
|
+
- Configurable min/max viewport widths
|
|
11
|
+
- Supports custom root font size (perfect for 10px = 1rem setups)
|
|
12
|
+
- Responsive variants (`sm:`, `md:`, etc.) included
|
|
13
|
+
- Override defaults via `theme.extend.fluidTypography` or plugin options
|
|
14
|
+
- Clean class names: `text-fluid-base`, `text-fluid-xl`, etc.
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
```bash
|
|
18
|
+
npm install --save-dev tailwindcss-fluid-typography
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
### 1. Add plugin
|
|
23
|
+
```mjs
|
|
24
|
+
// tailwind.config.mjs
|
|
25
|
+
import fluidTypography from 'tailwindcss-fluid-typography'
|
|
26
|
+
|
|
27
|
+
export default {
|
|
28
|
+
content: ['./index.html', './src/**/*.{js,ts,jsx,tsx}'],
|
|
29
|
+
plugins: [
|
|
30
|
+
fluidTypography({
|
|
31
|
+
rootFontSize: 10,
|
|
32
|
+
minViewport: 360,
|
|
33
|
+
maxViewport: 1536,
|
|
34
|
+
sizes: {
|
|
35
|
+
base: { min: 16, max: 20 }, // px values
|
|
36
|
+
xl: { min: 20, max: 32 },
|
|
37
|
+
'3xl': {min: 32, max: 56 }
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### 2. Use the generated classes
|
|
45
|
+
```html
|
|
46
|
+
<h1 class="text-fluid-5xl font-bold">Fluid Heading</h1>
|
|
47
|
+
<p class="text-fluid-base leading-relaxed">This paragraph scales smoothly.</p>
|
|
48
|
+
<h2 class="text-fluid-xl md:text-fluid-2xl">Responsive section title</h2>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Confguration Options
|
|
52
|
+
You can pass option when adding the plugin, or extend the theme.
|
|
53
|
+
|
|
54
|
+
| Option | Default | Description |
|
|
55
|
+
| ------ | ------- | ----------- |
|
|
56
|
+
| `rootFontSize` | `10` | Base font size in px (for rem conversion) |
|
|
57
|
+
| `minViewport` | `375` | Minimum viewport width in px |
|
|
58
|
+
| `maxViewport` | `1440` | Maximum viewport width in px |
|
|
59
|
+
| `prefix` | `fluid-` | prefix for generated classes |
|
|
60
|
+
| `sizes` | (see below) | Object of `{ min: number, max: number }` pairs |
|
|
61
|
+
|
|
62
|
+
### Default Sizes (in px):
|
|
63
|
+
```javascript
|
|
64
|
+
{
|
|
65
|
+
xs: { min: 12, max: 14 },
|
|
66
|
+
sm: { min: 14, max: 16 },
|
|
67
|
+
base: { min: 16, max: 18 },
|
|
68
|
+
lg: { min: 18, max: 22 },
|
|
69
|
+
xl: { min: 22, max: 28 },
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## How it works (math behind the scenes)
|
|
74
|
+
For each size:
|
|
75
|
+
```plain
|
|
76
|
+
minRem = minPx / rootFontSize
|
|
77
|
+
maxRem = maxPx / rootFontSize
|
|
78
|
+
|
|
79
|
+
slope = (maxRem - minRem) / (maxViewport - minViewport)
|
|
80
|
+
intercept = minRem - slope * minViewport
|
|
81
|
+
|
|
82
|
+
preferred = calc(${slope * 100}vw + ${intercept}rem)
|
|
83
|
+
|
|
84
|
+
font-size: clamp(${minRem}rem, ${preferred}, ${maxRem}rem)
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Development
|
|
88
|
+
```bash
|
|
89
|
+
# Link locally for testing
|
|
90
|
+
cd tailwindcss-fluid-typography
|
|
91
|
+
npm link
|
|
92
|
+
|
|
93
|
+
# In your project
|
|
94
|
+
npm link tailwindcss-fluid-typography
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Licence
|
|
98
|
+
MIT
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
|
|
2
|
+
# Security Policy
|
|
3
|
+
|
|
4
|
+
## Supported Versions
|
|
5
|
+
|
|
6
|
+
We actively support the following versions of the plugin:
|
|
7
|
+
|
|
8
|
+
| Version | Supported |
|
|
9
|
+
|---------|--------------------|
|
|
10
|
+
| 0.0.x | Yes (latest) |
|
|
11
|
+
| < 0.0.1 | No |
|
|
12
|
+
|
|
13
|
+
Tailwind CSS versions ≥ 3.0 are supported.
|
|
14
|
+
|
|
15
|
+
## Reporting a Vulnerability
|
|
16
|
+
|
|
17
|
+
If you discover a security vulnerability, please **do not** open a public GitHub issue.
|
|
18
|
+
|
|
19
|
+
Instead, report it privately so we can fix it quickly and safely:
|
|
20
|
+
|
|
21
|
+
**Preferred method**
|
|
22
|
+
Send an email to: **security@apexshift.co.uk**
|
|
23
|
+
or use GitHub Security Advisories if the repository is public:
|
|
24
|
+
|
|
25
|
+
1. Go to the repository → **Security** tab → **Report a vulnerability**
|
|
26
|
+
2. Fill in the advisory form with details
|
|
27
|
+
|
|
28
|
+
### What to include in your report
|
|
29
|
+
|
|
30
|
+
- Description of the vulnerability
|
|
31
|
+
- Steps to reproduce
|
|
32
|
+
- Affected versions
|
|
33
|
+
- Potential impact
|
|
34
|
+
- Any suggested fixes (optional)
|
|
35
|
+
|
|
36
|
+
### Response timeline
|
|
37
|
+
|
|
38
|
+
- Acknowledgment within 48 hours
|
|
39
|
+
- Detailed investigation within 5 business days
|
|
40
|
+
- Fix released (or workaround provided) as soon as possible
|
|
41
|
+
|
|
42
|
+
We will credit you in the release notes (unless you prefer to remain anonymous).
|
|
43
|
+
|
|
44
|
+
Thank you for helping keep this project secure!
|
package/index.mjs
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// index.mjs
|
|
2
|
+
import plugin from 'tailwindcss/plugin.js';
|
|
3
|
+
|
|
4
|
+
const defaultConfig = {
|
|
5
|
+
minViewport: 375,
|
|
6
|
+
maxViewport: 1440,
|
|
7
|
+
rootFontSize: 10, // your 62.5% root → 1rem = 10px
|
|
8
|
+
prefix: 'fluid-',
|
|
9
|
+
sizes: {
|
|
10
|
+
xs: { min: 12, max: 14 },
|
|
11
|
+
sm: { min: 14, max: 16 },
|
|
12
|
+
base: { min: 16, max: 18 },
|
|
13
|
+
lg: { min: 18, max: 22 },
|
|
14
|
+
xl: { min: 20, max: 28 },
|
|
15
|
+
'2xl': { min: 24, max: 36 },
|
|
16
|
+
'3xl': { min: 30, max: 48 },
|
|
17
|
+
'4xl': { min: 36, max: 60 },
|
|
18
|
+
'5xl': { min: 48, max: 72 },
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default plugin.withOptions(
|
|
23
|
+
// Plugin implementation
|
|
24
|
+
function (options = {}) {
|
|
25
|
+
return function ({ addUtilities, theme }) {
|
|
26
|
+
const config = {
|
|
27
|
+
...defaultConfig,
|
|
28
|
+
...options,
|
|
29
|
+
sizes: { ...defaultConfig.sizes, ...options?.sizes },
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const utilities = {};
|
|
33
|
+
|
|
34
|
+
Object.entries(config.sizes).forEach(([key, { min: minPx, max: maxPx }]) => {
|
|
35
|
+
if (typeof minPx !== 'number' || typeof maxPx !== 'number') return;
|
|
36
|
+
|
|
37
|
+
const minRem = minPx / config.rootFontSize;
|
|
38
|
+
const maxRem = maxPx / config.rootFontSize;
|
|
39
|
+
|
|
40
|
+
const viewportRange = config.maxViewport - config.minViewport;
|
|
41
|
+
const sizeRange = maxRem - minRem;
|
|
42
|
+
const slope = sizeRange / viewportRange;
|
|
43
|
+
const intercept = minRem - slope * config.minViewport;
|
|
44
|
+
|
|
45
|
+
const preferred = `calc(${slope * 100}vw + ${intercept}rem)`;
|
|
46
|
+
|
|
47
|
+
utilities[`.text-${config.prefix}${key}`] = {
|
|
48
|
+
'font-size': `clamp(${minRem}rem, ${preferred}, ${maxRem}rem)`,
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
addUtilities(utilities, ['responsive']);
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
// Theme extension (so users can override via tailwind.config.mjs)
|
|
57
|
+
function (options = {}) {
|
|
58
|
+
return {
|
|
59
|
+
theme: {
|
|
60
|
+
extend: {
|
|
61
|
+
fluidTypography: {
|
|
62
|
+
minViewport: options.minViewport ?? defaultConfig.minViewport,
|
|
63
|
+
maxViewport: options.maxViewport ?? defaultConfig.maxViewport,
|
|
64
|
+
rootFontSize: options.rootFontSize ?? defaultConfig.rootFontSize,
|
|
65
|
+
sizes: options.sizes ?? defaultConfig.sizes,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
);
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@apexshift/tailwindcss-fluid-typography",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Tailwind CSS plugin for automatic fluid typography using clamp()",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./index.mjs",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./index.mjs"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"tailwind",
|
|
12
|
+
"tailwindcss",
|
|
13
|
+
"tailwind-plugin",
|
|
14
|
+
"fluid-typography",
|
|
15
|
+
"clamp",
|
|
16
|
+
"responsive"
|
|
17
|
+
],
|
|
18
|
+
"author": "Team Apex",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"tailwindcss": "^3.0.0 || ^4.0.0"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"tailwindcss": "^4.0.0"
|
|
25
|
+
},
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "https://github.com/apexshift/tailwindcss-fluid-typography.git"
|
|
29
|
+
},
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/apexshift/tailwindcss-fluid-typography.git/issues"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"npm": "^11.10.0"
|
|
35
|
+
}
|
|
36
|
+
}
|