Skip to content

Installing Themes ​

Introduction ​

Installing a theme takes three steps: require the package, build it if it is a Vue theme, and activate it. A site created from a skeleton has done all three at installation for the themes it kept — unless it was told --no-build or had no npm: then run npm install && npm run build, and activate the theme as in step 3. These are the steps for a theme added later:

bash
composer require kitloom/journal-theme
npm install && npm run build       # every Vue and React theme of the site
php artisan site:theme Journal     # or Appearance → Themes
``` The site itself needs `kitloom/site` with its fallback route — see [Installation](/docs/installation).

## 1. Require the theme

A theme requires `kitloom/site` and, for a Vue theme, `kitloom/site-inertia`, so Composer installs them with it:

::: code-group

```bash [Vue theme]
composer require kitloom/portfolio-theme
# also installs kitloom/site-inertia and inertiajs/inertia-laravel
bash
composer require kitloom/blade-theme

:::

The theme's service provider is discovered by Laravel; nothing is added to your application. For the Themes screen, add the package for your panel:

bash
composer require kitloom/site-filament
bash
composer require kitloom/site-nova

A theme in a folder of your application ​

Every folder under themes/ is a theme of that name — themes/Studio is the theme Studio. A folder with resources/js/Templates is a Vue theme, any other a Blade theme. No package and no provider are needed; another folder is set in kitloom-site.theme.path. See Writing a Theme.

2. Build it (Vue themes) ​

A Blade theme has nothing to build — go on to step 3.

A Vue theme is built with Vite, each theme into its own directory, public/build-{Theme}. kitloom/site-inertia brings the Vite plugin that finds the theme in themes/ or vendor/. Which theme the config builds comes from the site, never from .env: a build names each theme it builds in KITLOOM_BUILD_THEME, and the dev server asks the site for its active one. The skeletons' vite.config.js:

js
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import vue from '@vitejs/plugin-vue';
import react from '@vitejs/plugin-react';
import kitloomTheme, { activeTheme, buildsWithVite, themeEntry } from './vendor/kitloom/site-inertia/vite/index.js';

export default defineConfig(({ command }) => {
    // `npm run build` names each theme it builds; `npm run dev` serves the one the site has active.
    const theme = process.env.KITLOOM_BUILD_THEME || activeTheme();

    // No theme, or a Blade one: nothing to build or serve.
    if (!buildsWithVite(theme)) {
        console.info('Vite has nothing to serve.');
        process.exit(0);
    }

    if (command === 'serve') {
        console.info(`Serving the ${theme} theme, the site's active one. After switching themes, start the dev server again.`);
    }

    return {
        plugins: [
            laravel({
                input: [themeEntry(theme)],
                buildDirectory: `build-${theme}`,
                refresh: true,
            }),
            ...kitloomTheme({ theme }),
            vue({
                template: {
                    transformAssetUrls: {
                        base: null,
                        includeAbsolute: false,
                    },
                },
            }),
            // A React theme's components; a Vue theme has none.
            react({ include: /\.[jt]sx$/ }),
        ],
        resolve: {
            preserveSymlinks: true,
        },
        server: {
            watch: {
                ignored: ['**/storage/framework/views/**'],
            },
        },
    };
});

kitloomTheme() returns three plugins, so it is spread into the list. preserveSymlinks matters when theme packages are symlinked into vendor/ from a Composer path repository; see Building Assets.

The theme's JavaScript is resolved from your application's node_modules. The bundled themes need these (the config above loads both the Vue and the React plugin):

bash
npm install -D vite@^7 laravel-vite-plugin@^2 @vitejs/plugin-vue@^6 @vitejs/plugin-react@^5
npm install vue@^3.5 @inertiajs/vue3@^3 axios

Some need more:

ThemeAlso needs
Saffron@glidejs/glide@^3.6
Atelierdate-fns@^4
Keystone, Waypointmaplibre-gl@6
Quire (React)react@^19 react-dom@^19 @inertiajs/react@^3

@inertiajs/vue3 and @inertiajs/react must be 3: the server side is inertiajs/inertia-laravel 3. A theme of your own may need more; the skeletons' package.json has all of the above.

build builds every theme, dev serves the active one:

json
{
    "scripts": {
        "dev": "vite",
        "build": "node vendor/kitloom/site-inertia/vite/build-themes.js",
        "build:themes": "npm run build"
    }
}
bash
npm run build                                   # every installed Vue and React theme, one after another
KITLOOM_BUILD_THEME=GameReviews npx vite build  # one theme, by hand
npm run dev                                     # the active theme, under the dev server

npm run build builds every Vue and React theme it finds, active or not, and takes no arguments (build:themes is the same, for the scripts that call it so). Each build writes its own manifest and the list of the theme's templates, so an administrator can switch between built themes without a rebuild — and the theme's SSR bundle into bootstrap/ssr, which php artisan inertia:start-ssr renders the pages from (Writing a Theme → Server-side rendering).

Deploying

Run npm run build in your deploy pipeline, so every installed theme is ready to be activated. A Vue theme that is not built cannot be activated: its card says Not built yet. A theme that is active but not built — a package updated, a build skipped — fails its pages with The Journal theme is not built: run npm install && npm run build.

3. Activate the theme ​

Open Appearance → Themes and click Activate on the theme's card. Activation runs the theme's migrations, then switches the site to it — see The Themes screen.

From the console — a deploy script, a site without an admin yet — site:theme does the same:

bash
php artisan site:theme Journal             # its migrations, then the switch
php artisan site:theme --none              # no theme: every page answers as JSON
php artisan site:theme                     # the installed themes, which is active, which is not built
php artisan site:theme --active            # the active theme's name, for a script
php artisan site:theme Journal --if-none   # a deploy: only while no theme was ever chosen

The switch is the kitloom_theme option (not WordPress's current_theme, which WordPress itself overwrites on a shared database) — the one place that says which theme is active. .env names none: APP_THEME stands in only while the option was never set, for a test's theme in phpunit.xml. A deploy that should bring a theme to a new server runs site:theme <Name> --if-none after its migrations: the first deploy activates it, and a switch made in the admin since stays.

Theme migrations

A theme's migrations run when it is activated on the Themes screen. After that, the active theme's migrations go with php artisan migrate: a deploy that brings a new one runs it with the site's own, and a new environment gets its tables when the theme is activated there (site:theme, the deploy's --if-none included). The migrations of themes that are not active wait for their activation.

Removing a theme ​

bash
composer remove kitloom/blade-theme

If the removed theme was active, the site has no theme until another is activated. Delete its build directory, public/build-{Theme}, too. Data the theme's migrations created stays in the database.

Running without a theme ​

The active theme's card has a Deactivate button. After a confirmation the site has no theme at all and every page answers with its data as JSON, for a headless front end. Activate on any card brings the rendered site back. See Headless & APIs.

kitloom — sites on Laravel, built for you and run with AI.
Contact · Services · License · Refunds · Privacy · Community · YouTube · [email protected]