npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tlwind-forms

v0.0.2

Published

A plugin that provides a basic reset for form styles that makes form elements easy to override with utilities.

Downloads

1

Readme

tlwind-forms

A plugin that provides a basic reset for form styles that makes form elements easy to override with utilities.

Installation

Install the plugin from npm:

npm install -D tlwind-forms

Then add the plugin to your tailwind.config.js file:

// tailwind.config.js
module.exports = {
  theme: {
    // ...
  },
  plugins: [
    require('tlwind-forms'),
    // ...
  ],
}

Basic usage

View the live demo

All of the basic form elements you use will now have some simple default styles that are easy to override with utilities.

Currently we add basic utility-friendly form styles for the following form element types:

  • input[type='text']
  • input[type='password']
  • input[type='email']
  • input[type='number']
  • input[type='url']
  • input[type='date']
  • input[type='datetime-local']
  • input[type='month']
  • input[type='week']
  • input[type='time']
  • input[type='search']
  • input[type='tel']
  • input[type='checkbox']
  • input[type='radio']
  • select
  • select[multiple]
  • textarea

Every element has been normalized/reset to a simple visually consistent style that is easy to customize with utilities, even elements like <select> or <input type="checkbox"> that normally need to be reset with appearance: none and customized using custom CSS:

<!-- You can actually customize padding on a select element now: -->
<select class="px-4 py-3 rounded-full">
  <!-- ... -->
</select>

<!-- Or change a checkbox color using text color utilities: -->
<input type="checkbox" class="rounded text-pink-500" />

More customization examples and best practices coming soon.

Using classes to style

In addition to the global styles, we also generate a set of corresponding classes which can be used to explicitly apply the form styles to an element. This can be useful in situations where you need to make a non-form element, such as a <div>, look like a form element.

<input type="email" class="form-input px-4 py-3 rounded-full" />

<select class="form-select px-4 py-3 rounded-full">
  <!-- ... -->
</select>

<input type="checkbox" class="form-checkbox rounded text-pink-500" />

Here is a complete table of the provided form-* classes for reference:

| Base | Class | | ------------------------- | ------------------ | | [type='text'] | form-input | | [type='email'] | form-input | | [type='url'] | form-input | | [type='password'] | form-input | | [type='number'] | form-input | | [type='date'] | form-input | | [type='datetime-local'] | form-input | | [type='month'] | form-input | | [type='search'] | form-input | | [type='tel'] | form-input | | [type='time'] | form-input | | [type='week'] | form-input | | textarea | form-textarea | | select | form-select | | select[multiple] | form-multiselect | | [type='checkbox'] | form-checkbox | | [type='radio'] | form-radio |

Using only global styles or only classes

Although we recommend thinking of this plugin as a "form reset" rather than a collection of form component styles, in some cases our default approach may be too heavy-handed, especially when integrating this plugin into existing projects.

If generating both the global (base) styles and classes doesn't work well with your project, you can use the strategy option to limit the plugin to just one of these approaches.

// tailwind.config.js
plugins: [
  require("tlwind-forms")({
    strategy: 'base', // only generate global styles
    strategy: 'class', // only generate classes
  }),
],

When using the base strategy, form elements are styled globally, and no form-{name} classes are generated.

When using the class strategy, form elements are not styled globally, and instead must be styled using the generated form-{name} classes.