Examples of usage

Type something to try out

Default input label

<NuxtFloatLabel>
    <input type="text" placeholder="Name" />
</NuxtFloatLabel>

Using a different label from placeholder

<NuxtFloatLabel label="A more complex text">
    <input type="text" placeholder="Text" />
</NuxtFloatLabel>

Select input

<NuxtFloatLabel>
  <select>
    <option disabled selected>Do you enjoy coding?</option>
    <option>Yes</option>
    <option>No</option>
  </select>
</NuxtFloatLabel>

Textarea input

<NuxtFloatLabel>
  <textarea type="text" placeholder="Description" />
</NuxtFloatLabel>

Set custom label class

<NuxtFloatLabel labelClass="text-purple-700">
    <input type="text" placeholder="Name" />
</NuxtFloatLabel>

Show float label on start by setting dispatch to true

<NuxtFloatLabel :dispatch="true">
  <input type="text" placeholder="Name" />
</NuxtFloatLabel>

Quick Setup

  1. Add nuxt-float-label dependency to your project
# Using npm
npm i -D nuxt-float-label
  1. Add nuxt-float-label to the modules section of nuxt.config.js
{
  modules: [
    'nuxt-float-label'
  ]
}

Props

NameTypeDescriptionRequired
labelStringOverrides placeholderNo
label-classStringAttribute a custom class to the labelNo
dispatchBooleanShows float label on mountNo

Configs

To use on nuxt.config.ts

NameTypeDescription
useCssBooleanChoose to use the default css or a custom one

Example

nuxtFloatLabel: {
    useCss: false
}

Css classes

NameDescription
fl-wrapperWrapper class
fl-labelLabel class
fl-on-focusLabel on focus and blur event
fl-on-inputLabel on input event