@@ -4,80 +4,33 @@ Tailwind plugin to add floating label, control with float label components
44
55Demo - https://unlight.github.io/tailwind-float-label
66
7- ## Setup
7+ ## Setup and configration
88
9- ``` sh
10- npm install --save-dev tailwind-float-label
11- ```
12-
13- Add plugin to ` plugins ` section of ` tailwind.config.js `
14-
15- ``` js
16- plugins: [require (' tailwind-float-label' )(options)],
17- ```
18-
19- ## Options
20-
21- ``` ts
22- type Options = {
23- /**
24- * Custom styles for container.
25- */
26- container? : DeepPartial <{ [k : string ]: string } | string >;
27- /**
28- * Custom styles for input control.
29- */
30- control? : DeepPartial <{ [k : string ]: string } | string >;
31- /**
32- * Custom styles for label.
33- */
34- label? : DeepPartial <{ [k : string ]: string } | string >;
35- };
36- ```
37-
38- ## Usage
39-
40- Plugins adds these components supposed used together:
41-
42- - ` .float-label-container ` Container which holds input control and label
43- - ` .float-label-control ` Form control
44- - ` .float-label-self ` Label
45- - ` .float-label-sticky ` Label which is always visible
46- - But ` .float-label-auto ` Automatically make ` label ` floating and ` input ` inside this container
9+ 1 . ` npm install --save-dev tailwind-float-label `
10+ 2 . Add ` @import 'tailwind-float-label' ` to your main css file
11+ 3 . Plugin provides classes which must be set for label and input to make label floats.
12+ - ` .float-container ` Container which holds input control and label
13+ - ` .float-input ` Form input control
14+ - ` .float-always ` Use with ` .float-container ` to makem label always visible (sticky)
4715
4816``` html
4917<form class =" max-w-xs mx-auto p-5 space-y-4" >
5018 <h2 class =" text-2xl font-bold text-center" >Example</h2 >
51- <div class =" float-label-container" >
52- <input
53- type =" text"
54- id =" name"
55- autocomplete =" off"
56- placeholder =" Name"
57- class =" float-label-control outline-none focus:shadow-outline border w-full px-1"
58- />
19+ <div class =" float-container" >
5920 <label for =" name" class =" float-label-self bg-white text-gray-500"
6021 >Name</label
6122 >
62- </div >
63- <!-- Auto: make `label` floating for `input` -->
64- <div class =" float-label-auto" >
6523 <input
6624 type =" text"
67- id =" auto "
25+ id =" name "
6826 autocomplete =" off"
69- placeholder =" Auto "
70- class =" outline-none focus:shadow-outline border w-full px-1"
27+ placeholder =" Name "
28+ class =" float-input outline-none focus:shadow-outline border w-full px-1"
7129 />
72- <label for =" auto" class =" bg-white text-gray-500" >Auto</label >
7330 </div >
7431</form >
7532```
7633
77- #### Notes:
78-
79- ` .float-label-control ` and ` .float-label-self ` must be direct children of ` .float-label-container `
80-
8134## Similar Projects
8235
8336- https://github.com/notiz-dev/floating-form-field-tailwindcss
@@ -100,5 +53,3 @@ Plugins adds these components supposed used together:
10053- update readme (no sticky, just remove input placeholder)
10154- block with multiple type of input (select, text area)
10255- block with size of inputs (lg, xs, sm)
103- - build
104- - rewrite documenation (old version, anatomy)
0 commit comments