useScopeId
Commons
stable
Reads the Vue SFC scope ID from the current component instance and returns it as an attribute object. Used to ensure that teleported or dynamically-created DOM nodes receive the same scoped-CSS attribute as their parent component, so that scoped style rules continue to match across teleport boundaries.
API
Signature
Full TypeScript signature sourced from the composable file.
API
Return values
Properties and methods exposed by the composable return object.
- scopeId
- An object whose single key is the Vue-generated scope attribute (e.g. { "data-v-abc123": "" }). Spread via v-bind on the teleported element to restore scoped CSS. Undefined when the component has no scope ID (e.g. in a plain JS context).
Usage
Examples
Ready-to-paste usage snippets.
Apply scope to a teleported overlay
Spread on a programmatic createElement call