useProvided

Commons
stable

Create a two-way-bound ref that falls back to an injected provided value when the component prop is null. The ref stays in sync with the provided value unless the consumer explicitly overrides it via the prop.

API

Signature

Full TypeScript signature sourced from the util file.

typescript

API

Parameters

Input parameters accepted by this util.

props
required
any
The component props object (from defineProps).
prop
required
string
The name of the prop key to watch and sync, e.g. "locale".
provided
required
Ref<T>
The injected fallback ref (e.g. from useLocale() at the ancestor level).

API

Return value

The value returned by this util.

A reactive ref that mirrors the prop when set, or the provided value when the prop is null/undefined.

Usage

Examples

Ready-to-paste usage snippets.

Locale prop with provided fallback

typescript