Skip to content

File Structure

A .slint source file is a sequence of zero or more top-level items, separated only by whitespace and comments.[sls.file.source-file]

A source file that contains only whitespace and comments is well-formed and defines no components.[sls.file.source-file.empty]

A top-level item is a component definition.[sls.file.top-level-item]

A component definition has one of the following two forms:[sls.file.component.definition-forms]

component Name { /* component body */ }
component Name inherits Base { /* component body */ }
slint

The identifier following the component keyword is the name of the component.[sls.file.component.name]

The first form defines a component with no explicit base; the second form defines a component that inherits from the element type named by Base. The identifier Base shall resolve to a built-in element or to a component previously defined.[sls.file.component.inherits]

The braces { and } delimit the component body.[sls.file.component.body-braces]

A component body is a sequence of zero or more element instantiations, separated only by whitespace and comments.[sls.file.component.body]

A component body that contains no element instantiations is well-formed.[sls.file.component.body.empty]

An element instantiation has the form:[sls.file.element.instantiation-form]

TypeName { /* element body */ }
slint

The identifier TypeName shall resolve to a built-in or user-defined component.[sls.file.element.instantiation-typename]

The braces delimit the element body. An element body is a sequence of zero or more nested element instantiations, separated only by whitespace and comments.[sls.file.element.body]

A nested element instantiation is a child of the element instantiation in whose body it appears. The child relationship forms a tree rooted at the elements that appear directly in a component body.[sls.file.element.tree]

The following is a complete, well-formed .slint source file:[sls.file.example.intro]

component Hello {
Rectangle {
Rectangle {
}
}
Rectangle {
}
}
slint

It defines one component, Hello, whose body contains two top-level Rectangle instantiations; the first of those has one nested Rectangle child.[sls.file.example.description]


© 2026 SixtyFPS GmbH