Create a code tile
Tilefolio is hackable: you can write your own HTML, CSS and JavaScript. A code tile shows your own little web page: one HTML file with its CSS and JavaScript. A moving drawing, a shader, a 3D object, a sound toy, or just a hand-made layout. Your visitors see an image, click it, and your page opens large and comes alive.

Who can create one
Code tiles are for every site, during the free trial too: the site's owner and its editors create them, change their code and delete them. They are created from the site, in edit mode (Edit on my site), where the editor has its live preview. A code tile can't be put up for sale.
Create the tile
- Open your site in edit mode, then click + Code tile (next to + Add a tile).
- In Start from a template, pick an example (see the templates), or write your code straight in the editor.
- The preview shows your code as it is, unsaved, and runs again when you stop typing. The code's errors are listed below it, with their line.
- Tick the libraries your code needs (see below).
- Choose the still (see below), a title, a date and a size.
- Click Create the tile: nothing is online before, and the tile is published right after.

To change the code later, select the tile on the site and click Edit the code: the same panel opens. The title and size are changed in the tile's toolbar, as for other tiles. You can also see the tile in the admin (Code tiles), but the site's editor is simpler: it has the preview and the templates.
Start from a template
Each template is one HTML file, short, commented in French and in English, with its CSS and JavaScript inside. It adapts to the tile's size. Picking a template fills the editor and ticks its libraries; if you already wrote code, you are asked to confirm before it is replaced.
- Free layout (HTML and CSS): no script. A small hand-made page, with scrolling text, colours and a title that changes hue.
- Generative shapes (p5.js): circles following a noise curve. A click in the tile changes the palette.
- Shader (p5.js): a "fragment shader", the small program that computes the colour of every point of the tile.
- Sound on click (Web Audio): a note at each click, higher at the top of the tile than at the bottom.
- Play a sound (audio): a click in the tile plays the sounds of your audio tiles, one after the other; another click stops them. The template starts with your site's first sounds.
- 3D object (three.js): a knot spinning, with a light. The mouse tilts it.
- My images (p5.js): your site's images floating in the tile. The template starts with the images of your site; to change them, see what the box can't do.
Change a number, a colour, a text, and watch the preview: it is the best way to learn.
The libraries
Two libraries are offered, ticked tile by tile; only the ticked ones are loaded.
- p5.js 1.11.13: for drawing, with
setup()anddraw(), as in its tutorials. - three.js 0.187.0: for 3D. It is written in a
<script type="module">withimport * as THREE from 'three', as in its documentation.
No other script address is accepted: you can't load a library from elsewhere. A library that fits in one file can, however, be pasted into your code (within the 200 KB).
The still
A code tile is always an image before the click: its cover, the one visitors see in the mosaic, search engines and sharing previews. Two ways to choose it:
- Capture takes the preview's image at that moment: handy for a p5.js drawing or a three.js scene. It only works for code that draws in a canvas and doesn't show an image of your library in it (the browser forbids it: it tells you).
- Upload an image: a screenshot, a photo. This is the way for the free layout and for the sound one.
Without a chosen image, Tilefolio makes one with the tile's title.
What your visitors see
The tile shows its still, like any tile, with the </> icon beside its title. As with the other tiles, a click opens its page over the site (/code/…, an address you can share): the code starts at once, as large as the screen allows, with the tile's text below. Nothing runs in the mosaic itself. Closing the page stops the code, which lets the computer or phone rest. The Full screen button, under the code, shows it on the whole screen (Esc or Exit full screen to leave): your code then gets the new size, as when a window is resized (windowResized in p5.js, the resize event; the templates already do it). On iPhones, whose browser doesn't allow it, there is no button.

Reporting, stopping
Under a running code tile, on its page, a Report this content link lets a visitor warn the Tilefolio team: they pick a reason (shocking or illegal content, scam, disrupts the page, infringes rights, other) and may add a few words. They are asked for no name and no address. The report shows in your Tilefolio support log, with its reason.
The Tilefolio team can then stop the tile, or all the site's code tiles: they show only their still, at once, and the stop is noted in that log, with the reason if the team gave one. In edit mode, the tile's toolbar says so, to the owner and the editors alike. You can't start it again yourself: write to support to know why, or once the code is fixed. A stop is of the display only: a stopped tile's code can still be changed (it stays stopped), and while all the site's code tiles are stopped you can still create, change and delete them; visitors see only their stills until the team starts them again.
Combinations and sharing
The tile's page tells your code two things, in the address of its box, after the #: page, the address of the tile's page on your site (for example https://picasol.fr/code/remix-pinkasol), and preset, when the page's address ends with ?preset=… (up to 200 letters, digits and . _ ~ -). Your code reads them with location.hash, and does what it likes with the preset: a combination, a level, a colour. So a visitor can keep a link to this state of your tile: …/code/remix-pinkasol?preset=d07.2-p01.3.
const hash = new URLSearchParams(location.hash.slice(1));
const page = hash.get("page"); // https://your-site/code/your-tile
const preset = hash.get("preset"); // null without one
// a link to keep: page + "?preset=" + yourPreset
Your code can also ask the page to open the visitor's mail app with a message to you (your site's address: its E-mail profile link, else the footer's contact if it is just an address). After a click in the tile:
parent.postMessage({ tf: "code-share", preset: "d07.2-p01.3",
title: "My combination", text: "Listen to this one!" }, "*");
The page writes the e-mail itself: the title (else the tile's), the text (500 characters at most), then the link to the tile's page with the preset. Nothing is sent: the visitor's mail app opens with a draft, they send it or not. The page answers your code with { tf: "code-share", ok: true } (false when your site has no address, or a second time within 3 seconds).
What the box can't do, and why
Your code doesn't run on your site, but in a "box": a separate page with an address of its own, in a closed frame. This is what lets Tilefolio let any artist write code without putting visitors, or your account, at risk. As a result:
- Almost no network. The code can't load a script, font or style sheet from another site, no analytics, no iframe, and
fetchonly reads the files of your library. Fonts are the ones on the visitor's computer, or embedded in the code. - Images from your site only. An image loads by its address, and only if it is in your library. To add one, right-click the image on your site, choose Copy image address and paste it in the code. An image from another site is refused, and the preview says so.
- No forms, no windows. A form can't send anything, and the code can't open a window, a link to the outside, a download or a dialog box (an e-mail to you, through the page: see sharing).
- No camera, microphone or location, and no cookies or storage: the box remembers nothing from one visit to the next.
- Sounds from anywhere, but read from your site only. A sound or a video plays from any https address with
<audio src="…">,<video>ornew Audio("…")(p5'screateAudiotoo). To read a sound withfetchand decode it with Web Audio (decodeAudioData, to analyse, cut or transform it), it must come from your library: add it to an audio tile of your site. The Play a sound template starts from your sounds. - No sound before a click. Browsers only play sound after a gesture from the visitor: they must click inside the tile (the click that opens its page doesn't count). The Sound on click and Play a sound templates show how.
The code can't exceed 200 KB either (the panel shows the size). That's a lot for text: a page, its styles and a drawing take only a few.
When it doesn't work
The code's errors are listed under the preview, with the line number when the browser gives it. Safari doesn't give the text of an error from the box, only that there is one: open the panel in Chrome or Firefox to read it. A "Blocked by the box" message means the code tries to do something the box forbids (see above).
A shader or a 3D scene needs the visitor's graphics chip: on a very old computer the tile may stay black. Try a lighter code.