Skip to content

Preview & Public Assets ​

The Filament panel theme styles the editor chrome. The iframe preview and public template output are separate HTML documents, so they also need CSS. FilamentCraft uses a three-tier asset model.

Tier 0 — package fallback (default) ​

php artisan filamentcraft:install copies the package's compiled section bundle to public/css/.... Built-in sections render correctly out of the box, even before the host has a custom front-end build.

Tier 1 — mirror the admin panel into the iframe ​

If your Filament panel theme also contains your site/section utilities, copy those <link> and <style> tags into the iframe at runtime:

php
$plugin = FilamentCraftPlugin::make()
    ->mirrorEditorStyles();

This is useful while editing because the iframe inherits the same compiled theme as the panel. It only affects authenticated preview rendering; public pages still need their own stylesheet.

Tier 2 — register the host site's Vite build ​

Production hosts should register the CSS/JS that visitors will receive:

php
$plugin = FilamentCraftPlugin::make()
    ->viteBuild('build', [
        'resources/css/site.css',
        'resources/js/site.ts',
    ]);

viteBuild() takes the build directory and finds the manifest inside it, handling both layouts: Vite 5 and Laravel 11+ write build/.vite/manifest.json, while older builds wrote build/manifest.json.

Or for theme-style builds under a sub-directory:

php
$plugin = FilamentCraftPlugin::make()
    ->viteBuild('themes/shop/debut/editor');

->viteManifest(public_path('build/.vite/manifest.json'), [...]) does the same thing when you want to name the manifest file explicitly. Point it at a path that doesn't exist and it silently registers nothing — which is why viteBuild() is the safer default.

Pass the configured $plugin to $panel->plugin($plugin). You can also register URLs directly with ->stylesheet('https://…/theme.css') / ->script('…/site.js') or via config('filamentcraft.assets.extra_styles') / extra_scripts.

Disabling the fallback ​

If your site build fully owns the section styling, disable the package fallback:

php
'assets' => [
    'site_css_enabled' => false,
],

White-label storefront ​

By default the live storefront's markup and bundle carry the package's names: fc- classes and data attributes, --fc- CSS variables, the <fc-island> element, filamentcraft: browser events, and site.css / site.js under /css/filamentcraft/ and /js/filamentcraft/. An agency shipping the builder under its own brand can rename all of that:

php
// config/filamentcraft.php
'storefront' => [
    'prefix' => env('FILAMENTCRAFT_STOREFRONT_PREFIX', 'fc'),   // e.g. 'sew'
    'namespace' => env('FILAMENTCRAFT_STOREFRONT_NAMESPACE'),   // null: 'filamentcraft' for 'fc', else the prefix
    'assets_path' => env('FILAMENTCRAFT_STOREFRONT_ASSETS_PATH'), // null: Filament's path for 'fc', else 'assets/{namespace}'
],

Then write the renamed bundle, and do it on every deploy (filamentcraft:upgrade runs it for you):

bash
php artisan filamentcraft:storefront-assets

With prefix set to sew, the live storefront serves /assets/sew/site.css and /assets/sew/site.js, and every page uses sew- classes, data-sew-* attributes, --sew- variables, <sew-island>, sew: events, /sew/cart/* cart URLs and sew-section.* Livewire aliases. Setting only assets_path keeps the fc names and just moves the two files.

How it works:

  • The views, your saved content and your exports keep fc. The renaming happens on the way out: the finished storefront page is rewritten, and so is the HTML of storefront Livewire components (LivewireSection subclasses and components using RendersInSiteShell) on every update.
  • Only class, id, for, ARIA reference, style, fragment-link, data-fc-* and Alpine attributes, <style> blocks and inline scripts change. Text, links, image URLs, form values, island props and Livewire's own state are never touched, so a product called "fc-barcelona" stays as it is.
  • The editor canvas and every preview route keep fc and the stock bundle.
  • Until both files exist, the storefront falls back to the stock names, so a deploy that skipped the command is still styled. filamentcraft:doctor fails when the files are missing or out of date (for example after a package update or a prefix change).
  • The rewrite adds about 5 ms to a 200 KB page and runs only when a prefix or namespace is set.

What stays:

  • Your own stylesheets and scripts are not rewritten. Rules that target .fc-* in a host theme, extra_styles or a Vite build need the new prefix.
  • Host Livewire components that don't use RendersInSiteShell re-render with fc- markup on update.
  • Island bundles keep pushing to window.FilamentCraftIslands, so one build works in the editor and on the storefront.
  • The licence watermark and the bundled preset images (/images/filamentcraft/…) keep their names.
  • Changing the prefix renames the saved colour-scheme key, so visitors' dark-mode choice resets once, and open pages need a reload before their next Livewire action.