# vue-floater

> Float label pattern for Vue.js

Latest version **1.0.6** (published 2019-04-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install vue-floater
pnpm add vue-floater
yarn add vue-floater
bun add vue-floater
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.6 |
| Published | 2019-04-18 |
| First published | 2019-04-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 18.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Harald Atteneder |
| Maintainers | urbantrout |
| Keywords | vue, vuejs, float, label |

## Links

- npm: https://www.npmjs.com/package/vue-floater
- Repository: https://github.com/urbantrout/vue-floater
- Homepage: https://github.com/urbantrout/vue-floater#readme
- Issues: https://github.com/urbantrout/vue-floater/issues
- npm.io page: https://npm.io/package/vue-floater

## Recent versions

- 1.0.6 (latest) — 2019-04-18
- 1.0.5 — 2019-04-17
- 1.0.4 — 2019-04-17
- 1.0.3 — 2019-04-17
- 1.0.2 — 2019-04-17
- 1.0.1 — 2019-04-17
- 1.0.0 — 2019-04-17

## README

# vue-floater

>  This is a fork of [brtjkzl/vue-floater](https://github.com/brtjkzl/vue-floater)

Float label pattern for Vue.js. Cross-browser compatible and easy to customize
with CSS.

![intro](https://github.com/urbantrout/vue-floater/raw/master/demo/intro.gif)

```html
<floater>
  <input type="text" placeholder="Label">
</floater>
```

## Installation

### npm / yarn

Install package using `npm` or `yarn`:

```sh
$ npm install --save vue-floater

# or

$ yarn add vue-floater
```

#### Global

Load the plugin by calling `Vue.use()`:

```js
import Vue from "vue";
import VueFloater from "vue-floater";

Vue.use(VueFloater);
```

Now you have access in your templates to the `<floater>` component.

#### Local

You may prefer to explicitly import the plugin and use it inside your components:

```vue
<template>
  <floater>
    ...
  </floater>
</template>

<script>
import floater from "vue-floater/components/Floater";

export default {
  components: {
    floater
  }
};
</script>
```

## Usage

Wrap input, textarea or select with `<floater>`:

```html
<floater>
  <input type="email" placeholder="E-mail">
</floater>

<floater>
  <textarea placeholder="Comment"></textarea>
</floater>

<floater :dispatch="false">
  <select>
    <option disabled selected>Framework</option>
    <option>Vue</option>
    <option>React</option>
    <option>Angular</option>
    <option>Ember</option>
  </select>
</floater>
```

See more examples at [Demo.vue](https://github.com/urbantrout/vue-floater/blob/master/demo/Demo.vue).

## Customization

### Design

Style `.vfl-label`, `.vfl-label-on-input` and `.vfl-label-on-focus`
to meet your design requirements:

![example](https://github.com/urbantrout/vue-floater/raw/master/demo/example.gif)

```css
.vfl-label {
  text-transform: uppercase;
}

.vfl-label-on-input {
  top: -1em;
}

.vfl-label-on-focus {
  color: #ff851b;
}

.vfl-label + input {
  padding-left: 0;
  font-size: 100%;
  border: 0;
  border-bottom: 2px solid #aaa;
  transition: border 0.2s;
}

.vfl-label-on-focus + input {
  border-bottom: 2px solid #ff851b;
}
```

### Props

Set `:on` prop to add an additional condition for label activation:

```vue
<template>
  <floater :on="isActive">
    <input type="text" placeholder="Inactive">
  </floater>
</template>

<script>
export default {
  computed: {
    isActive() {
      return false;
    }
  },
  components: {
    floater
  }
};
</script>
```

Set `:label` prop to override `placeholder` attribute for input/textarea or
`option[disabled][selected]` for select:

```html
<floater label="Last name">
  <input type="text" placeholder="Surname">
</floater>
```

```vue
<template>
  <floater label="Version">
    <select v-model="version">
      <option v-for="option in options" :value="option.value">
        {{ option.text }}
      </option>
    </select>
  </floater>
</template>

<script>
export default {
  data() {
    return {
      version: "beta",
      options: [
        { value: "alpha", text: "Alpha" },
        { value: "beta", text: "Beta" },
        { value: "stable", text: "Stable" }
      ]
    };
  },
  components: {
    floater
  }
};
</script>
```

Set `:fixed` to `true` to make label permanently active:

```vue
<template>
  <floater fixed>
    <input type="text" placeholder="Fixed">
  </floater>
</template>
```

Set `:dispatch` to `false` to disable triggering `input` event
once the component is mounted:

_By default it's set to true to activate label when form element has value._

```vue
<template>
  <floater :dispatch="false">
    <input type="email" placeholder="Email" v-model="email">
  </floater>
</template>

<script>
export default {
  data() {
    return {
      email: "john@example.com"
    };
  },
  components: {
    floater
  }
};
</script>
```

## Development

1.  Clone the repository:

    ```sh
    $ git clone git@github.com:urbantrout/vue-floater.git
    ```

2.  Install dependencies:

    ```sh
    $ npm install
    ```

3.  Start development:

    ```sh
    $ npm start
    ```

---

Code is open sourced [on GitHub](https://github.com/urbantrout/vue-floater). Up to date changelog is available under [the releases section](https://github.com/urbantrout/vue-floater/releases).

---
_Source: https://npm.io/package/vue-floater · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
