useDefaults

Commons
stable

Component-side hook for the OrigamDefaultsProvider system. Returns a Proxy over the component's own props that resolves each value through a four-level chain: explicitly passed prop → component-specific defaults from the closest provider → global defaults from the closest provider → withDefaults() value.

API

Signature

Full TypeScript signature sourced from the composable file.

typescript

The wasPropPassed check reads vm.vnode.props on every resolution (not once at setup) to handle dynamic v-bind patterns where the parent's forwarded props may be empty on the first render.

Consumed interfaces

IDefault

API

Parameters

Input parameters accepted by this composable.

props
required
T
The component's reactive props object (as returned by defineProps).
name
string
getCurrentInstanceName()
Component name used to look up component-specific defaults in the provider. Defaults to the current instance's kebab-cased name via getCurrentInstanceName().

API

Return values

Properties and methods exposed by the composable return object.

(proxied props)
A Proxy wrapping the original props. Every property read goes through the four-level resolution chain. Object.keys(), spread, and filterProps still see the original prop names. Non-prop accesses (Vue internals, symbols) are forwarded to the original props directly.

Usage

Examples

Ready-to-paste usage snippets.

Opt in to defaults resolution in a component

vue

Provide defaults for a subtree

vue