Skip to content

Slint Compiler

slint-compiler translates a .slint file into one Rust source file for the slint-sc runtime. To run it from a Cargo build script, see Compiling .slint Files.

Terminal window
slint-compiler --slint-sc [--coverage] [--depfile <dependency file>] [-o <output file>] <file>
bash

Always pass --slint-sc. Without it, slint-compiler generates code for the full Slint runtime, which isn’t part of Slint SC.

OptionEffect
<file>The .slint file to compile. Use - to read it from standard input.
--slint-scCompile the Slint SC subset and generate code for the slint-sc crate.
-o <output file>Write the generated Rust code to this file. The default, -, writes it to standard output.
--coverageWrite the coverage map next to the output file. Requires -o.
--depfile <dependency file>Write the files the output depends on, in the Make format.
-V, --versionPrint the version and exit.
-h, --helpPrint the options and exit.

Imports and @image-url paths resolve relative to the file that contains them. For a file read from standard input, they resolve relative to the current directory. There are no include or library paths.

The compiler embeds every image the file uses into the generated code. The application needs no files at run time.

The compiler rewrites the output file only when its content changes. An unchanged output keeps its modification time, so build systems don’t rebuild what depends on it.

The generated code only compiles with the slint-sc crate of the same release (sls.gen.version). --version prints the release of the compiler.

With --coverage, the compiler also writes the map of the coverage points of the .slint source. It has the name of the output file, with the extension .slintcov: -o indicator.rs writes indicator.slintcov.

The generated code is the same with and without --coverage. To turn the map into a coverage report, see Coverage of Slint Code.

With --depfile, the compiler writes one line in the format of gcc -M:

indicator.rs: ui/indicator.slint /path/to/ui/lamp.slint /path/to/ui/lamp.png
make

It lists the output file, then the input file as given on the command line. Then it lists every imported .slint file and every embedded image, with absolute paths.

slint-compiler accepts more options than the ones above, for the full Slint runtime. With --slint-sc, it rejects each of them with an error:

  • -f, --format
  • --style
  • -I, -L
  • --scale-factor
  • --embed-resources
  • --translation-domain
--slint-sc cannot be used together with -I
text

The compiler prints errors and warnings to standard error, each with the file, line, and column it’s about. An error names the construct at fault, for example one outside the Slint SC subset:

error: The builtin element 'Text' is not supported in Slint SC
text

The exit status is zero when the compilation succeeds, warnings or not. It’s non-zero on any error, and the compiler then leaves the output file untouched. Check the exit status, rather than the presence of the output file, to tell whether the compilation succeeded.


© 2026 SixtyFPS GmbH

Built from commit 9e95c298ad7251b85418c922c492cd327464b66c