Skip to content

Omit the requirement to specify the type attribute for the text inputs #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ Currently we add basic utility-friendly form styles for the following form eleme
- `select[multiple]`
- `textarea`

**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.

Every element has been normalized/reset in a way that they look pretty great without doing anything to them at all:

```html
Expand Down Expand Up @@ -86,4 +84,4 @@ We've baked in a few useful tricks, like making the checkbox and radio controls
<input type="checkbox" class="text-green-500">
```

More customization examples and best practices coming soon.
More customization examples and best practices coming soon.
4 changes: 4 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ <h2 class="text-2xl font-bold">Styled</h2>
<span class="text-gray-700">Input (text)</span>
<input type="text" class="mt-1 block w-full" placeholder="john@example.com" />
</label>
<label class="block">
<span class="text-gray-700">Input (text) [without `type` attribute]</span>
<input class="mt-1 block w-full" placeholder="john@example.com" />
</label>
<label class="block">
<span class="text-gray-700">Input (email)</span>
<input type="email" class="mt-1 block w-full" placeholder="john@example.com" />
Expand Down
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const { colors, spacing, borderWidth, borderRadius, outline } = defaultTheme
const forms = plugin(function ({ addBase, theme }) {
addBase({
[`
input:not([type]),
[type='text'],
[type='email'],
[type='url'],
Expand Down