Building a site
The canvas shows your CSS
How the visual editor shows blocks in the website's own stylesheet.
The visual editor renders your blocks in the website's own stylesheet, so they look on the canvas exactly as they do on the site. There's nothing to set up: Aurora finds resources/css/app.css through Vite (the built file, or the dev server while npm run dev runs) and scopes it to the canvas with CSS @scope, so it can't touch the admin around it.
How your CSS is scoped
- The stylesheet is wrapped in
@scope (.fpb-canvas)(Aurora\Support\CanvasStyles). :root,html,bodyand.fpb-canvasare all the canvas: whatever your stylesheet says of the page itself, it says of the canvas.- Combinators are kept, so rules match as they do on the website:
body > .xmatches only an.xstraight on the canvas, not one inside a block v1.2.0.
Styling blocks on the canvas
On the canvas, each block is wrapped in .fpb-block, with its type in data-type and its own markup in .fpb-block-body. Target them with :scope > .fpb-block (a block straight on the page), .fpb-block[data-type="hero"] and .fpb-block-body. On the website, :scope at the top level is :root, so these rules do nothing there. This website gives a block dropped straight onto the page its gutters this way:
/* On the website… */
.fpb-page > .fpb-el:not([data-block='band'], [data-block='hero']),
/* …and on the canvas. */
:scope > .fpb-block:not([data-type='band'], [data-type='hero']) > .fpb-block-body {
max-width: 72rem;
margin-inline: auto;
}
Colours v1.2.0
The page's background and text colour, set on html or body (in a CSS layer or not), become the canvas's --fpb-canvas-bg and --fpb-canvas-fg. To choose them yourself, set those two on html:
html {
--fpb-canvas-bg: var(--color-zinc-50);
--fpb-canvas-fg: var(--color-zinc-700);
}
Widths v1.2.0
Width breakpoints (@media (width >= 48rem), min-width, max-width) are asked of the canvas, as container queries (@container fpb-canvas), so the editor's Tablet and Mobile widths show the site's tablet and mobile layouts. vw is the canvas's width (cqw). Other media queries, such as print, colour scheme and hover, stay as they are.
Style the page in CSS, not with classes on <body>
The canvas has no <body> of the site's, so put the page's font, colours and background in the stylesheet:
@layer base {
body {
@apply bg-white font-body text-zinc-600;
}
}
Fonts
Fonts in the stylesheet (@font-face, or an @import url(…) at the top) come along, and so do fonts loaded with Vite's font loading. Fonts linked from your layout's <head> don't, so load them in the stylesheet too, or the canvas shows them in a fallback font.
@import url('https://fonts.bunny.net/css?family=inter:400,500,600,700');
@import 'tailwindcss';
Another entry
Set AURORA_WEBSITE_CSS (aurora.website_css) to another Vite entry, or leave it empty to show blocks without the site's styles.