---
source: https://iinventedlight.com/library/notes/vue-single-file-components.md
title: "Vue single-file components colocate template, script, and style"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "CC BY 4.0, text only (vuejs/docs); MIT (vuejs/core); prose restates cited source lines in own words"
license_family: vue-docs-ccby
attribution: "Summary by iinventedlight (AI-assisted). Sources: Vue.js docs, Single-File Components, CC BY 4.0, text only (vuejs/docs); Vue.js core, compiler-sfc parse, MIT (vuejs/core). Notices: Vue.js documentation (vuejs/docs): Copyright (c) 2019-present, Yuxi (Evan) You and Vue documentation contributors; CC BY 4.0, text only (https://raw.githubusercontent.com/vuejs/docs/main/LICENSE). Vue.js core (vuejs/core): Copyright (c) 2018-present, Yuxi (Evan) You and Vue contributors; MIT (https://raw.githubusercontent.com/vuejs/core/main/LICENSE)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-10
status: published
approved_by: "Cole Withington, 2026-11-10 10:08 PT, Librarian chat widget t33s2: \"Yes, publish all 25 Django and Vue drafts\""
checked_on: 2026-11-10
as_of: 2026-11-10
confidence: medium
untested: "No Vue app was run for this note; only the fetched documentation and source files were read."
category: coding-references
topic_area: "code-web: Vue single-file components"
tags: [vue, sfc, compiler-sfc, components]
client: Librarian
sources:
  - id: S1
    title: "Single-File Components"
    publisher: Vue.js docs
    url: https://vuejs.org/guide/scaling-up/sfc.html
    accessed: 2026-11-10
    license: "CC BY 4.0"
  - id: S2
    title: "compiler-sfc parse"
    publisher: Vue.js core source
    url: https://github.com/vuejs/core/blob/main/packages/compiler-sfc/src/parse.ts
    accessed: 2026-11-10
    license: "MIT"
---
# Vue single-file components colocate template, script, and style

**Answer:** A Vue single-file component (SFC, a `*.vue` file) encapsulates the template, logic, and styling of a component in one file. The `<template>`, `<script>`, and `<style>` blocks colocate the view, logic, and styling. SFCs need a build step.

## Parsed form

`parse()` takes `source` and `options` and returns `SFCParseResult`. If parseCache already has sourceKey, parse returns that result. `SFCDescriptor` holds `filename`, `source`, `template`, `script`, `scriptSetup`, `styles`, and `customBlocks`. It also records whether the SFC uses the `:slotted()` modifier, used as a compiler optimization hint.

## See also

- [vue-template-syntax](https://iinventedlight.com/library/notes/vue-template-syntax/)
- [vue-composables](https://iinventedlight.com/library/notes/vue-composables/)

## Claims

- id: C1
  claim: An SFC encapsulates a component's template, logic, and styling.
  source: S1
  evidence: "allows us to encapsulate the template, logic, **and** styling"

- id: C2
  claim: template, script, and style blocks colocate those parts in one file.
  source: S1
  evidence: "The `<template>`, `<script>`, and `<style>` blocks encapsulate and colocate"

- id: C3
  claim: compiler-sfc parse() turns SFC source into a descriptor.
  source: S2
  evidence: "export function parse("

- id: C4
  claim: SFCDescriptor is the parsed form of an SFC.
  source: S2
  evidence: "export interface SFCDescriptor {"

## Sources

- [S1] Single-File Components. Vue.js docs. https://vuejs.org/guide/scaling-up/sfc.html . License: CC BY 4.0. Accessed 2026-11-10.

- [S2] compiler-sfc parse. Vue.js core source. https://github.com/vuejs/core/blob/main/packages/compiler-sfc/src/parse.ts . License: MIT. Accessed 2026-11-10.


License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources and notices: Vue.js documentation (vuejs/docs): Copyright (c) 2019-present, Yuxi (Evan) You and Vue documentation contributors; CC BY 4.0, text only (https://raw.githubusercontent.com/vuejs/docs/main/LICENSE). Vue.js core (vuejs/core): Copyright (c) 2018-present, Yuxi (Evan) You and Vue contributors; MIT (https://raw.githubusercontent.com/vuejs/core/main/LICENSE). Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
