├── .editorconfig ├── .gitattributes ├── .gitignore ├── LICENSE ├── README.md ├── index.html ├── index.ts ├── package.json ├── test.ts ├── tsconfig.json └── yarn.lock /.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | root = true 3 | 4 | # All files should use 5 | # - tabs unless specified otherwise 6 | # - unix-style newlines with a newline ending every file 7 | [*] 8 | indent_style = space 9 | indent_size = 2 10 | end_of_line = lf 11 | charset = utf-8 12 | trim_trailing_whitespace = true 13 | insert_final_newline = true 14 | 15 | [*.md] 16 | trim_trailing_whitespace = false 17 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Set default behavior to always use LF line endings 2 | * text=auto eol=lf 3 | 4 | # Denote all files that are truly binary and should not be modified. 5 | *.ico binary 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .build 2 | build 3 | node_modules 4 | web_modules 5 | .DS_Store 6 | 7 | .cache 8 | dist 9 | website 10 | __generated__ 11 | tsconfig.dist*.json 12 | 13 | benchmarks/*.min.mjs 14 | 15 | # Svelte Component type defs 16 | *.svelte.tsx 17 | __svelte-jsx.d.ts 18 | __svelte-shims.d.ts 19 | 20 | # Logs 21 | logs 22 | *.log 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | lerna-debug.log* 27 | 28 | # Diagnostic reports (https://nodejs.org/api/report.html) 29 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 30 | 31 | # Runtime data 32 | pids 33 | *.pid 34 | *.seed 35 | *.pid.lock 36 | 37 | # Directory for instrumented libs generated by jscoverage/JSCover 38 | lib-cov 39 | 40 | # Coverage directory used by tools like istanbul 41 | coverage/ 42 | *.lcov 43 | 44 | # nyc test coverage 45 | .nyc_output 46 | 47 | # Dependency directories 48 | node_modules/ 49 | jspm_packages/ 50 | 51 | # TypeScript v1 declaration files 52 | typings/ 53 | 54 | # TypeScript cache 55 | *.tsbuildinfo 56 | 57 | # Optional npm cache directory 58 | .npm 59 | 60 | # Optional eslint cache 61 | .eslintcache 62 | 63 | # Optional REPL history 64 | .node_repl_history 65 | 66 | # Output of 'npm pack' 67 | *.tgz 68 | 69 | # Yarn Integrity file 70 | .yarn-integrity 71 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 [these people](https://github.com/tw-in-js/forms/graphs/contributors) 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. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # @twind/forms 2 | 3 | A [Twind](https://twind.dev) extension that provides a basic reset for form styles that makes form elements easy to override with utilities. 4 | 5 | [](https://github.com/tw-in-js/twind-forms/blob/main/LICENSE) 6 | [](https://www.npmjs.com/package/@twind/forms) 7 | [](https://github.com/tw-in-js/twind-forms) 8 | [](https://unpkg.com/@twind/forms/forms.js 'brotli module size') 9 | [](https://unpkg.com/browse/@twind/forms/forms.d.ts) 10 | 11 | > Based on [@tailwindcss/forms](https://github.com/tailwindlabs/tailwindcss-forms) and [with form classes](https://github.com/tailwindlabs/tailwindcss-forms/pull/39). 12 | 13 | ## Installation 14 | 15 | Install from npm: 16 | 17 | ```sh 18 | # Using npm 19 | npm install @twind/forms 20 | 21 | # Using Yarn 22 | yarn add @twind/forms 23 | ``` 24 | 25 | ## Usage as Directive 26 | 27 | ```js 28 | import { forms } from '@twind/forms' 29 | 30 | document.body.innerHTML = ` 31 |
34 | ` 35 | ``` 36 | 37 | ## Usage as Plugin 38 | 39 | ```js 40 | import { forms } from '@twind/forms' 41 | 42 | setup({ 43 | plugins: { 44 | forms, 45 | }, 46 | }) 47 | ``` 48 | 49 | ```html 50 | 53 | ``` 54 | 55 | ## Usage as Preflight 56 | 57 | Add to the `preflight` of your setup call: 58 | 59 | ```js 60 | import { withForms } from '@twind/forms' 61 | 62 | setup({ 63 | preflight: withForms(), 64 | }) 65 | 66 | setup({ 67 | preflight: withForms({ 68 | /* custom preflight */ 69 | }), 70 | }) 71 | 72 | setup({ 73 | preflight: withForms((preflight, context) => { 74 | /* custom preflight */ 75 | }), 76 | }) 77 | ``` 78 | 79 | ## Usage as form field Directive 80 | 81 | ```js 82 | import { 83 | formCheckbox, 84 | formField, 85 | formFile, 86 | formInput, 87 | formRadio, 88 | formSelect, 89 | formTextarea, 90 | } from '@twind/forms' 91 | 92 | document.body.innerHTML = ` 93 | 94 | ` 95 | ``` 96 | 97 | ## Usage as form field Plugins 98 | 99 | ```js 100 | import { forms } from '@twind/forms' 101 | 102 | setup({ 103 | plugins: { 104 | 'form-checkbox': formCheckbox, 105 | 'form-field': formField, 106 | 'form-file': formFile, 107 | 'form-input': formInput, 108 | 'form-radio': formRadio, 109 | 'form-select': formSelect, 110 | 'form-textarea': formTextarea, 111 | }, 112 | }) 113 | ``` 114 | 115 | ```html 116 | 117 | ``` 118 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |23 | These are form elements this plugin styles by default. 24 |
25 |163 | These are form elements we don't handle (yet?), but we use this to make sure we haven't 164 | accidentally styled them by mistake. 165 |
166 |