🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

vue-scroll-picker

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-scroll-picker

iOS Style Scroll Picker Component for Vue 3. Support All Gestures of Mouse(also MouseWheel) and Touch.

2.0.0
latest
Version published
Weekly downloads
4.6K
-18.21%
Maintainers
0
Weekly downloads
 
Created

Vue Scroll Picker

Build Downloads Version License VueJS 3.x Language Typescript

Vue Scroll Picker is an iOS-style scroll picker component for Vue 3. It supports all gestures, including mouse and touch interactions, ensuring a smooth and intuitive user experience.

If you are using Vue 2, please refer to the v0.x branch.

Live Demo (source)

Features

  • TypeScript Support: Uses generics for strict type checking and improved developer experience.
  • Native-like Behavior: Mimics <select> element behavior for consistency.
  • Lightweight & Performant: Minimal dependencies with optimized rendering.

Installation

npm install vue-scroll-picker

Usage

Vue Scroll Picker can be used both globally and locally in your Vue application. Below are examples of how to set it up.

Global Registration

To register Vue Scroll Picker globally in your Vue application, import it in your main file and apply it as a plugin:

Vue3 Global Registration Guide

import { createApp } from "vue";
import VueScrollPicker from "vue-scroll-picker";

import "vue-scroll-picker/dist/style.css";

const app = createApp(); /* */

app.use(VueScrollPicker); // export default is plugin

Local Registration

To use Vue Scroll Picker in a specific component, import it and register it locally:

Vue3 Local Registration Guide

<script setup>
import { VueScrollPicker } from 'vue-scroll-picker'

</script>
<template>
  <VueScrollPicker :options="options" />
</template>
<style src="vue-scroll-picker/dist/style.css"></style>

Options

Props

Vue Scroll Picker accepts several props to customize its behavior:

PropTypeDefaultDescription
modelValuestring | number | boolean | nullundefinedThe selected value of the picker.
optionsArray<{ name: string; value: any; disabled?: boolean }>[]The list of options displayed in the picker.
emptyTextstring'No options available'Text displayed when there are no options available.
dragSensitivitynumber1.7Sensitivity of dragging interaction.
touchSensitivitynumber1.7Sensitivity of touch interaction.
wheelSensitivitynumber1Sensitivity of mouse wheel scrolling.

Events

Vue Scroll Picker emits several events to notify changes:

EventPayloadDescription
update:modelValuestring | number | boolean | nullFired when the selected value changes.
startvoidFired when interaction starts.
movestring | number | boolean | nullFired when the selection moves.
endstring | number | boolean | nullFired when interaction ends.
cancelvoidFired when interaction is canceled.
wheelstring | number | boolean | nullFired when using the mouse wheel.
clickstring | number | boolean | nullFired when the picker is clicked.

Slots

Vue Scroll Picker provides slots for custom rendering:

SlotPropsDescription
default{ option: { name: string; value: any; disabled?: boolean } }Custom rendering for each option.
empty{ text: string }Custom rendering when no options are available.

FAQs

Package last updated on 30 Jan 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts