Skip to main content
You are viewing Pre-Alpha documentation.
Vuetify0 Logo
Theme
Mode
Accessibility
Vuetify

Sign in

Sign in with your preferred provider to access your account.

useProxyModel

A composable for syncing refs bidirectionally with selection contexts, enabling seamless v-model integration with selection state.


Intermediate99.1% coverageFeb 4, 2026

Usage

The useProxyModel composable syncs an existing ref (like from defineModel()) with a selection context bidirectionally. Changes in either direction automatically propagate.

ts
import { ref } from 'vue'
import { createSelection, useProxyModel } from '@vuetify/v0'

const model = ref<string>()
const selection = createSelection({ events: true })

selection.onboard([
  { id: 'apple', value: 'Apple' },
  { id: 'banana', value: 'Banana' },
])

// Sync model with selection
const stop = useProxyModel(selection, model)

model.value = 'Apple'
console.log(selection.selectedIds) // Set { 'apple' }

selection.select('banana')
console.log(model.value) // 'Banana'

Architecture

useProxyModel creates bidirectional sync between v-model refs and selection state:

Proxy Model Flow

Use controls to zoom and pan. Click outside or press Escape to close.

Proxy Model Flow

Reactivity

useProxyModel creates bidirectional reactive sync between a ref and a selection registry. It uses Vue watchers internally for automatic propagation.

BehaviorReactiveNotes
Model → SelectionChanges to model auto-select items
Selection → ModelSelection changes update model
Tip

Automatic cleanup The watchers are disposed automatically via onScopeDispose. The returned stop() function allows early manual cleanup.

API Reference

The following API details are for the useProxyModel composable.

Functions

useProxyModel

(registry: SelectionContext<Z>, model: Ref<unknown, unknown>, options?: ProxyModelOptions) => () => void

Syncs a ref with a selection registry bidirectionally.

Options

multiple

MaybeRefOrGetter<boolean>

transformIn

(val: unknown) => unknown

transformOut

(val: unknown) => unknown
Was this page helpful?

© 2016-1970 Vuetify, LLC
Ctrl+/