Vue Utility Components

0.4.65 · active · verified Sun Apr 19

vueuc is a collection of essential utility components designed for Vue 3 applications, currently at version 0.4.65. This library provides specialized components such as `VBinder` for advanced element positioning and tracking, `VVirtialList` for efficient rendering of large datasets with variable-height items, `VXScroll` for horizontal scrolling via vertical mouse wheel input, and `VResizeObserver` for observing element dimension changes. The library's development and maintenance are primarily driven by a single developer, as explicitly stated in the README, which implies a potentially less formal release cadence and documentation style. Its key differentiator lies in offering low-level UI utilities focused on specific interaction patterns and performance optimizations (like virtualization), distinguishing it from broader UI component libraries. Users should note that detailed API documentation might be sparse, often requiring consultation of the source code.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates the usage of `VBinder`, `VTarget`, and `VFollower` for element positioning, along with `VVirtialList` for rendering a large, scrollable list efficiently in a Vue 3 component using `<script setup>`.

<template>
  <div style="height: 200px; padding: 50px; border: 1px solid #ccc;">
    <p>Target element below:</p>
    <v-binder>
      <v-target>
        <div ref="targetEl" style="width: 100px; height: 50px; background-color: lightblue; text-align: center; line-height: 50px;">
          Target
        </div>
      </v-target>
      <v-follower :show="true" placement="bottom-start" :overlap="true" :width="100">
        <div style="background-color: lightcoral; padding: 10px; border: 1px solid red;">
          Follower content
          <br>
          (Bottom-start)
        </div>
      </v-follower>
       <v-follower :show="true" placement="top-end" :overlap="true" :width="100">
        <div style="background-color: lightgreen; padding: 10px; border: 1px solid green;">
          Follower content
          <br>
          (Top-end)
        </div>
      </v-follower>
    </v-binder>
    <p style="margin-top: 20px;">Scroll down to see virtual list example.</p>
  </div>

  <div style="height: 300px; border: 1px solid #eee; margin-top: 20px;">
    <h3 style="margin: 0; padding: 10px;">Virtual List Example</h3>
    <v-virtual-list
      :items="items"
      :item-height="50"
      :height="250"
      style="border: 1px solid blue; overflow: auto;"
    >
      <template #default="{ item, index }">
        <div :key="item.id" style="height: 50px; display: flex; align-items: center; padding-left: 10px; border-bottom: 1px solid #f0f0f0;">
          Item {{ item.text }} - {{ index }}
        </div>
      </template>
    </v-virtual-list>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { VBinder, VTarget, VFollower, VVirtialList } from 'vueuc';

const targetEl = ref<HTMLElement | null>(null);

const items = Array.from({ length: 1000 }, (_, i) => ({
  id: i,
  text: `Content for item ${i}`,
}));
</script>

<style>
body { margin: 0; font-family: sans-serif; }
</style>

view raw JSON →