npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

unplugin-formkit

v0.3.0

Published

Automatic FormKit configuration 🪄

Downloads

54,425

Readme

unplugin-formkit

CI

This is an unplugin (Vite, Rollup, Webpack, and esbuild) build tool for injecting FormKit into your Vue 3 application.

Note: This plugin is still still experimental and may change in the future.

What is it?

This plugin eliminates the need to register the global formkit plugin. Instead, it will automatically inject FormKit into your Vue 3 application at the point of use.

By default it will attempt to load a formkit.config.{ts,js,mjs} file in the root of your project.

<script setup>
import { FormKit } from '@formkit/vue'
</script>

<template>
  <FormKit type="form">
    <ForKit
      type="text"
      name="username"
    />
    <ForKit
      type="password"
      name="password"
    />
  </FormKit>
</template>

Into the (conceptually) following:

<script setup>
import { FormKit, FormKitConfigProvider } from '@formkit/vue'
</script>

<template>
  <Suspense>
    <FormKitConfigProvider :config="./formkit.config.ts">
      <FormKit type="form">
        <ForKit
          type="text"
          name="username"
        />
        <ForKit
          type="password"
          name="password"
        />
      </FormKit>
    </FormKit>
  </Suspense>
</template>

[!NOTE] The <Suspense> boundary and configuration loader is only injected if not already in the component tree. These runtime determinations are part of the <FormKitLazyProvider> component, not this plugin.

Installation

npm install unplugin-formkit --save-dev

Then add it to your vite.config.ts (or rollup.config.ts or webpack config etc).

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { formkit } from 'unplugin-formkit'

export default defineConfig({
  plugins: [
    formkit(),
    vue(),
  ]
})

Important: Order matters — this plugin should always be placed before the Vue plugin.

Usage

Once installed, you can use FormKit in your Vue components without any further configuration — FormKit’s configuration will automatically be injected into your application at the point of use.

[!WARNING]
Because a global plugin is not installed, you will not be able to use the this.$formkit API when using options API components.

To add some FormKit configuration to your project, simply create a formkit.config.ts (or .js or .mjs) file in the root of your project (adjacent to your vite.config.ts file) and export a configuration object:

import { DefaultConfigOptions, createInput } from '@formkit/vue';

export default {
  inputs: {
    custom: createInput([
      {
        $el: 'h1',
        children: 'Super Custom Input!',
      },
    ]),
  },
} satisfies DefaultConfigOptions