tailwind-clamp 4.0.4 → 4.0.6
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/README.html +249 -0
- package/README.md +23 -19
- package/dist/index.js +873 -738
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +1 -1
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +3 -2
package/README.html
ADDED
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>Tailwind clamp</title>
|
|
6
|
+
<style>
|
|
7
|
+
/* From extension vscode.github */
|
|
8
|
+
/*---------------------------------------------------------------------------------------------
|
|
9
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
10
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
11
|
+
*--------------------------------------------------------------------------------------------*/
|
|
12
|
+
|
|
13
|
+
.vscode-dark img[src$=\#gh-light-mode-only],
|
|
14
|
+
.vscode-light img[src$=\#gh-dark-mode-only],
|
|
15
|
+
.vscode-high-contrast:not(.vscode-high-contrast-light) img[src$=\#gh-light-mode-only],
|
|
16
|
+
.vscode-high-contrast-light img[src$=\#gh-dark-mode-only] {
|
|
17
|
+
display: none;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
</style>
|
|
21
|
+
|
|
22
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Microsoft/vscode/extensions/markdown-language-features/media/markdown.css">
|
|
23
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Microsoft/vscode/extensions/markdown-language-features/media/highlight.css">
|
|
24
|
+
<style>
|
|
25
|
+
body {
|
|
26
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe WPC', 'Segoe UI', system-ui, 'Ubuntu', 'Droid Sans', sans-serif;
|
|
27
|
+
font-size: 14px;
|
|
28
|
+
line-height: 1.6;
|
|
29
|
+
}
|
|
30
|
+
</style>
|
|
31
|
+
<style>
|
|
32
|
+
.task-list-item {
|
|
33
|
+
list-style-type: none;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.task-list-item-checkbox {
|
|
37
|
+
margin-left: -20px;
|
|
38
|
+
vertical-align: middle;
|
|
39
|
+
pointer-events: none;
|
|
40
|
+
}
|
|
41
|
+
</style>
|
|
42
|
+
<style>
|
|
43
|
+
:root {
|
|
44
|
+
--color-note: #0969da;
|
|
45
|
+
--color-tip: #1a7f37;
|
|
46
|
+
--color-warning: #9a6700;
|
|
47
|
+
--color-severe: #bc4c00;
|
|
48
|
+
--color-caution: #d1242f;
|
|
49
|
+
--color-important: #8250df;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
</style>
|
|
53
|
+
<style>
|
|
54
|
+
@media (prefers-color-scheme: dark) {
|
|
55
|
+
:root {
|
|
56
|
+
--color-note: #2f81f7;
|
|
57
|
+
--color-tip: #3fb950;
|
|
58
|
+
--color-warning: #d29922;
|
|
59
|
+
--color-severe: #db6d28;
|
|
60
|
+
--color-caution: #f85149;
|
|
61
|
+
--color-important: #a371f7;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
</style>
|
|
66
|
+
<style>
|
|
67
|
+
.markdown-alert {
|
|
68
|
+
padding: 0.5rem 1rem;
|
|
69
|
+
margin-bottom: 16px;
|
|
70
|
+
color: inherit;
|
|
71
|
+
border-left: .25em solid #888;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.markdown-alert>:first-child {
|
|
75
|
+
margin-top: 0
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.markdown-alert>:last-child {
|
|
79
|
+
margin-bottom: 0
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.markdown-alert .markdown-alert-title {
|
|
83
|
+
display: flex;
|
|
84
|
+
font-weight: 500;
|
|
85
|
+
align-items: center;
|
|
86
|
+
line-height: 1
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.markdown-alert .markdown-alert-title .octicon {
|
|
90
|
+
margin-right: 0.5rem;
|
|
91
|
+
display: inline-block;
|
|
92
|
+
overflow: visible !important;
|
|
93
|
+
vertical-align: text-bottom;
|
|
94
|
+
fill: currentColor;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.markdown-alert.markdown-alert-note {
|
|
98
|
+
border-left-color: var(--color-note);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.markdown-alert.markdown-alert-note .markdown-alert-title {
|
|
102
|
+
color: var(--color-note);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.markdown-alert.markdown-alert-important {
|
|
106
|
+
border-left-color: var(--color-important);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.markdown-alert.markdown-alert-important .markdown-alert-title {
|
|
110
|
+
color: var(--color-important);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.markdown-alert.markdown-alert-warning {
|
|
114
|
+
border-left-color: var(--color-warning);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.markdown-alert.markdown-alert-warning .markdown-alert-title {
|
|
118
|
+
color: var(--color-warning);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.markdown-alert.markdown-alert-tip {
|
|
122
|
+
border-left-color: var(--color-tip);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.markdown-alert.markdown-alert-tip .markdown-alert-title {
|
|
126
|
+
color: var(--color-tip);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.markdown-alert.markdown-alert-caution {
|
|
130
|
+
border-left-color: var(--color-caution);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.markdown-alert.markdown-alert-caution .markdown-alert-title {
|
|
134
|
+
color: var(--color-caution);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
</style>
|
|
138
|
+
|
|
139
|
+
</head>
|
|
140
|
+
<body class="vscode-body vscode-light">
|
|
141
|
+
<h1 id="tailwind-clamp">Tailwind clamp</h1>
|
|
142
|
+
<p>Tailwind CSS plugin to use CSS <code>clamp</code> in your project. Enabling fluid interfaces using Tailwind syntax.</p>
|
|
143
|
+
<p>The plugin is based on the formula presented in this <a href="https://chriskirknielsen.com/blog/modern-fluid-typography-with-clamp/">article</a></p>
|
|
144
|
+
<h2 id="features">Features</h2>
|
|
145
|
+
<ul>
|
|
146
|
+
<li>Clamp values between a min and max viewport width, making it grow / shrink with the viewport.</li>
|
|
147
|
+
<li>Possibility to use small to large, large to small, negative to positive, positive to negative and negative to negative values. (Negative values only work on properties that allow them, e.g. <code>margin</code>)</li>
|
|
148
|
+
<li>Supports <code>px</code>, <code>rem</code> and <code>em</code> units.</li>
|
|
149
|
+
<li>Supports <code>text</code> values with multiple properties (<code>fontSize</code>, <code>lineHeight</code>, <code>letterSpacing</code>). If <code>lineHeight</code> is definded as a unitless number or a <code>calc()</code> function, the resulting value is calculated and converted to the <code>fontSize</code> unit.</li>
|
|
150
|
+
<li>Supports using Tailwind CSS theme values, arbitrary values or a combination.</li>
|
|
151
|
+
<li>Supports container queries.</li>
|
|
152
|
+
</ul>
|
|
153
|
+
<h2 id="requirements">Requirements</h2>
|
|
154
|
+
<p>The current version of the plugin is designed to be used with Tailwind version 4. To use it with version 3 use version 3.x.</p>
|
|
155
|
+
<h2 id="installation">Installation</h2>
|
|
156
|
+
<p>Install the plugin from npm:</p>
|
|
157
|
+
<pre><code class="language-sh">npm i tailwind-clamp
|
|
158
|
+
</code></pre>
|
|
159
|
+
<p>Add the plugin in your main CSS file:</p>
|
|
160
|
+
<pre><code class="language-css"><span class="hljs-keyword">@import</span> <span class="hljs-string">'tailwindcss'</span>;
|
|
161
|
+
<span class="hljs-keyword">@plugin</span> <span class="hljs-string">"tailwind-clamp"</span>;
|
|
162
|
+
</code></pre>
|
|
163
|
+
<h3 id="configuration">Configuration</h3>
|
|
164
|
+
<p>The plugin allows two configuration options:</p>
|
|
165
|
+
<table>
|
|
166
|
+
<thead>
|
|
167
|
+
<tr>
|
|
168
|
+
<th>Name</th>
|
|
169
|
+
<th>Type</th>
|
|
170
|
+
<th>Description</th>
|
|
171
|
+
<th>Default value</th>
|
|
172
|
+
</tr>
|
|
173
|
+
</thead>
|
|
174
|
+
<tbody>
|
|
175
|
+
<tr>
|
|
176
|
+
<td><strong><code>minSize</code></strong></td>
|
|
177
|
+
<td><code>{string}</code></td>
|
|
178
|
+
<td>Viewport or container size where the clamp starts.</td>
|
|
179
|
+
<td><code>23.4375rem</code></td>
|
|
180
|
+
</tr>
|
|
181
|
+
<tr>
|
|
182
|
+
<td><strong><code>maxSize</code></strong></td>
|
|
183
|
+
<td><code>{string}</code></td>
|
|
184
|
+
<td>Viewport or container size where the clamp end.</td>
|
|
185
|
+
<td><code>90rem</code></td>
|
|
186
|
+
</tr>
|
|
187
|
+
</tbody>
|
|
188
|
+
</table>
|
|
189
|
+
<p>Value should be a css length (<code>px</code>, <code>rem</code>, <code>em</code>). The unit for both options need to match.</p>
|
|
190
|
+
<pre><code class="language-css"><span class="hljs-keyword">@import</span> <span class="hljs-string">"tailwindcss"</span>;
|
|
191
|
+
<span class="hljs-keyword">@plugin</span> <span class="hljs-string">"tailwind-clamp"</span> {
|
|
192
|
+
minSize: <span class="hljs-number">25rem</span>,
|
|
193
|
+
maxSize: <span class="hljs-number">80rem</span>
|
|
194
|
+
};
|
|
195
|
+
</code></pre>
|
|
196
|
+
<h2 id="usage">Usage</h2>
|
|
197
|
+
<p>The plugin relies on the arbitrary values syntax <code>clamp-[...]</code>. You need to pass at least three arguments separated by commas without whitespace, optionally you can also pass the <code>minSize</code> and the <code>maxSize</code>:</p>
|
|
198
|
+
<pre><code>clamp-[<property>,<start>,<end>,[minSize,maxSize]]
|
|
199
|
+
</code></pre>
|
|
200
|
+
<h3 id="arguments">Arguments</h3>
|
|
201
|
+
<ul>
|
|
202
|
+
<li><strong><code>property</code></strong> Property that the value should be applied to. See a list of all supported properties below.</li>
|
|
203
|
+
<li><strong><code>start</code></strong> Value at <code>minSize</code> viewport size. It can be a key from your Tailwind CSS config file or a a css length (<code>px</code>, <code>rem</code>, <code>em</code>), the unit will need to match <code>end</code>.</li>
|
|
204
|
+
<li><strong><code>end</code></strong> Value at <code>maxSize</code> viewport size. It can be a key from your Tailwind CSS config file or a css length (<code>px</code>, <code>rem</code>, <code>em</code>), the unit will need to match <code>start</code>.</li>
|
|
205
|
+
<li><strong><code>[minSize=23.4375rem]</code></strong> Viewport or container size, where the clamp starts, defaults to <code>23.4375rem</code> (<code>375px</code>). It can be a breakpoint name from your theme or a css length (<code>px</code>, <code>rem</code>, <code>em</code>), the unit will need to match <code>maxSize</code> and be smaller than <code>maxSize</code>.</li>
|
|
206
|
+
<li><strong><code>[maxSize=90rem]</code></strong> Viewport or container size, where the clamp stops, defaults to <code>90rem</code> (<code>1440px</code>). It can be a breakpoint name from your theme or a css length (<code>px</code>, <code>rem</code>, <code>em</code>), the unit will need to match <code>minSize</code> and be be larger than <code>minSize</code>.</li>
|
|
207
|
+
</ul>
|
|
208
|
+
<h3 id="examples">Examples</h3>
|
|
209
|
+
<pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"clamp-[px,20,40] clamp-[py,10,18]"</span>></span>
|
|
210
|
+
Add some fluid padding here.
|
|
211
|
+
<span class="hljs-tag"></<span class="hljs-name">div</span>></span>
|
|
212
|
+
|
|
213
|
+
<span class="hljs-tag"><<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"@container"</span>></span>
|
|
214
|
+
<span class="hljs-tag"><<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"clamp-[text,lg,3xl,@sm,@5xl] clamp-[py,2,4,@29.5rem,@82rem]"</span>></span>
|
|
215
|
+
Add some fluid typography and padding to the content of the container.
|
|
216
|
+
<span class="hljs-tag"></<span class="hljs-name">div</span>></span>
|
|
217
|
+
<span class="hljs-tag"></<span class="hljs-name">div</span>></span>
|
|
218
|
+
</code></pre>
|
|
219
|
+
<h2 id="supported-properties">Supported properties</h2>
|
|
220
|
+
<ul>
|
|
221
|
+
<li><code>p</code> including <code>pt</code>, <code>pb</code>, <code>pl</code>, <code>pr</code>, <code>px</code>, <code>py</code>, <code>ps</code>, <code>pe</code>.</li>
|
|
222
|
+
<li><code>m</code> including <code>mt</code>, <code>mb</code>, <code>ml</code>, <code>mr</code>, <code>mx</code>, <code>my</code>, <code>ms</code>, <code>me</code>.</li>
|
|
223
|
+
<li><code>inset</code> including <code>inset-x</code>, <code>inset-y</code>.</li>
|
|
224
|
+
<li><code>top</code></li>
|
|
225
|
+
<li><code>left</code> and <code>start</code>.</li>
|
|
226
|
+
<li><code>right</code> and <code>end</code>.</li>
|
|
227
|
+
<li><code>bottom</code></li>
|
|
228
|
+
<li><code>text</code> including <code>font-size</code>, <code>line-height</code> and <code>letter-spacing</code> if defined.</li>
|
|
229
|
+
<li><code>gap</code> including <code>gap-x</code>, <code>gap-y</code>.</li>
|
|
230
|
+
<li><code>w</code></li>
|
|
231
|
+
<li><code>h</code></li>
|
|
232
|
+
<li><code>size</code></li>
|
|
233
|
+
<li><code>min-w</code> and <code>min-h</code></li>
|
|
234
|
+
<li><code>max-w</code> and <code>max-h</code></li>
|
|
235
|
+
<li><code>rounded</code> including <code>rounded-s</code>, <code>rounded-ss</code>, <code>rounded-se</code>, <code>rounded-e</code>, <code>rounded-ee</code>, <code>rounded-es</code>, <code>rounded-t</code>, <code>rounded-r</code>, <code>rounded-b</code>, <code>rounded-l</code>, <code>rounded-tl</code>, <code>rounded-tr</code>, <code>rounded-bl</code>, <code>rounded-br</code>.</li>
|
|
236
|
+
<li><code>translate-x</code> and <code>translate-y</code></li>
|
|
237
|
+
<li><code>text-stroke</code></li>
|
|
238
|
+
<li><code>stroke</code></li>
|
|
239
|
+
<li><code>leading</code></li>
|
|
240
|
+
<li><code>tracking</code></li>
|
|
241
|
+
<li><code>border</code> including <code>border-t</code>, <code>border-b</code>, <code>border-l</code>, <code>border-r</code>, <code>border-x</code>, <code>border-y</code>.</li>
|
|
242
|
+
<li><code>scroll-m</code> including <code>scroll-mx</code>, <code>scroll-my</code>, <code>scroll-ms</code>, <code>scroll-me</code>, <code>scroll-mt</code>, <code>scroll-mb</code>, <code>scroll-ml</code>, <code>scroll-mr</code></li>
|
|
243
|
+
<li><code>scroll-p</code> including <code>scroll-px</code>, <code>scroll-py</code>, <code>scroll-ps</code>, <code>scroll-pe</code>, <code>scroll-pt</code>, <code>scroll-pb</code>, <code>scroll-pl</code>, <code>scroll-pr</code></li>
|
|
244
|
+
</ul>
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
</body>
|
|
249
|
+
</html>
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Tailwind clamp
|
|
1
|
+
# Tailwind clamp 🗜️
|
|
2
2
|
|
|
3
3
|
Tailwind CSS plugin to use CSS `clamp` in your project. Enabling fluid interfaces using Tailwind syntax.
|
|
4
4
|
|
|
@@ -11,6 +11,7 @@ The plugin is based on the formula presented in this [article](https://chriskirk
|
|
|
11
11
|
- Supports `px`, `rem` and `em` units.
|
|
12
12
|
- Supports `text` values with multiple properties (`fontSize`, `lineHeight`, `letterSpacing`). If `lineHeight` is definded as a unitless number or a `calc()` function, the resulting value is calculated and converted to the `fontSize` unit.
|
|
13
13
|
- Supports using Tailwind CSS theme values, arbitrary values or a combination.
|
|
14
|
+
- Supports container queries.
|
|
14
15
|
|
|
15
16
|
## Requirements
|
|
16
17
|
|
|
@@ -35,36 +36,36 @@ Add the plugin in your main CSS file:
|
|
|
35
36
|
|
|
36
37
|
The plugin allows two configuration options:
|
|
37
38
|
|
|
38
|
-
| Name
|
|
39
|
-
|
|
|
40
|
-
| **`
|
|
41
|
-
| **`
|
|
39
|
+
| Name | Type | Description | Default value |
|
|
40
|
+
| ------------- | ---------- | -------------------------------------------------- | ------------- |
|
|
41
|
+
| **`minSize`** | `{string}` | Viewport or container size where the clamp starts. | `23.4375rem` |
|
|
42
|
+
| **`maxSize`** | `{string}` | Viewport or container size where the clamp end. | `90rem` |
|
|
42
43
|
|
|
43
44
|
Value should be a css length (`px`, `rem`, `em`). The unit for both options need to match.
|
|
44
45
|
|
|
45
46
|
```css
|
|
46
47
|
@import "tailwindcss";
|
|
47
48
|
@plugin "tailwind-clamp" {
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
minSize: 25rem,
|
|
50
|
+
maxSize: 80rem
|
|
50
51
|
};
|
|
51
52
|
```
|
|
52
53
|
|
|
53
54
|
## Usage
|
|
54
55
|
|
|
55
|
-
The plugin relies on the arbitrary values syntax `clamp-[...]`. You need to pass at least three arguments separated by commas without whitespace, optionally you can also pass the `
|
|
56
|
+
The plugin relies on the arbitrary values syntax `clamp-[...]`. You need to pass at least three arguments separated by commas without whitespace, optionally you can also pass the `minSize` and the `maxSize`:
|
|
56
57
|
|
|
57
58
|
```
|
|
58
|
-
clamp-[<property>,<start>,<end>,[
|
|
59
|
+
clamp-[<property>,<start>,<end>,[minSize,maxSize]]
|
|
59
60
|
```
|
|
60
61
|
|
|
61
62
|
### Arguments
|
|
62
63
|
|
|
63
|
-
-
|
|
64
|
-
-
|
|
65
|
-
-
|
|
66
|
-
-
|
|
67
|
-
-
|
|
64
|
+
- **`property`** Property that the value should be applied to. See a list of all supported properties below.
|
|
65
|
+
- **`start`** Value at `minSize` viewport size. It can be a key from your Tailwind CSS config file or a a css length (`px`, `rem`, `em`), the unit will need to match `end`.
|
|
66
|
+
- **`end`** Value at `maxSize` viewport size. It can be a key from your Tailwind CSS config file or a css length (`px`, `rem`, `em`), the unit will need to match `start`.
|
|
67
|
+
- **`[minSize=23.4375rem]`** Viewport or container size, where the clamp starts, defaults to `23.4375rem` (`375px`). It can be a breakpoint name from your theme or a css length (`px`, `rem`, `em`), the unit will need to match `maxSize` and be smaller than `maxSize`.
|
|
68
|
+
- **`[maxSize=90rem]`** Viewport or container size, where the clamp stops, defaults to `90rem` (`1440px`). It can be a breakpoint name from your theme or a css length (`px`, `rem`, `em`), the unit will need to match `minSize` and be be larger than `minSize`.
|
|
68
69
|
|
|
69
70
|
### Examples
|
|
70
71
|
|
|
@@ -72,6 +73,12 @@ clamp-[<property>,<start>,<end>,[minViewportWidth,maxViewportWidth]]
|
|
|
72
73
|
<div class="clamp-[px,20,40] clamp-[py,10,18]">
|
|
73
74
|
Add some fluid padding here.
|
|
74
75
|
</div>
|
|
76
|
+
|
|
77
|
+
<div class="@container">
|
|
78
|
+
<div class="clamp-[text,lg,3xl,@sm,@5xl] clamp-[py,2,4,@29.5rem,@82rem]">
|
|
79
|
+
Add some fluid typography and padding to the content of the container.
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
75
82
|
```
|
|
76
83
|
|
|
77
84
|
## Supported properties
|
|
@@ -97,8 +104,5 @@ clamp-[<property>,<start>,<end>,[minViewportWidth,maxViewportWidth]]
|
|
|
97
104
|
- `leading`
|
|
98
105
|
- `tracking`
|
|
99
106
|
- `border` including `border-t`, `border-b`, `border-l`, `border-r`, `border-x`, `border-y`.
|
|
100
|
-
- `scroll-m`
|
|
101
|
-
|
|
102
|
-
## Roadmap
|
|
103
|
-
|
|
104
|
-
- Add showcase
|
|
107
|
+
- `scroll-m` including `scroll-mx`, `scroll-my`, `scroll-ms`, `scroll-me`, `scroll-mt`, `scroll-mb`, `scroll-ml`, `scroll-mr`
|
|
108
|
+
- `scroll-p` including `scroll-px`, `scroll-py`, `scroll-ps`, `scroll-pe`, `scroll-pt`, `scroll-pb`, `scroll-pl`, `scroll-pr`
|