Design to code (HTML and CSS)
This page helps you turn a screen or a layer into web code. The code is HTML and CSS.
How to copy the code of a layer
- Select a screen or a layer.
- In the Properties panel, open the Export tab. Find the Code section.
- Pick what to see: HTML, CSS or Page (HTML with CSS). A layer with click or scroll motion also has a JavaScript view.
- Click Copy HTML or Copy CSS.
The code includes every child layer inside it.
How to save a web page
- Select a screen.
- In the Code section of the Export tab, click Export page.
- Choose where to save it.
Brsh saves the page. Images go into an assets folder beside the page.
How to save a whole site
- Select one screen on a page that has more than one screen.
- In the Code section of the Export tab, click Export site.
Each screen becomes its own web page. They link to each other as in your prototype. They share one style file. The screen you selected is index.html.
Two switches
- Use variables. On: colour and number variables become CSS custom properties, such as
var(--ink). Other themes, such as dark mode, get their own block of values. Off: Brsh writes the plain values. - Responsive. On: a screen fills the browser window. Pinned layers follow their pins. Off: the page keeps the sizes of your design.
What carries over
- Layout. Auto layout becomes flexbox or grid. Gap, padding, wrap and alignment stay. Fixed, hug and fill sizes stay. Pins stay.
- Style. Text styles, fills, gradients, strokes, corner radii, shadows, blurs and blend modes.
- Shapes. Paths, icons, arcs and rings become inline SVG.
- Components. All instances of one component share one CSS class. The class takes the layer name.
- Links. A click link to a screen becomes a web link.
- Motion. Motion becomes CSS animation. It covers load, hover, click and scroll. A click or scroll motion also adds a JavaScript view. Screen changes play with View Transitions. If the person's system has Reduce motion on, only fades play.
- Images and fonts. Local images go in the assets folder as WebP. The page loads the same fonts that Brsh uses.
- Things CSS cannot draw. Shaders, mesh gradients, booleans and text on a path become images.
How to check the result
Brsh has a script, scripts/export-check.mjs. It compares the HTML of each screen with Brsh's own drawing. It writes a report. The report shows how many pixels differ, a map of the differences and the layers out of place.
Limits
- Code export is HTML and CSS only.
- A browser draws text in its own way. An exported page differs from the canvas in a few per cent of pixels.
How to send a design to your own app code
If you connected a code folder, an agent can write the code for you.
- Select a screen or a component.
- Click the code icon (code brackets) in the Properties header. Its tooltip says "Mark ready for code".
- In the chat, type
/design-to-code. - The agent asks "Change your code?". Click Allow only if you agree. Skip keeps your code as it is.
The agent writes the code in your connected code folder. It commits only the files it wrote, on your current branch. It does not push.
The icon then changes:
- Code brackets: ready.
- A check: the screen is in code.
- A changed-file icon: the design changed after that. Click the icon again to send the change.
The same icon shows on the canvas label and in the Screens tab. Click the icon again to take the mark off.
For AI tools that connect to Brsh, the command is /brsh:design-to-code. See design-to-code.md for how the agent works.