Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

tailwind-float-label

unlight832MIT3.0.0

Tailwind plugin to add floating label, control with float label components

floating-label, float-label, float-label-pattern, tailwindcss-plugin, tailwind-plugin, tailwind-component, tailwind-components

readme

tailwind-float-label

Tailwind plugin to add floating label, control with float label components

Demo - https://unlight.github.io/tailwind-float-label

Setup

npm install --save-dev tailwind-float-label

Add plugin to plugins section of tailwind.config.js

plugins: [require('tailwind-float-label')(options)],

Options

type Options = {
    /**
     * Custom styles for container.
     */
    container?: DeepPartial<{ [k: string]: string } | string>;
    /**
     * Custom styles for input control.
     */
    control?: DeepPartial<{ [k: string]: string } | string>;
    /**
     * Custom styles for label.
     */
    label?: DeepPartial<{ [k: string]: string } | string>;
};

Usage

Plugins adds these components supposed used together:

  • .float-label-container Container which holds input control and label
  • .float-label-control Form control
  • .float-label-self Label
  • .float-label-sticky Label which is always visible
  • But .float-label-auto Automatically make label floating and input inside this container
<form class="max-w-xs mx-auto p-5 space-y-4">
    <h2 class="text-2xl font-bold text-center">Example</h2>
    <div class="float-label-container">
        <input
            type="text"
            id="name"
            autocomplete="off"
            placeholder="Name"
            class="float-label-control outline-none focus:shadow-outline border w-full px-1"
        />
        <label for="name" class="float-label-self bg-white text-gray-500">Name</label>
    </div>
    <!-- Auto: make `label` floating for `input` -->
    <div class="float-label-auto">
        <input
            type="text"
            id="auto"
            autocomplete="off"
            placeholder="Auto"
            class="outline-none focus:shadow-outline border w-full px-1"
        />
        <label for="auto" class="bg-white text-gray-500">Auto</label>
    </div>
</form>

Notes:

.float-label-control and .float-label-self must be direct children of .float-label-container

Similar Projects

Resources

changelog

3.0.0 (2022-03-13)

⚠ BREAKING CHANGES

  • All classes prefixed with float-label, see readme
  • Tailwind 3

Miscellaneous Chores

Code Refactoring

2.1.0 (2021-09-03)

Features

  • Added .auto-float-label (6b0215e)

2.0.0 (2021-05-01)

Features

  • New helper class .is-float-label-sticky (2a83d5a)

BREAKING CHANGES

  • Inversed markup for sticky label are not working anymore use .is-float-label-sticky instead

1.0.3 (2021-05-01)

Bug Fixes

1.0.2 (2021-05-01)

Bug Fixes

1.0.1 (2020-10-14)

Bug Fixes

1.0.0 (2020-10-11)

Features