css-preflight 2.0.2 → 2.0.3
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/LICENSE_TAILWIND.md +21 -0
- package/README.md +144 -0
- package/package.json +1 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Tailwind Labs, Inc.
|
|
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,144 @@
|
|
|
1
|
+
# CSS Preflight
|
|
2
|
+
|
|
3
|
+
This is a CSS browser reset based on Tailwind's preflight, optimized for non-Tailwind projects. Optional enhancements like smooth scrolling and other utilities are also provided.
|
|
4
|
+
|
|
5
|
+
## Differences to Tailwind's Preflight
|
|
6
|
+
|
|
7
|
+
The following adjustments have been made to the preflight:
|
|
8
|
+
|
|
9
|
+
1. Tailwind-specific CSS variables and styling removed.
|
|
10
|
+
2. Two Tailwind `font-family` defaults have been removed from the preflight in favor of optional imports. One was setting the default font stack for the overall HTML document, and the other was setting monospace fonts for HTML elements like `code`.
|
|
11
|
+
|
|
12
|
+
#### Why Font Family Defaults Removed
|
|
13
|
+
|
|
14
|
+
Font stacks are a rapidly evolving space at the moment, and the use of system fonts is becoming more common, such as in Tailwind's preflight. However, the use of `system-ui` and similar values for the `font-family` property can be problematic. They not only depend on the OS version, but on the language settings of the OS as well, which can be unpredictable, according to the following article: https://infinnie.github.io/blog/2017/systemui.html.
|
|
15
|
+
|
|
16
|
+
Granted, this is an older article, but as a precaution, `font-family` defaults have been moved to optional imports with possible system fonts being manually specified over the usage of `system-ui`, `monospace-ui`, etc.
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
#pnpm
|
|
22
|
+
pnpm add css-preflight
|
|
23
|
+
|
|
24
|
+
#npm
|
|
25
|
+
npm install css-preflight
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Typical Usage
|
|
29
|
+
|
|
30
|
+
Note this setup doesn't contain any defaults for the main font. Those are available as optional imports.
|
|
31
|
+
|
|
32
|
+
```javascript
|
|
33
|
+
// main preflight
|
|
34
|
+
// import "css-preflight" does the same.
|
|
35
|
+
import "css-preflight/preflight.css";
|
|
36
|
+
|
|
37
|
+
// Sets default fonts for html elements that use monospace fonts
|
|
38
|
+
// Unnecessary to use this if wanting to set your own monospace fonts
|
|
39
|
+
import "css-preflight/mono-elements.css";
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
For fastest performance, it's recommended to have the CSS directly injected into the HTML as a `<style>` tag, along with any other critical CSS applying to above-the-fold content. Avoid putting the `<style>` tag inside `<head>` as invalid CSS can break processing of other elements inside `<head>`.
|
|
43
|
+
|
|
44
|
+
```html
|
|
45
|
+
<head></head>
|
|
46
|
+
<body>
|
|
47
|
+
<style>
|
|
48
|
+
<!-- Inject here -->
|
|
49
|
+
</style>
|
|
50
|
+
<!-- Rest of html -->
|
|
51
|
+
</body>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Reminder to set emoji font fallbacks when defining your own font stacks:
|
|
55
|
+
|
|
56
|
+
```css
|
|
57
|
+
:root,
|
|
58
|
+
:host {
|
|
59
|
+
font-family:
|
|
60
|
+
/* Your fonts here */
|
|
61
|
+
sans-serif, /* or serif, monospace, etc. */
|
|
62
|
+
/* then do: */
|
|
63
|
+
"Apple Color Emoji",
|
|
64
|
+
"Segoe UI Emoji",
|
|
65
|
+
"Segoe UI Symbol",
|
|
66
|
+
"Noto Color Emoji";
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Package Exports
|
|
71
|
+
|
|
72
|
+
### Main Preflight
|
|
73
|
+
|
|
74
|
+
The main Tailwind-derived CSS reset.
|
|
75
|
+
|
|
76
|
+
#### Bare Import
|
|
77
|
+
|
|
78
|
+
```javascript
|
|
79
|
+
import "css-preflight"; // styles/preflight.css
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
#### Named Import
|
|
83
|
+
|
|
84
|
+
```javascript
|
|
85
|
+
import "css-preflight/preflight.css"; // styles/preflight.css
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Default Main Fonts
|
|
89
|
+
|
|
90
|
+
Sets a default main font for the document (body text, headings, etc.) Only applies these to `:root` and `:host`, to be inherited by other elements. Useful in development when no main font has been chosen for the design yet, or for simple testing purposes.
|
|
91
|
+
|
|
92
|
+
#### Mono
|
|
93
|
+
|
|
94
|
+
```javascript
|
|
95
|
+
import "css-preflight/font-mono.css";
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
#### Sans Serif
|
|
99
|
+
|
|
100
|
+
```javascript
|
|
101
|
+
import "css-preflight/font-sans-serif.css";
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
#### Serif
|
|
105
|
+
|
|
106
|
+
```javascript
|
|
107
|
+
import "css-preflight/font-serif.css";
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Mono Elements
|
|
111
|
+
|
|
112
|
+
Sets a default monospace font stack for the `code`, `kbd`, `samp`, and `pre` HTML elements. Many design and branding systems don't include monospace font guidelines so this option can be useful for those cases.
|
|
113
|
+
|
|
114
|
+
```javascript
|
|
115
|
+
import "css-preflight/mono-elements.css";
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Rem Same Px
|
|
119
|
+
|
|
120
|
+
Sets `1 rem = 1px` at the root for easier design-dev hand-off. This calculation is done using `%`, so if the user adjusts the browser font sizes, those will still affect the page for accessibility purposes. Note this may affect framework error debug message pages in development (e.g. Nuxt, Next, Astro, etc.).
|
|
121
|
+
|
|
122
|
+
```javascript
|
|
123
|
+
import "css-preflight/rem-same-px.css"; // styles/rem-same-px.css
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Smooth Scroll
|
|
127
|
+
|
|
128
|
+
Enables smooth scrolling to anchor points (e.g. #about). Disabled for `prefers-reduced-motion`.
|
|
129
|
+
|
|
130
|
+
```javascript
|
|
131
|
+
import "css-preflight/smooth-scroll.css"; // styles/smooth-scroll.css
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Text Wrap Balance
|
|
135
|
+
|
|
136
|
+
Adds `text-wrap: balance` on h1-h6 and blockquote. Helps prevent single hanging words on heading newlines.
|
|
137
|
+
|
|
138
|
+
```javascript
|
|
139
|
+
import "css-preflight/text-wrap-balance.css"; // styles/text-wrap-balance.css
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## License
|
|
143
|
+
|
|
144
|
+
The repo falls under MIT licensing, contained in the LICENSE.md file. Usage of the `preflight.css` file is also subject to Tailwind's licensing (MIT), which is included in the repo for reference.
|
package/package.json
CHANGED