Theme Style Sheet (TSS)
Learn how to use TSS files for management purposes.
Read time 3 minutesLast updated 22 days ago
Theme Style Sheet (TSS) files are regular USS files. UI Toolkit treats TSS as a distinct asset type and uses it for management purposes.
Regular USS syntax and format apply to TSS files, but usually, a theme file contains references to other USS files through the rule.
@importCreate a TSS
You can create different TSS files for different themes and switch between them at runtime. Typically, you should use USS for styles. Consider TSS when you customize the look and feel for different platforms or devices, or when you use different fonts for different languages if your games or applications support multiple languages.
To create a new TSS:
-
Create one or more USS files with your custom styles.
-
Do one of the following:
- Select Assets > Create > UI Toolkit > TSS Theme File to create an empty theme file and import the default theme.
- Select Assets > Create > UI Toolkit > Default Runtime Theme File to create a copy of the default runtime theme file. You can rename the file if you want.
-
Import your style USS files to your theme.
Preview a TSS
Your custom theme also appears in the theme list of the in UI Builder. To preview your theme, select it from the Viewport.
Viewport
?
Apply a TSS
You can reference a TSS in UXML or C# the same way as you do with USS.
You can also set a TSS as the default theme for a Panel Setting asset. If you have more than one Panel Setting, each one can use a different TSS file.
Import a theme
You can use the TSS asset's Inspector window or the rule to import a theme.
@importImport a theme with the Inspector window
- Select the TSS asset.
- Go to the Inspector window > Inherited Themes.
- Select +. This adds a new reference field.
- Select the list icon in the reference field. A dropdown list displays with all the style sheets in your project.
- Select the style sheet to use.
- Select Apply.
Import the default theme with the @import
rule
@importTo import the default Unity runtime theme, you must use the following syntax:
@import url("unity-theme://default");
Import other themes with the @import
rule
@importTo import a theme other than the default theme, or a USS file, use the following syntax:
@import url("<path-to-file>/<file-name-with-extension>");
You can use a relative or an absolute path:
- Absolute paths start from the project's folder and begin with a
Assetsor/. For example,project://database/or/Assets/myFolder/myFile.uss.project://database/Assets/myFolder/myFile.uss - Relative paths start from the current file and exclude the . For example,
/.../myFolder/myFile.uss