Skip to Content
Themes

How themes work

Where a theme lives, how Flute picks one for a request, how templates and styles are resolved and what a theme hands to Studio.

By the end of this page you will know where Flute takes the template and styles for every page from, what a theme can override and where the line between a theme and a module runs. A step-by-step build is in Your own theme, and every theme.json key is listed in Theme parameters.

Where themes live

A theme is a folder app/Themes/<key>/ with a theme.json file. The theme key is the folder name: the database stores the theme under it, asset paths include it and the Studio preview selects by it. A folder without theme.json is not a theme.

The engine repository holds one theme, standard. It is the base and the fallback: if the active theme breaks or disappears, the site switches to it. The examples below also use separate game themes you may not have: gamekit extends standard and adds a console on the ~ key, number keys for the menu, interface sounds and a dark-only scheme, and arena extends gamekit and mostly changes tokens and styles.

How Flute picks a theme

Flute\Core\Theme\ThemeManager (app/Core/Theme/ThemeManager.php) makes the choice. On first use it reads the theme.json of every folder in app/Themes and reconciles them with the themes table in the database. A new folder gets a row with the notinstalled status, and only standard starts as active. The current theme is the first row whose status is active.

MethodWhat it does
getCurrentTheme()key of the theme this request renders with. For a Studio editor with ?studio_theme=<key> in the address it is the previewed theme, not the active one
setTheme($key)switches the theme for the current process only and dispatches ThemeChangedEvent. Nothing is written to the database
loadThemeJson($key)reads and decodes one theme's theme.json. Broken JSON goes to the templates log and returns null
getThemeData($key)the same, from memory when the file has been read already
scheme()light or dark when the theme or a parent paints only one scheme, otherwise null. Templates get the same from theme_scheme()

Flute\Core\Theme\ThemeActions turns a theme on for visitors: installTheme() and activateTheme() set its row to active and the previous theme to disabled, clear caches and restart workers. For ten minutes after the switch ThemeHealth watches the theme and brings the previous one back after repeated errors (Switch back).

All theme.json data is cached for an hour. The site sees a new folder or an edited manifest after php flute cache:clear or the "Refresh Themes List" button in AdminExtensionsThemes.

Do not write a theme name in code

Modules and the core never check which theme is on and never build paths like app/Themes/standard. Take the current theme from ThemeManager::getCurrentTheme() and a theme asset path from tt('assets/...').

Inheritance

A theme with "extends": "standard" gets everything it lacks: templates, styles, components, Studio settings, presets and translations. The chain can be longer (arena → gamekit → standard). For template lookup standard always comes last, even when the theme does not name it.

That is why your own theme nearly always extends standard and keeps only what it changed. A theme that copied the whole views/ tree stops getting new core templates: after a Flute update new pages look dated or break.

Folder layout

This is a child theme, using arena as the example. Items in brackets exist only in standard.

app/Themes/arena/
├── theme.json                      manifest, required
├── preview.webp                    picture for the admin card, 16:10
├── assets/
│   ├── sass/app.scss               main stylesheet
│   ├── sass/theme/_tokens.scss     own tokens and style partials
│   ├── scripts/                    plain JS, no build step
│   └── images/
├── views/
│   ├── layouts/                    page frames: app, error, oauth, header, footer
│   ├── pages/                      pages: home, login, profile/…
│   ├── components/                 x-* components, registered automatically
│   ├── partials/                   @include fragments such as theme-head
│   └── modules/<namespace>/        overrides of module templates
├── lang/ru.json, en.json           theme texts
├── presets/skin/*.json             ready-made palettes for the Style tab
├── (presets/blocks/<type>/*.json)  ready-made block looks
├── (zones/<zone>.json)             starting content of header and footer zones
└── (skeleton.html)                 frame template for "Site template" in Studio

Templates

Templates are Blade. When code renders view('flute::pages.home'), Flute looks for pages/home.blade.php in order: folders that modules added with template()->overrideViews(), then the current theme, its parents and standard. The first file found wins. To replace a core template, put a file with the same relative path under your theme's views/.

A module template is overridden the same way inside views/modules/<namespace>/. For shop::index that is views/modules/shop/index.blade.php, for the <x-shop::card> component it is views/modules/shop/components/card.blade.php. The sections, admin* and studio* namespaces cannot be overridden this way, and theme overrides do not apply in the admin panel.

When you only need to add something to a parent template, do not copy it. Include the original by its path from app/ and add your part:

app/Themes/nightfall/views/layouts/footer.blade.php
@include('Themes.standard.views.layouts.footer')
<p class="nightfall-note">{{ __('theme.footer_note') }}</p>

Files under views/components/** become <x-…> tags on their own: header/actions.blade.php turns into <x-header.actions>. The component map and resolved templates are cached, so a new file may show up only after php flute cache:clear.

Styles

Styles are SCSS compiled on the server by scssphp 2, no Node.js needed. The standard frame loads the theme's main file with @at(tt('assets/sass/app.scss')), and tt() prefixes the current theme folder and searches the inheritance chain. The compiled CSS lands in public/assets/css/cache/.

A child theme starts app.scss by importing its parent by path, then adds its own partials:

app/Themes/arena/assets/sass/app.scss
@import 'Themes/gamekit/assets/sass/app';

@import 'theme/tokens';
@import 'theme/chrome';

scssphp supports @import only: @use and math.div do not work. Styles for particular pages go in scoped_styles and reach only the pages where the listed template renders. In development mode editing any partial rebuilds the CSS on reload; on a live site clear the style cache with php flute cache:clear. php flute template:clear removes compiled Blade only and does not rebuild styles.

The theme sets colours, fonts and radii as CSS variables in :root[data-theme], and the owner changes them on the Studio Style tab. The owner's values come in a separate file after the theme styles and override them. The details are in Theme parameters.

Scripts, images, fonts

Scripts in assets/scripts/ are served as they are: plain JavaScript without a build step, npm imports, TypeScript or JSX. Every <script> in a template needs @nonce, and handlers such as onclick= are forbidden: once the CSP policy is enforced in the security settings, the browser will not run them. Images are included with @at('Themes/<key>/assets/images/x.svg'); @at() on a missing file silently returns an empty string.

A theme names its fonts in fonts of its theme.json and keeps the files in assets/fonts/: the site serves them itself, see Theme parameters. Other <head> tags go in views/partials/theme-head.blade.php, which the standard frames include on their own. The theme check refuses stylesheets and fonts from other sites.

Translations

Theme texts live in lang/<locale>.json as a flat {"key": "text"} object and are printed with __('theme.key'). The file is read along the inheritance chain, the child's key wins. A locale without its own file falls back to English, and a file over 64 KB is not read.

app/Themes/arena/lang/en.json
{
    "play": "Play",
    "skin_label": "Arena"
}

A theme is presentation only

A theme is responsible for looks. It has no business logic, no database writes, no routes and no calls to outside services. A controller or a module brings the data to the template, the theme displays it. If a theme needs something the data does not have, that is a job for a module.

Part of this rule is enforced in code. Before a theme is turned on from Studio, Flute runs Theme\Authoring\ThemeCheck: the manifest, the ThemeLint safety check, compiling every SCSS and Blade file, and rendering the home page, /privacy, a 404 page and the check_paths entries. A theme with an error will not be turned on from Studio. The "Install" and "Apply" buttons in the admin panel do not run this check.

Themes and Studio

A theme declares what the owner can set in Studio, and Studio builds its panels from that.

WhatWhere in the themeWhere in Studio
frame settings: menu on top or on the side, width, sticky headerframe in theme.json"Style" → "Header and menu"
zones for blocks: header, footer, sidebarzones in theme.json and zones/*.jsonheader and footer blocks
ready-made palettespresets/skin/*.json"Style" → "Ready-made themes"
ready-made block lookspresets/blocks/<type>/*.jsonblock settings
theme fontsfonts in theme.jsonfonts, group "From the theme"
decor packs: frames, textures, corner shapesdecor/<pack>/decor.jsonchecked with php flute studio:check-pack
frame templateskeleton in theme.json and skeleton.html"Whole site" → "For developers" → "Site template"

Studio registries (PresetRegistry, FontRegistry and DecorRegistry in app/Core/Modules/Studio) take nothing through register(): they read these folders of the current theme and its extends parents themselves. Each key in detail: Theme parameters.

More

On this page