@dblechoc/twind-forms
TypeScript icon, indicating that this package has built-in type declarations

0.1.32 • Public • Published

@twind/forms

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

MIT License Latest Release Github Module Size Typescript

Based on @tailwindcss/forms and with form classes.

Installation

Install from npm:

# Using npm
npm install @twind/forms

# Using Yarn
yarn add @twind/forms

Usage as Directive

import { forms } from '@twind/forms'

document.body.innerHTML = `
  <form class="${tw`max-w-xs mx-auto ${forms}`}">
    <!-- ... -->
  </form>
`

Usage as Plugin

import { forms } from '@twind/forms'

setup({
  plugins: {
    forms,
  },
})
<form class="max-w-xs mx-auto forms">
  <!-- ... -->
</form>

Usage as Preflight

Add to the preflight of your setup call:

import { withForms } from '@twind/forms'

setup({
  preflight: withForms(),
})

setup({
  preflight: withForms({
    /* custom preflight */
  }),
})

setup({
  preflight: withForms((preflight, context) => {
    /* custom preflight */
  }),
})

Usage as form field Directive

import { formCheckbox, formField, formFile, formInput, formRadio, formSelect, formTextarea } from '@twind/forms'

document.body.innerHTML = `
  <input class="${tw`${formInput}`}">
`

Usage as form field Plugins

import { forms } from '@twind/forms'

setup({
  plugins: {
    'form-checkbox': formCheckbox,
    'form-field': formField,
    'form-file': formFile,
    'form-input': formInput,
    'form-radio': formRadio,
    'form-select': formSelect,
    'form-textarea': formTextarea,
  },
})
<input class="${tw`form-input`}">

Dependents (0)

Package Sidebar

Install

npm i @dblechoc/twind-forms

Homepage

twind.dev

Weekly Downloads

0

Version

0.1.32

License

MIT

Unpacked Size

79.5 kB

Total Files

12

Last publish

Collaborators

  • dblechoc