Svelte uses capitalized names to identify components. If a component name starts with a lowercase letter, Svelte treats it as a regular HTML tag, which can cause errors or unexpected behavior.
Svelte components should be named using PascalCase starting with a capital letter. This helps with clarity and matches the component naming conventions.
import header from './Header.svelte'; <header />
What will be the rendered output in the browser?
import header from './Header.svelte'; <header />
Svelte treats lowercase tags as native HTML elements. So <header /> renders the HTML header element, not the imported component named 'header'.
import navbar from './Navbar.svelte'; <Navbar />
import navbar from './Navbar.svelte'; <Navbar />
JavaScript is case-sensitive. Importing as 'navbar' but using <Navbar /> causes a ReferenceError because 'Navbar' is not defined.
<script>
export let label = 'Click';
</script>
<button>{label}</button>And this usage in another component:
import mybutton from './MyButton.svelte'; <mybutton label="Press" />
What will be displayed on the page?
import mybutton from './MyButton.svelte'; <mybutton label="Press" />
Svelte treats lowercase tags as native HTML elements. Since <mybutton /> is lowercase, it is not recognized as the imported component and renders nothing or an unknown tag.