url stringlengths 24 106 | html stringlengths 41 53k | title stringlengths 0 63 |
|---|---|---|
https://vuejs.org/api/built-in-components.html | Built-in Components
Registration and Usage
Built-in components can be used directly in templates without needing to be registered. They are also tree-shakeable: they are only included in the build when they are used.
When using them in render functions, they need to be imported explicitly. For example:
js
import ... | Built-in Components | Vue.js |
https://vuejs.org/api/built-in-directives.html | Built-in Directives
v-text
Update the element's text content.
Expects: string
Details
v-text works by setting the element's textContent property, so it will overwrite any existing content inside the element. If you need to update the part of textContent, you should use mustache interpolations instead.
Example
... | Built-in Directives | Vue.js |
https://vuejs.org/api/component-instance.html | Component Instance
INFO
This page documents the built-in properties and methods exposed on the component public instance, i.e. this.
All properties listed on this page are readonly (except nested properties in $data).
$data
The object returned from the data option, made reactive by the component. The component... | Component Instance | Vue.js |
https://vuejs.org/api/options-misc.html | Options: Misc
name
Explicitly declare a display name for the component.
Type
ts
interface ComponentOptions {
name?: string
}
Details
The name of a component is used for the following:
Recursive self-reference in the component's own template
Display in Vue DevTools' component inspection tree
Display in warni... | Options: Misc | Vue.js |
https://vuejs.org/api/options-composition.html | Options: Composition
provide
Provide values that can be injected by descendant components.
Type
ts
interface ComponentOptions {
provide?: object | ((this: ComponentPublicInstance) => object)
}
Details
provide and inject are used together to allow an ancestor component to serve as a dependency injector for al... | Options: Composition | Vue.js |
https://vuejs.org/api/options-lifecycle.html | Options: Lifecycle
See also
For shared usage of lifecycle hooks, see Guide - Lifecycle Hooks
beforeCreate
Called when the instance is initialized.
Type
ts
interface ComponentOptions {
beforeCreate?(this: ComponentPublicInstance): void
}
Details
Called immediately when the instance is initialized, after pr... | Options: Lifecycle | Vue.js |
https://vuejs.org/api/options-rendering.html | Options: Rendering
template
A string template for the component.
Type
ts
interface ComponentOptions {
template?: string
}
Details
A template provided via the template option will be compiled on-the-fly at runtime. It is only supported when using a build of Vue that includes the template compiler. The templat... | Options: Rendering | Vue.js |
https://vuejs.org/api/options-state.html | Options: State
data
A function that returns the initial reactive state for the component instance.
Type
ts
interface ComponentOptions {
data?(
this: ComponentPublicInstance,
vm: ComponentPublicInstance
): object
}
Details
The function is expected to return a plain JavaScript object, which will be m... | Options: State | Vue.js |
https://vuejs.org/api/composition-api-dependency-injection.html | Composition API:
Dependency Injection
provide()
Provides a value that can be injected by descendant components.
Type
ts
function provide<T>(key: InjectionKey<T> | string, value: T): void
Details
provide() takes two arguments: the key, which can be a string or a symbol, and the value to be injected.
When using... | Composition API: Dependency Injection | Vue.js |
https://vuejs.org/api/composition-api-lifecycle.html | Composition API: Lifecycle Hooks
Usage Note
All APIs listed on this page must be called synchronously during the setup() phase of a component. See Guide - Lifecycle Hooks for more details.
onMounted()
Registers a callback to be called after the component has been mounted.
Type
ts
function onMounted(callback: ... | Composition API: Lifecycle Hooks | Vue.js |
https://vuejs.org/api/reactivity-advanced.html | Reactivity API: Advanced
shallowRef()
Shallow version of ref().
Type
ts
function shallowRef<T>(value: T): ShallowRef<T>
interface ShallowRef<T> {
value: T
}
Details
Unlike ref(), the inner value of a shallow ref is stored and exposed as-is, and will not be made deeply reactive. Only the .value access is rea... | Reactivity API: Advanced | Vue.js |
https://vuejs.org/api/reactivity-utilities.html | Reactivity API: Utilities
isRef()
Checks if a value is a ref object.
Type
ts
function isRef<T>(r: Ref<T> | unknown): r is Ref<T>
Note the return type is a type predicate, which means isRef can be used as a type guard:
ts
let foo: unknown
if (isRef(foo)) {
// foo's type is narrowed to Ref<unknown>
foo.value... | Reactivity API: Utilities | Vue.js |
https://vuejs.org/api/reactivity-core.html | Reactivity API: Core
See also
To better understand the Reactivity APIs, it is recommended to read the following chapters in the guide:
Reactivity Fundamentals (with the API preference set to Composition API)
Reactivity in Depth
ref()
Takes an inner value and returns a reactive and mutable ref object, which has ... | Reactivity API: Core | Vue.js |
https://vuejs.org/api/composition-api-setup.html | Composition API: setup()
Basic Usage
The setup() hook serves as the entry point for Composition API usage in components in the following cases:
Using Composition API without a build step;
Integrating with Composition-API-based code in an Options API component.
Note
If you are using Composition API with Single-F... | Composition API: setup() | Vue.js |
https://vuejs.org/api/general.html | Global API: General
version
Exposes the current version of Vue.
Type: string
Example
js
import { version } from 'vue'
console.log(version)
nextTick()
A utility for waiting for the next DOM update flush.
Type
ts
function nextTick(callback?: () => void): Promise<void>
Details
When you mutate reactive stat... | Global API: General | Vue.js |
https://vuejs.org/api/application.html | Application API
createApp()
Creates an application instance.
Type
ts
function createApp(rootComponent: Component, rootProps?: object): App
Details
The first argument is the root component. The second optional argument is the props to be passed to the root component.
Example
With inline root component:
js
im... | Application API | Vue.js |
https://vuejs.org/api/application.html#createapp | Application API
createApp()
Creates an application instance.
Type
ts
function createApp(rootComponent: Component, rootProps?: object): App
Details
The first argument is the root component. The second optional argument is the props to be passed to the root component.
Example
With inline root component:
js
im... | Application API | Vue.js |
https://vueuse.org/core/useUrlSearchParams/?foo=bar&vueuse=awesome#VPContent | useUrlSearchParams
Category
Browser
Export Size
1.59 kB
Last Changed
last year
Reactive URLSearchParams
Demo
source
foo=bar
vueuse=awesome
Usage
js
import { useUrlSearchParams } from '@vueuse/core'
const params = useUrlSearchParams('history')
console.log(params.foo) // 'bar'
params.foo = 'bar'
params.vueus... | useUrlSearchParams | VueUse |
https://vueuse.org/core/useCloned/#VPContent | useCloned
Category
Utilities
Export Size
499 B
Last Changed
6 months ago
Reactive clone of a ref. By default, it use JSON.parse(JSON.stringify()) to do the clone.
Demo
source
reset
Usage
ts
import { useCloned } from '@vueuse/core'
const original = ref({ key: 'value' })
const { cloned } = useCloned(original)... | useCloned | VueUse |
https://vueuse.org/core/useTimestamp/#VPContent | useTimestamp
Category
Animation
Export Size
817 B
Last Changed
last year
Reactive current timestamp
Demo
source
Timestamp: 1701206238338
Usage
js
import { useTimestamp } from '@vueuse/core'
const timestamp = useTimestamp({ offset: 0 })
js
const { timestamp, pause, resume } = useTimestamp({ controls: true })
... | useTimestamp | VueUse |
https://vueuse.org/core/templateRef/#VPContent | templateRef
Category
Component
Export Size
270 B
Last Changed
last year
Shorthand for binding ref to template element.
Usage
vue
<script lang="ts">
import { templateRef } from '@vueuse/core'
export default {
setup() {
const target = templateRef('target')
// no need to return the `target`, it will bind... | templateRef | VueUse |
https://vueuse.org/core/useRafFn/#VPContent | useRafFn
Category
Animation
Export Size
342 B
Last Changed
2 months ago
Call function on every requestAnimationFrame. With controls of pausing and resuming.
Demo
source
Count: 8
pauseresume
Usage
js
import { ref } from 'vue'
import { useRafFn } from '@vueuse/core'
const count = ref(0)
const { pause, resume ... | useRafFn | VueUse |
https://vueuse.org/core/useSpeechSynthesis/#VPContent | useSpeechSynthesis
Category
Sensors
Export Size
724 B
Last Changed
2 months ago
Reactive SpeechSynthesis.
Can I use?
Demo
source
Spoken Text
Language
Select Language
Pitch
Rate
SpeakPauseStop
Usage
ts
import { useSpeechSynthesis } from '@vueuse/core'
const {
isSupported,
isPlaying,
status,
voice... | useSpeechSynthesis | VueUse |
https://vueuse.org/core/useDevicePixelRatio/#VPContent | useDevicePixelRatio
Category
Sensors
Export Size
294 B
Last Changed
2 months ago
Reactively track window.devicePixelRatio
NOTE: there is no event listener for window.devicePixelRatio change. So this function uses Testing media queries programmatically (window.matchMedia) applying the same mechanism as described in ... | useDevicePixelRatio | VueUse |
https://vueuse.org/core/onStartTyping/#VPContent | onStartTyping
Category
Sensors
Export Size
704 B
Last Changed
8 months ago
Fires when users start typing on non-editable elements.
Demo
source
Type anything
Usage
html
<input ref="input" type="text" placeholder="Start typing to focus" />
ts
import { onStartTyping } from '@vueuse/core'
export default {
setu... | onStartTyping | VueUse |
https://vueuse.org/core/useurlsearchparams/?foo=bar&vueuse=awesome#VPContent | useUrlSearchParams
Category
Browser
Export Size
1.59 kB
Last Changed
last year
Reactive URLSearchParams
Demo
source
foo=bar
vueuse=awesome
Usage
js
import { useUrlSearchParams } from '@vueuse/core'
const params = useUrlSearchParams('history')
console.log(params.foo) // 'bar'
params.foo = 'bar'
params.vueus... | useUrlSearchParams | VueUse |
https://vueuse.org/core/useFileSystemAccess/#VPContent | useFileSystemAccess
Category
Browser
Export Size
878 B
Last Changed
2 months ago
Create and read and write local files with FileSystemAccessAPI
Demo
source
Open
New file
Save
Save as
DataType
Text
ArrayBuffer
Blob
isSupported: true
fileName: ''
fileMIME: ''
fileSize: 0
fileLastModified: 0
Usage
ts
import { u... | useFileSystemAccess | VueUse |
https://vueuse.org/core/useMouseInElement/#VPContent | useMouseInElement
Category
Elements
Export Size
1.12 kB
Last Changed
3 weeks ago
Reactive mouse position related to an element
Demo
source
Hover me
x: 0
y: 0
sourceType: null
elementX: -976
elementY: -408
elementPositionX: 976
elementPositionY: 408
elementHeight: 160
elementWidth: 160
isOutside: true
Usage
h... | useMouseInElement | VueUse |
https://vueuse.org/core/useElementVisibility/#VPContent | useElementVisibility
Category
Elements
Export Size
692 B
Last Changed
2 months ago
Tracks the visibility of an element within the viewport.
Demo
source
Info on the right bottom corner
Target Element (scroll down)
Element inside the viewport
Usage
html
<template>
<div ref="target">
<h1>Hello world</h1>
... | useElementVisibility | VueUse |
https://vueuse.org/core/useTimeoutPoll/ | useTimeoutPoll
Category
Utilities
Export Size
407 B
Last Changed
5 months ago
Use timeout to poll something. It's will trigger callback after last task is done.
Demo
source
Count: 0
isActive: false
pauseresume
Usage
ts
import { useTimeoutPoll } from '@vueuse/core'
const count = ref(0)
async function fetchDa... | useTimeoutPoll | VueUse |
https://vueuse.org/core/useSupported/ | useSupported
Category
Utilities
Export Size
194 B
Last Changed
8 months ago
SSR compatibility isSupported
Usage
ts
import { useSupported } from '@vueuse/core'
const isSupported = useSupported(() => navigator && 'getBattery' in navigator)
if (isSupported.value) {
// do something
navigator.getBattery
}
Source... | useSupported | VueUse |
https://vueuse.org/core/useDebouncedRefHistory/#VPContent | useDebouncedRefHistory
Category
State
Export Size
1.7 kB
Last Changed
8 months ago
Related
useRefHistory
useThrottledRefHistory
Shorthand for useRefHistory with debounced filter.
Demo
source
Count: 0
IncrementDecrement/UndoRedo
Delay (in ms):
History (limited to 10 records for demo)
2023-11-28 22:17:15{ valu... | useDebouncedRefHistory | VueUse |
https://vueuse.org/core/useSessionStorage/#VPContent | useSessionStorage
Category
State
Export Size
2.03 kB
Last Changed
8 months ago
Related
useStorage
Reactive SessionStorage.
Usage
Please refer to useStorage
Source
Source • Docs
Contributors
Anthony Fu
Antério Vieira
ntnyq
Jelf
Shinigami
Pig Fang
Alex Kozack
Changelog
v10.0.0-beta.4 on 4/13/2023
4d757 - ... | useSessionStorage | VueUse |
https://vueuse.org/core/useStepper/ | useStepper
Category
Utilities
Export Size
433 B
Last Changed
last year
Provides helpers for building a multi-step wizard interface.
Demo
source
User information
Billing address
Terms
Payment
User information
First name:
Last name:
Next
Form
{
"firstName": "Jon",
"lastName": "",
"billingAddress": "",
"co... | useStepper | VueUse |
https://vueuse.org/core/usePrevious/ | usePrevious
Category
Utilities
Export Size
260 B
Last Changed
8 months ago
Holds the previous value of a ref.
Usage
ts
import { ref } from 'vue'
import { usePrevious } from '@vueuse/core'
const counter = ref('Hello')
const previous = usePrevious(counter)
console.log(previous.value) // undefined
counter.value =... | usePrevious | VueUse |
https://vueuse.org/core/useMemoize/ | useMemoize
Category
Utilities
Export Size
403 B
Last Changed
8 months ago
Cache results of functions depending on arguments and keep it reactive. It can also be used for asynchronous functions and will reuse existing promises to avoid fetching the same data at the same time.
TIP
The results are not cleared automat... | useMemoize | VueUse |
https://vueuse.org/core/useOffsetPagination/ | useOffsetPagination
Category
Utilities
Export Size
650 B
Last Changed
4 months ago
Reactive offset pagination.
Demo
source
total:
80
pageCount:
8
currentPageSize:
10
currentPage:
1
isFirstPage:
true
isLastPage:
false
prev12345678next
id name
Usage
TypeScript
ts
import { useOffsetPagination } from '@vueuse/cor... | useOffsetPagination | VueUse |
https://vueuse.org/core/useEventBus/ | useEventBus
Category
Utilities
Export Size
332 B
Last Changed
2 months ago
A basic event bus.
Demo
source
News channel:
Broadcast
Television:
--- no signal ---
Usage
TypeScript
ts
import { useEventBus } from '@vueuse/core'
const bus = useEventBus<string>('news')
function listener(event: string) {
console.lo... | useEventBus | VueUse |
https://vueuse.org/core/useCycleList/ | useCycleList
Category
Utilities
Export Size
463 B
Last Changed
7 months ago
Cycle through a list of items.
Learn how to use useCycleList to create an image carousel with this FREE video lesson from Vue School!
Demo
source
Dog
PrevNext
Usage
ts
import { useCycleList } from '@vueuse/core'
const { state, next, ... | useCycleList | VueUse |
https://vueuse.org/core/usecloned/ | useCloned
Category
Utilities
Export Size
499 B
Last Changed
5 months ago
Reactive clone of a ref. By default, it use JSON.parse(JSON.stringify()) to do the clone.
Demo
source
reset
Usage
ts
import { useCloned } from '@vueuse/core'
const original = ref({ key: 'value' })
const { cloned } = useCloned(original)... | useCloned | VueUse |
https://vueuse.org/core/useConfirmDialog/ | useConfirmDialog
Category
Utilities
Export Size
418 B
Last Changed
2 months ago
Creates event hooks to support modals and confirmation dialog chains.
Functions can be used on the template, and hooks are a handy skeleton for the business logic of modals dialog or other actions that require user confirmation.
Demo
... | useConfirmDialog | VueUse |
https://vueuse.org/core/useCached/ | useCached
Category
Utilities
Export Size
169 B
Last Changed
2 years ago
Cache a ref with a custom comparator.
Demo
source
Value: 42
Extra: 0
Cached Value: 42
Cached Extra: 0
Temp Value:
Local Extra:
Sync
Usage
TypeScript
ts
import { useCached } from '@vueuse/core'
interface Data {
value: number
extra: n... | useCached | VueUse |
https://vueuse.org/core/useBase64/ | useBase64
Category
Utilities
Export Size
769 B
Last Changed
8 months ago
Reactive base64 transforming. Supports plain text, buffer, files, canvas, objects, maps, sets and images.
Demo
source
Text Input
Base64
Buffer Input
new ArrayBuffer(1024)
Base64
File Input
Base64
Image Input
Base64
Usage
TypeScript
ts
im... | useBase64 | VueUse |
https://vueuse.org/core/useAsyncQueue/ | useAsyncQueue
Category
Utilities
Export Size
511 B
Last Changed
3 months ago
Executes each asynchronous task sequentially and passes the current task result to the next task
Demo
source
activeIndex: 1
result: [ { "state": "fulfilled", "data": 1000 }, { "state": "fulfilled", "data": 2000 } ]
Usage
TypeScript
t... | useAsyncQueue | VueUse |
https://vueuse.org/core/useTimeAgo/ | useTimeAgo
Category
Time
Export Size
1.63 kB
Last Changed
2 months ago
Reactive time ago. Automatically update the time ago string when the time changes.
Demo
source
just now
0ms
Usage
js
import { useTimeAgo } from '@vueuse/core'
const timeAgo = useTimeAgo(new Date(2021, 0, 1))
Component Usage
This functi... | useTimeAgo | VueUse |
https://vueuse.org/core/createUnrefFn/ | createUnrefFn
Category
Utilities
Export Size
166 B
Last Changed
8 months ago
Related
reactify
Make a plain function accepting ref and raw values as arguments. Returns the same value the unconverted function returns, with proper typing.
TIP
Make sure you're using the right tool for the job. Using reactify might be ... | createUnrefFn | VueUse |
https://vueuse.org/core/computedAsync/ | computedAsync
Category
Reactivity
Export Size
358 B
Last Changed
9 months ago
Alias
asyncComputed
Computed for async functions
Usage
js
import { ref } from 'vue'
import { computedAsync } from '@vueuse/core'
const name = ref('jack')
const userInfo = computedAsync(
async () => {
return await mockLookUp(name... | computedAsync | VueUse |
https://vueuse.org/core/useVModels/ | useVModels
Category
Component
Export Size
567 B
Last Changed
2 months ago
Related
useVModel
Shorthand for props v-model binding. Think it like toRefs(props) but changes will also trigger emit.
Usage
js
import { useVModels } from '@vueuse/core'
export default {
props: {
foo: String,
bar: Number,
},
... | useVModels | VueUse |
https://vueuse.org/core/useSorted/ | useSorted
Category
Array
Export Size
366 B
Last Changed
2 months ago
reactive sort array
Demo
source
input:
random
output: [ "13", "17", "41", "49", "53", "59", "67", "72", "81", "98", "99" ]
object property sort:
input:
[ { "name": "John", "age": 40 }, { "name": "Jane", "age": 20 }, { "name": "Joe", "age": 30 ... | useSorted | VueUse |
https://vueuse.org/core/useVModel/ | useVModel
Category
Component
Export Size
533 B
Last Changed
4 months ago
Related
useVModels
Shorthand for v-model binding, props + emit -> ref
Usage
js
import { useVModel } from '@vueuse/core'
export default {
setup(props, { emit }) {
const data = useVModel(props, 'data', emit)
console.log(data.value)... | useVModel | VueUse |
https://vueuse.org/core/useVirtualList/ | useVirtualList
Category
Component
Export Size
1.8 kB
Last Changed
2 months ago
WARNING
Consider using vue-virtual-scroller instead, if you are looking for more features.
Create virtual lists with ease. Virtual lists (sometimes called virtual scrollers) allow you to render a large number of items performantly. They... | useVirtualList | VueUse |
https://vueuse.org/core/useTemplateRefsList/ | useTemplateRefsList
Category
Component
Export Size
177 B
Last Changed
2 years ago
Shorthand for binding refs to template elements and components inside v-for.
WARNING
This function only works for Vue 3
Demo
source
12345
IncDec
Open the console to see the output
Usage
html
<template>
<div v-for="i of 5" :k... | useTemplateRefsList | VueUse |
https://vueuse.org/core/useMounted/ | useMounted
Category
Component
Export Size
156 B
Last Changed
2 months ago
Mounted state in ref.
Demo
source
mounted
Usage
js
import { useMounted } from '@vueuse/core'
const isMounted = useMounted()
Which is essentially a shorthand of:
ts
const isMounted = ref(false)
onMounted(() => {
isMounted.value = t... | useMounted | VueUse |
https://vueuse.org/core/useCurrentElement/ | useCurrentElement
Category
Component
Export Size
355 B
Last Changed
last year
Get the DOM element of current component as a ref.
Demo
source
Open your console.log to see the element
Usage
ts
import { useCurrentElement } from '@vueuse/core'
const el = useCurrentElement() // ComputedRef<Element>
Caveats
Thi... | useCurrentElement | VueUse |
https://vueuse.org/core/unrefElement/ | unrefElement
Category
Component
Export Size
165 B
Last Changed
8 months ago
Retrieves the underlying DOM element from a Vue ref or component instance
Usage
html
<template>
<div ref="div"/>
<HelloWorld ref="hello"/>
</template>
<script setup>
import { ref, onMounted } from 'vue'
import { unrefElement } from '... | unrefElement | VueUse |
https://vueuse.org/core/templateref/ | templateRef
Category
Component
Export Size
270 B
Last Changed
last year
Shorthand for binding ref to template element.
Usage
vue
<script lang="ts">
import { templateRef } from '@vueuse/core'
export default {
setup() {
const target = templateRef('target')
// no need to return the `target`, it will bind... | templateRef | VueUse |
https://vueuse.org/core/createTemplatePromise/ | createTemplatePromise
Category
Component
Export Size
497 B
Last Changed
2 months ago
Template as Promise. Useful for constructing custom Dialogs, Modals, Toasts, etc.
WARNING
This function only works for Vue 3
Demo
source
Open 1
Open 2
Open 1 & 2
Usage
html
<script setup lang="ts">
import { createTemplatePr... | createTemplatePromise | VueUse |
https://vueuse.org/core/computedInject/ | computedInject
Category
Component
Export Size
183 B
Last Changed
last year
Combine computed and inject
Demo
source
Array
[
{
"key": 1,
"value": "1"
},
{
"key": 2,
"value": "2"
},
{
"key": 3,
"value": "3"
}
]
Computed Array
[
{
"key": 0,
"value": "all"
},
{
"... | computedInject | VueUse |
https://vueuse.org/core/createReusableTemplate/ | createReusableTemplate
Category
Component
Export Size
738 B
Last Changed
4 months ago
Define and reuse template inside the component scope.
Motivation
It's common to have the need to reuse some part of the template. For example:
html
<template>
<dialog v-if="showInDialog">
<!-- something complex -->
</d... | createReusableTemplate | VueUse |
https://vueuse.org/core/usetimestamp/ | useTimestamp
Category
Animation
Export Size
817 B
Last Changed
last year
Reactive current timestamp
Demo
source
Timestamp: 1701206224633
Usage
js
import { useTimestamp } from '@vueuse/core'
const timestamp = useTimestamp({ offset: 0 })
js
const { timestamp, pause, resume } = useTimestamp({ controls: true })
... | useTimestamp | VueUse |
https://vueuse.org/core/useTransition/ | useTransition
Category
Animation
Export Size
1.15 kB
Last Changed
2 months ago
Transition between values
Demo
source
Transition
Cubic bezier curve: 0.00
Custom function: 0.00
Vector: [0.00, 0.00]
Usage
Define a numeric source value to follow, and when changed the output will transition to the new value. ... | useTransition | VueUse |
https://vueuse.org/core/useraffn/ | useRafFn
Category
Animation
Export Size
342 B
Last Changed
2 months ago
Call function on every requestAnimationFrame. With controls of pausing and resuming.
Demo
source
Count: 5
pauseresume
Usage
js
import { ref } from 'vue'
import { useRafFn } from '@vueuse/core'
const count = ref(0)
const { pause, resume ... | useRafFn | VueUse |
https://vueuse.org/core/useAnimate/ | useAnimate
Category
Animation
Export Size
1.56 kB
Last Changed
4 months ago
Reactive Web Animations API.
Demo
source
VueUse useAnimate
pausereversefinishcancel
startTime: 1876.8
currentTime: 233.30000000000007
playbackRate: 1
playState: 'running'
replaceState: 'active'
pending: false
Usage
Basic Usage
Th... | useAnimate | VueUse |
https://vueuse.org/core/useNow/ | useNow
Category
Animation
Export Size
788 B
Last Changed
2 years ago
Reactive current Date instance.
Demo
source
Now: Tue Nov 28 2023 22:17:03 GMT+0100 (Central European Standard Time)
Usage
js
import { useNow } from '@vueuse/core'
const now = useNow()
js
const { now, pause, resume } = useNow({ controls: tru... | useNow | VueUse |
https://vueuse.org/core/useWebSocket/ | useWebSocket
Category
Network
Export Size
1.34 kB
Last Changed
3 weeks ago
Reactive WebSocket client.
Usage
js
import { useWebSocket } from '@vueuse/core'
const { status, data, send, open, close } = useWebSocket('ws://websocketurl')
See the Type Declarations for more options.
Immediate
Auto-connect (enabled... | useWebSocket | VueUse |
https://vueuse.org/core/useEventSource/ | useEventSource
Category
Network
Export Size
679 B
Last Changed
7 months ago
An EventSource or Server-Sent-Events instance opens a persistent connection to an HTTP server, which sends events in text/event-stream format.
Usage
js
import { useEventSource } from '@vueuse/core'
const { status, data, error, close } = ... | useEventSource | VueUse |
https://vueuse.org/core/useFetch/ | useFetch
Category
Network
Export Size
2.42 kB
Last Changed
3 weeks ago
Reactive Fetch API provides the ability to abort requests, intercept requests before they are fired, automatically refetch requests when the url changes, and create your own useFetch with predefined options.
Learn useFetch with this FREE video l... | useFetch | VueUse |
https://vueuse.org/core/useUserMedia/ | useUserMedia
Category
Sensors
Export Size
569 B
Last Changed
8 months ago
Related
useDevicesList
useDisplayMedia
usePermission
Reactive mediaDevices.getUserMedia streaming.
Demo
source
Start
Usage
js
import { useUserMedia } from '@vueuse/core'
const { stream, start } = useUserMedia()
start()
ts
const video ... | useUserMedia | VueUse |
https://vueuse.org/core/useTextSelection/ | useTextSelection
Category
Sensors
Export Size
681 B
Last Changed
4 months ago
Reactively track user text selection based on Window.getSelection.
Demo
source
You can select any text on the page.
Selected Text:
No selected
Selected rects:
[]
Usage
html
<template>
<p>{{state.text}}</p>
</template>
<script ... | useTextSelection | VueUse |
https://vueuse.org/core/useSwipe/ | useSwipe
Category
Sensors
Export Size
996 B
Last Changed
4 months ago
Reactive swipe detection based on TouchEvents.
Demo
source
Reset
Swipe right
Direction: none
lengthX: 0 | lengthY: 0
Usage
html
<template>
<div ref="el">
Swipe here
</div>
</template>
<script>
setup() {
const el = ref(null... | useSwipe | VueUse |
https://vueuse.org/core/usespeechsynthesis/ | useSpeechSynthesis
Category
Sensors
Export Size
724 B
Last Changed
2 months ago
Reactive SpeechSynthesis.
Can I use?
Demo
source
Spoken Text
Language
Select Language
Pitch
Rate
SpeakPauseStop
Usage
ts
import { useSpeechSynthesis } from '@vueuse/core'
const {
isSupported,
isPlaying,
status,
voice... | useSpeechSynthesis | VueUse |
https://vueuse.org/core/useParallax/ | useParallax
Category
Sensors
Export Size
1.5 kB
Last Changed
last year
Create parallax effect easily. It uses useDeviceOrientation and fallback to useMouse if orientation is not supported.
Demo
source
roll: 0.5
tilt: -0.5
source: mouse
Credit of images to Jarom Vogel
Usage
html
<div ref='container'>
</div>
j... | useParallax | VueUse |
https://vueuse.org/core/useSpeechRecognition/ | useSpeechRecognition
Category
Sensors
Export Size
694 B
Last Changed
8 months ago
Reactive SpeechRecognition.
Can I use?
Demo
source
English (US)
French
Spanish
Press and talk
Usage
ts
import { useSpeechRecognition } from '@vueuse/core'
const {
isSupported,
isListening,
isFinal,
result,
start,
s... | useSpeechRecognition | VueUse |
https://vueuse.org/core/useScrollLock/ | useScrollLock
Category
Sensors
Export Size
915 B
Last Changed
3 weeks ago
Lock scrolling of the element.
Demo
source
TopLeft
BottomLeft
TopRight
BottomRight
Scroll Me
isLocked false
Lock
Usage
html
<script setup lang="ts">
import { useScrollLock } from '@vueuse/core'
const el = ref<HTMLElement | null>(null)
... | useScrollLock | VueUse |
https://vueuse.org/core/usePointerSwipe/ | usePointerSwipe
Category
Sensors
Export Size
1.04 kB
Last Changed
8 months ago
Reactive swipe detection based on PointerEvents.
Demo
source
Reset
Swipe
Usage
html
<script setup>
import { ref } from 'vue'
import { usePointerSwipe } from '@vueuse/core'
const el = ref(null)
const { isSwiping, direction } = us... | usePointerSwipe | VueUse |
https://vueuse.org/core/useScroll/ | useScroll
Category
Sensors
Export Size
1.53 kB
Last Changed
2 weeks ago
Reactive scroll position and state.
Demo
source
TopLeft
BottomLeft
TopRight
BottomRight
Scroll Me
X Position
Y Position
Smooth scrolling
isScrolling
false
Top Arrived
true
Right Arrived
false
Bottom Arrived
false
Left Arrived
true
Scrolling... | useScroll | VueUse |
https://vueuse.org/core/usePointer/ | usePointer
Category
Sensors
Export Size
1.14 kB
Last Changed
2 months ago
Reactive pointer state.
Demo
source
{
"x": 0,
"y": 0,
"pointerId": 0,
"pressure": 0,
"tiltX": 0,
"tiltY": 0,
"width": 0,
"height": 0,
"twist": 0,
"pointerType": null,
"isInside": false
}
Basic Usage
js
import { use... | usePointer | VueUse |
https://vueuse.org/core/usePointerLock/ | usePointerLock
Category
Sensors
Export Size
1.36 kB
Last Changed
11 months ago
Reactive pointer lock.
Demo
source
Basic Usage
js
import { usePointerLock } from '@vueuse/core'
const { isSupported, lock, unlock, element, triggerElement } = usePointerLock()
Component Usage
This function also provides a rende... | usePointerLock | VueUse |
https://vueuse.org/core/usePageLeave/ | usePageLeave
Category
Sensors
Export Size
576 B
Last Changed
2 years ago
Reactive state to show whether the mouse leaves the page.
Demo
source
{
"isLeft": false
}
Usage
js
import { usePageLeave } from '@vueuse/core'
const isLeft = usePageLeave()
Component Usage
This function also provides a renderless c... | usePageLeave | VueUse |
https://vueuse.org/core/useOnline/ | useOnline
Category
Sensors
Export Size
830 B
Last Changed
2 years ago
Reactive online state. A wrapper of useNetwork
Demo
source
Disconnect your network to see changes
Status: Online
Usage
js
import { useOnline } from '@vueuse/core'
const online = useOnline()
Component Usage
This function also provides a ... | useOnline | VueUse |
https://vueuse.org/core/useNavigatorLanguage/ | useNavigatorLanguage
Category
Sensors
Export Size
632 B
Last Changed
8 months ago
Reactive navigator.language.
Demo
source
Supported: true
Navigator Language:
en-US
Usage
TypeScript
ts
import { defineComponent, ref } from 'vue'
import { useNavigatorLanguage } from '@vueuse/core'
export default defineComponen... | useNavigatorLanguage | VueUse |
https://vueuse.org/core/useMousePressed/ | useMousePressed
Category
Sensors
Export Size
679 B
Last Changed
2 months ago
Reactive mouse pressing state. Triggered by mousedown touchstart on target element and released by mouseup mouseleave touchend touchcancel on window.
Demo
source
pressed: false
sourceType: null
Tracking on Entire page
Basic Usage
js... | useMousePressed | VueUse |
https://vueuse.org/core/useNetwork/ | useNetwork
Category
Sensors
Export Size
814 B
Last Changed
last year
Reactive Network status. The Network Information API provides information about the system's connection in terms of general connection type (e.g., 'wifi', 'cellular', etc.). This can be used to select high definition content or low definition conte... | useNetwork | VueUse |
https://vueuse.org/core/useMouse/ | useMouse
Category
Sensors
Export Size
825 B
Last Changed
2 months ago
Reactive mouse position
Demo
source
Basic Usage
x: 0
y: 0
sourceType: null
Extractor Usage
x: 0
y: 0
sourceType: null
Basic Usage
js
import { useMouse } from '@vueuse/core'
const { x, y, sourceType } = useMouse()
Touch is enabled by ... | useMouse | VueUse |
https://vueuse.org/core/useKeyModifier/ | useKeyModifier
Category
Sensors
Export Size
587 B
Last Changed
last year
Reactive Modifier State. Tracks state of any of the supported modifiers - see Browser Compatibility notes.
Learn useKeyModifier with this FREE video lesson from Vue School!
Demo
source
capsLock
numLock
scrollLock
shift
control
alt
Usage
... | useKeyModifier | VueUse |
https://vueuse.org/core/useMagicKeys/ | useMagicKeys
Category
Sensors
Export Size
1.02 kB
Last Changed
2 months ago
Reactive keys pressed state, with magical keys combination support.
This function uses Proxy
It is NOT supported by IE 11 or below.
Demo
source
Press the following keys to test out
V
u
e
U
s
e
Shift
Vue
Use
Keys Pressed
Usage
js
imp... | useMagicKeys | VueUse |
https://vueuse.org/core/useInfiniteScroll/ | useInfiniteScroll
Category
Sensors
Export Size
1.98 kB
Last Changed
3 months ago
Infinite scrolling of the element.
Demo
source
1
2
3
4
5
6
Usage
html
<script setup lang="ts">
import { ref } from 'vue'
import { useInfiniteScroll } from '@vueuse/core'
const el = ref<HTMLElement | null>(null)
const data = ref(... | useInfiniteScroll | VueUse |
https://vueuse.org/core/useFocus/ | useFocus
Category
Sensors
Export Size
605 B
Last Changed
4 months ago
Reactive utility to track or set the focus state of a DOM element. State changes to reflect whether the target element is the focused element. Setting reactive value from the outside will trigger focus and blur events for true and false values res... | useFocus | VueUse |
https://vueuse.org/core/useIdle/ | useIdle
Category
Sensors
Export Size
977 B
Last Changed
8 months ago
Tracks whether the user is being inactive.
Demo
source
For demonstration purpose, the idle timeout is set to 5s in this demo (default 1min).
Idle: false
Inactive: 0s
Usage
js
import { useIdle } from '@vueuse/core'
const { idle, lastActive }... | useIdle | VueUse |
https://vueuse.org/core/useGeolocation/ | useGeolocation
Category
Sensors
Export Size
526 B
Last Changed
4 months ago
Reactive Geolocation API. It allows the user to provide their location to web applications if they so desire. For privacy reasons, the user is asked for permission to report location information.
Demo
source
{
"coords": {
"accurac... | useGeolocation | VueUse |
https://vueuse.org/core/useFps/ | useFps
Category
Sensors
Export Size
458 B
Last Changed
2 years ago
Reactive FPS (frames per second).
Demo
source
FPS: 37
Usage
js
import { useFps } from '@vueuse/core'
const fps = useFps()
Source
Source • Demo • Docs
Contributors
Anthony Fu
webfansplz
jelf
Changelog
No recent changes | useFps | VueUse |
https://vueuse.org/core/useFocusWithin/ | useFocusWithin
Category
Sensors
Export Size
769 B
Last Changed
8 months ago
Reactive utility to track if an element or one of its decendants has focus. It is meant to match the behavior of the :focus-within CSS pseudo-class. A common use case would be on a form element to see if any of its inputs currently have focu... | useFocusWithin | VueUse |
https://vueuse.org/core/useElementHover/ | useElementHover
Category
Sensors
Export Size
598 B
Last Changed
8 months ago
Reactive element's hover state.
Demo
source
Hover me
Usage
vue
<script setup>
import { useElementHover } from '@vueuse/core'
const myHoverableElement = ref()
const isHovered = useElementHover(myHoverableElement)
</script>
<template... | useElementHover | VueUse |
https://vueuse.org/core/useElementByPoint/ | useElementByPoint
Category
Sensors
Export Size
953 B
Last Changed
3 weeks ago
Reactive element by point.
Demo
source
X
Y
Usage
ts
import { useElementByPoint, useMouse } from '@vueuse/core'
const { x, y } = useMouse({ type: 'client' })
const { element } = useElementByPoint({ x, y })
Source
Source • Demo • ... | useElementByPoint | VueUse |
https://vueuse.org/core/useDisplayMedia/ | useDisplayMedia
Category
Sensors
Export Size
476 B
Last Changed
2 months ago
Related
useUserMedia
Reactive mediaDevices.getDisplayMedia streaming.
Demo
source
Start sharing my screen
Usage
ts
import { useDisplayMedia } from '@vueuse/core'
const { stream, start } = useDisplayMedia()
// start streaming
start... | useDisplayMedia | VueUse |
https://vueuse.org/core/useDevicesList/ | useDevicesList
Category
Sensors
Export Size
1.09 kB
Last Changed
8 months ago
Related
useUserMedia
Reactive enumerateDevices listing available input/output devices.
Demo
source
CAMERA (0)
MICROPHONES (0)
SPEAKERS (0)
Usage
js
import { useDevicesList } from '@vueuse/core'
const {
devices,
videoInputs: cam... | useDevicesList | VueUse |
https://vueuse.org/core/usedevicepixelratio/ | useDevicePixelRatio
Category
Sensors
Export Size
294 B
Last Changed
2 months ago
Reactively track window.devicePixelRatio
NOTE: there is no event listener for window.devicePixelRatio change. So this function uses Testing media queries programmatically (window.matchMedia) applying the same mechanism as described in ... | useDevicePixelRatio | VueUse |
https://vueuse.org/core/useDeviceOrientation/ | useDeviceOrientation
Category
Sensors
Export Size
672 B
Last Changed
last year
Reactive DeviceOrientationEvent. Provide web developers with information from the physical orientation of the device running the web page.
Demo
source
isSupported: true
isAbsolute: false
alpha: null
beta: null
gamma: null
Usage
js... | useDeviceOrientation | VueUse |
https://vueuse.org/core/useDeviceMotion/ | useDeviceMotion
Category
Sensors
Export Size
703 B
Last Changed
2 years ago
Reactive DeviceMotionEvent. Provide web developers with information about the speed of changes for the device's position and orientation.
Demo
source
Device Motion:
{
"acceleration": {},
"accelerationIncludingGravity": {},
"rotati... | useDeviceMotion | VueUse |
https://vueuse.org/core/onstarttyping/ | onStartTyping
Category
Sensors
Export Size
704 B
Last Changed
8 months ago
Fires when users start typing on non-editable elements.
Demo
source
Type anything
Usage
html
<input ref="input" type="text" placeholder="Start typing to focus" />
ts
import { onStartTyping } from '@vueuse/core'
export default {
setu... | onStartTyping | VueUse |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.