# autofocus

Vue directive to bring focus to an element when it mounts to the page.

Source

# Installation

Global install:

import Vue from "vue"
import { autofocus } from "vuetensils"

Vue.directive("autofocus", autofocus)

Local install:

<script>
  import { autofocus } from "vuetensils"

  export default {
    directives: {
      autofocus,
    },
  }
</script>

# Usage

<template>
  <div>
    <p>Check it out, this input is focused whenever the page loads</p>
    <form>
      <label>
        Some label
        <input v-autofocus />
      </label>
    </form>
  </div>
</template>

With multiple elements, focus will land on the latest in the DOM.

Last Updated: 11/19/2019, 5:58:27 AM