solid-sfc documentation
solid-sfc compiles .solid single-file components for SolidJS 2.0. A .solid file holds one component: a script, scoped styles and markup.
<script>
const { initial = 0 } = $props<{ initial?: number }>();
let count = $signal(initial);
</script>
<style>
button {
font-weight: ${count > 9 ? 'bold' : 'normal'};
}
</style>
<button onClick=(() => count++)>
Clicked {count} times
</button>
#if (count > 9) {
<p>That's a lot of clicks.</p>
}
#Guides
- Getting started: install the packages and write a first component.
- Components: the parts of a
.solidfile, props, generics and module code. - Markup: the JSX syntax that
.solidfiles use. - Control flow:
#if,#forand the other blocks. - Reactivity:
$signal,$memo,$effectand the other compile-time functions. - Styles: scoped styles and reactive CSS values.
- Tooling: type checking, editors, bundler plugins and the compiler API.
- Migrating from 0.x: moving from
babel-plugin-solid-sfc.