Playground
Pick a model and its options; the code underneath is what you'd paste into your page.
Quick start
From a CDN
Add the script once, then use the element anywhere on the page.
<script type="module" src="https://cdn.jsdelivr.net/npm/blueprintspace@{v}/index.js"></script>
<blueprint-model model="gameboy" theme="amber" render="photo"></blueprint-model>From npm
npm install blueprintspace
import "blueprintspace"; // registers <blueprint-model>
import { models, thumbnail, BlueprintModel } from "blueprintspace";The models load from the jsDelivr CDN by default, matching the installed version, so nothing else needs copying. To serve them yourself, see self-hosting.
Frameworks
It's a standard custom element, so it works in any framework, or none.
React
import "blueprintspace";
import { useRef } from "react";
export function Hero() {
const ref = useRef(null);
return (
<>
<blueprint-model ref={ref} model="ps5" render="shaded" autorotate="15" style={{ width: "100%" }} />
<button onClick={() => ref.current.explode()}>Take it apart</button>
</>
);
}React 19 sets the element's properties directly. In React 18, give boolean options as strings (animation="true", xray="false") or set them through the ref (ref.current.animation = true).
Vue
<script setup> import "blueprintspace"; </script> <template> <blueprint-model model="v8" render="photo" :animation="true" :transparent="true" /> </template>
Tell Vue it's a custom element: compilerOptions.isCustomElement = tag => tag === "blueprint-model" in the Vue plugin's options.
Svelte
<script>
import "blueprintspace";
let el;
</script>
<blueprint-model bind:this={el} model="walkman" theme="navy" render="shaded" />
<button on:click={() => (el.exploded = !el.exploded)}>Explode</button>Attributes and properties
A model opens at a 45° view from its right side and holds it: people can zoom in and take it apart, but not turn it. Change the view with angle and elevation, or set locked="false" to let them turn it.
Every option is both an HTML attribute and a JavaScript property on the element. Boolean attributes are on when present (or "true") and off with "false". All of them change live except model, base and motion, which reload the model.
| Attribute / property | Values | Default | What it does |
|---|---|---|---|
model | a model id | — | Which model to show. See the list. |
theme | dark light amber navy lime, each with :inv | dark | The colours. :inv swaps background and lines. In the Photo render it sets the backdrop. |
render | lines shaded photo | lines | Line drawing, flat-shaded, or a photoshoot-style render with materials, textures and shadows. |
animation | boolean | off | Plays the model's own animation: a screen, a game, an LED pattern. Models without one ignore it. |
transparent | boolean | off | Shows your page behind the model, in every render style. |
xray | boolean | on | Hidden edges faintly visible through the parts. |
exploded | true false, or absent | hover | true takes it apart, false holds it assembled; without the attribute it comes apart while hovered. |
labels | boolean | off | Callout labels on the parts. |
controls | boolean | off | The model page's own buttons, title and hints. |
angle | degrees | 45 | The view's angle round the model, from the front towards its right side: 0 straight on, 90 the right side, -45 from the left. |
elevation | degrees | the model's own | How high the view is, above the model. |
locked | boolean | on | Holds the view at its angle so the pointer can't turn it; zoom and taking it apart still work. locked="false" lets people turn it. |
autorotate | boolean, or degrees a second | off | A slow turn: autorotate at 12°/s, or autorotate="30". It turns even while locked. |
interactive | boolean | on | Turn, zoom and take it apart with the pointer. Off makes it a still picture that ignores the pointer. |
motion | boolean | on | Moving parts (fans, reels, cranks) and camera easing. Off keeps everything still. |
base | a URL | the CDN | Where models/ and thumbs/ are served from. |
<blueprint-model model="playdate" render="photo" theme="amber" animation transparent xray="false" autorotate="20"></blueprint-model>
const el = document.querySelector("blueprint-model");
el.animation = true; // start its animation
el.transparent = true; // let the page show through
el.xray = false; // no hidden edges
el.exploded = true; // take it apart (false: together, null: on hover)
el.autorotate = 20; // degrees a second (0 stops)
el.interactive = false; // a still picture
el.angle = 90; // see it from the right side
el.locked = false; // let people turn it
el.theme = "navy:inv";
el.render = "shaded";Methods and events
| Method | What it does |
|---|---|
explode() | Takes it apart, or puts it back together. |
toggleAnimation() | Starts or stops its animation. |
tour() | Plays the "how it works" tour. |
reset() | Back to the starting view. |
setTheme(t), setRender(r) | The same as setting theme or render. |
| Event | When |
|---|---|
ready | The model has loaded and will take commands. event.detail holds { model, title }. |
el.addEventListener("ready", e => console.log("loaded", e.detail.title));
el.info; // { id, label, kind, category, tags }
BlueprintModel.models; // every model in the packageSizing
The element behaves like an image: it fills the width it's given at a 4:3 ratio. Give it a height, or an aspect-ratio, to change that. It's an ordinary block element, so CSS layout, borders, rounded corners and shadows all apply.
blueprint-model { width: 100%; aspect-ratio: 16 / 9; border-radius: 16px; overflow: hidden; }
blueprint-model::part(frame) { /* the iframe inside, if you need it */ }Each model runs in its own sandboxed iframe, so its scripts and styles never touch your page and yours never touch it.
Self-hosting
By default the models load from jsDelivr. To serve them from your own domain, copy the package's models/ and thumbs/ folders into your public folder, then point the element at them, once for every element or on one.
cp -r node_modules/blueprintspace/models node_modules/blueprintspace/thumbs public/blueprintspace/
import { BlueprintModel } from "blueprintspace";
BlueprintModel.base = "/blueprintspace/"; // the folder holding models/ and thumbs/<blueprint-model base="/blueprintspace/" model="v8"></blueprint-model>
The model pages load three.js from cdnjs and their fonts from Google Fonts.
Thumbnails
Every model also comes as a still line drawing, white on transparent. thumbnail(id) gives its URL. Use it as an <img>, or as a CSS mask to colour it with any colour.
import { thumbnail } from "blueprintspace";
img.src = thumbnail("gameboy");.icon {
background: currentColor;
mask: url(https://cdn.jsdelivr.net/npm/blueprintspace@{v}/thumbs/v8.webp) center / contain no-repeat;
}Models
Click one to load it into the playground. Its model id is under its name.