Skip to content

Commit d625ea1

Browse files
committed
Update README, move tailwindcss to dependencies
1 parent 9ac4ac3 commit d625ea1

File tree

3 files changed

+59
-11
lines changed

3 files changed

+59
-11
lines changed

Diff for: README.md

+54-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
A plugin that provides basic default form styles that are easy to override with utilities. Hopefully the successor to `@tailwindcss/custom-forms`.
44

5-
65
## Installation
76

87
Install the plugin from npm:
@@ -32,4 +31,57 @@ module.exports = {
3231

3332
## Usage
3433

35-
All of the basic form elements you use will now have some sensible default styles that are easy to override with utilities. Works basically like the `@tailwindcss/custom-forms` plugin in terms of how you modify things using utility classes. More details eventually.
34+
All of the basic form elements you use will now have some sensible default styles that are easy to override with utilities.
35+
36+
Currently we add basic utility-friendly form styles for the following form element types:
37+
38+
- `input[type='text']`
39+
- `input[type='password']`
40+
- `input[type='email']`
41+
- `input[type='number']`
42+
- `input[type='url']`
43+
- `input[type='date']`
44+
- `input[type='datetime-local']`
45+
- `input[type='month']`
46+
- `input[type='week']`
47+
- `input[type='time']`
48+
- `input[type='search']`
49+
- `input[type='tel']`
50+
- `input[type='checkbox']`
51+
- `input[type='radio']`
52+
- `select`
53+
- `select[multiple]`
54+
- `textarea`
55+
56+
**Note that for text inputs, you must add the `type="text"` attribute for these styles to take effect.** This is a necessary trade-off to avoid relying on the overly greedy `input` selector and unintentionally styling elements we don't have solutions for yet, like `input[type="range"]` for example.
57+
58+
Every element has been normalized/reset in a way that they look pretty great without doing anything to them at all:
59+
60+
```html
61+
<!-- This just looks good! -->
62+
<input type="text">
63+
```
64+
65+
The real benefit of this plugin however is that all of these elements are easy to modify on the fly with utilities, which is not possible with user agent form styles:
66+
67+
```html
68+
<!-- You can customize padding on a select element! Oh my god! -->
69+
<select class="px-4 py-3 rounded-full">
70+
<!-- ... -->
71+
</select>
72+
```
73+
74+
We've baked in a few useful tricks, like making the checkbox and radio controls use `currentColor` for their checked state, so you can even customize how those look using text color utilities:
75+
76+
```html
77+
<!-- This will be blue when checked -->
78+
<input type="checkbox" class="text-blue-500">
79+
80+
<!-- This will be pink when checked -->
81+
<input type="checkbox" class="text-pink-500">
82+
83+
<!-- This will be green when checked -->
84+
<input type="checkbox" class="text-green-500">
85+
```
86+
87+
More customization examples and best practices coming soon.

Diff for: demo.html

+3-7
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,8 @@
1212
<body>
1313
<div class="antialiased text-gray-900 px-6">
1414
<div class="max-w-2xl mx-auto py-12">
15-
<div class="flex flex-wrap -mx-6">
16-
<div class="w-1/2 px-6">
17-
<label class="block">
18-
<span class="text-gray-700">Input (no type)</span>
19-
<input class="mt-1 block w-full" placeholder="[email protected]" />
20-
</label>
15+
<div class="grid grid-cols-2 gap-4">
16+
<div>
2117
<label class="block mt-4">
2218
<span class="text-gray-700">Input (text)</span>
2319
<input type="text" class="mt-1 block w-full" placeholder="[email protected]" />
@@ -112,7 +108,7 @@
112108
</div>
113109
</div>
114110
</div>
115-
<div class="w-1/2 px-2">
111+
<div>
116112
<label class="block">
117113
<span class="text-gray-700">Select</span>
118114
<select class="block w-full mt-1">

Diff for: package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
"devDependencies": {
2020
"autoprefixer": "^9.6.1",
2121
"clean-css": "^4.2.1",
22-
"postcss": "^7.0.17",
23-
"tailwindcss": "^2.0.0-alpha.14"
22+
"postcss": "^7.0.17"
2423
},
2524
"dependencies": {
25+
"tailwindcss": "^2.0.0-alpha.15",
2626
"mini-svg-data-uri": "^1.2.3"
2727
}
2828
}

0 commit comments

Comments
 (0)