Skip to content
This repository was archived by the owner on Aug 5, 2025. It is now read-only.
This repository was archived by the owner on Aug 5, 2025. It is now read-only.

Docs mentioning SFC do not demonstrate an SFC #333

@mikemaccana

Description

@mikemaccana

(moved from sveltejs/svelte#1601)

Current documentation

From https://svelte.technology/guide#understanding-svelte-components

A component is a reusable self-contained block of code that encapsulates markup, styles and behaviours that belong together.
Like Ractive and Vue, Svelte promotes the concept of single-file components: a component is just an .html file. Here's a simple example:

<h1>Hello {name}!</h1>

As only HTML is used in the .html file, this is either not a demonstration of, or a poor demonstration of the concept of including JS, HTML and CSS in a single file.

Additionally, since the file is called .html there is nothing to suggest there should be more inside the file than what is shown, ie, HTML.

Furthermore the component has data that is given to it later, on instatiation.

Suggestion

In the example below, I have avoided the use of obtuse language, tightened the copy and avoided the term 'SFC' as it does not serve a purpose - Svelte components are explained to be in a single file, we do not need a new acronym for this

Understanding Svelte components

Svelte applications are made from one or more components. In Svelte, like other frameworks, a component is a reusable self-contained block of code with HTML, CSS and JS in a single file.


<h1>Hello {name}!</h1>

<script>
	export default {
		data: function(){
			return {
				name: Joe
			}
		}
	}
</script>

<style>
    h1 {
        color: red;
    }
</style>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions