The template language
Built-in elements
Weft's elements, canvas shapes, scene objects, and the HTML attributes written.
A lowercase name is an element: an HTML element, or one of Weft's own. Inside a canvas2d or scene3d, names mean that surface's shapes and objects instead.
- HTML elements render as themselves. Any HTML tag works; the ones listed below are those the language server knows and describes.
- Weft's own elements are listed with the attributes they take. They include
heading,markdown, layout primitives such ascolumnandrow, and the drawing surfacescanvas2d,scene3d,shaderandparticles2d. - Shapes and objects belong inside a drawing surface. The README's graphics section shows them at work.
Every element on the HTML side also takes class, id, label, role, style, hidden, events and motion-*.
These tables are generated from the element documentation the language server uses for hovers and completions, so they always match what the editor says.
Weft's elements
Elements on the HTML side that Weft adds.
heading
A heading: h1–h6 by level.
| Attribute | Takes | Default | Does |
|---|---|---|---|
level | 1–6 | 1 | Which heading level. |
heading(level: 2) "Our services"markdown
Renders Markdown (headings, emphasis, links, images, lists, quotes, code). Text is never parsed as HTML.
| Attribute | Takes | Default | Does |
|---|---|---|---|
source | string | — | The Markdown. |
markdown(source: post.body)column
A flex column (a div).
Also written stack.
column(class: "gap-4") { … }row
A flex row with centred items (a div).
row(class: "gap-2") { … }group
A labelled group (a div with role="group").
group(label: "Filters") { … }text
Inline text (a span).
text(class: "font-bold") "Hi"paragraph
A paragraph (p).
paragraph "…"link
A link (a).
| Attribute | Takes | Default | Does |
|---|---|---|---|
href | url | — | Where it goes. |
link(href: "/about") "About"image
An image (img).
| Attribute | Takes | Default | Does |
|---|---|---|---|
src | url | — | The image. |
alt | string | — | Its text alternative (required unless decorative). |
image(src: "/a.jpg", alt: "A cat")slot
Where a component's content goes.
div(class: "card") { slot }canvas2d
A 2D drawing: shapes (rect, circle, arc, line, path, text) drawn to a canvas, with accessible proxies for labelled shapes and click/hover events.
| Attribute | Takes | Default | Does |
|---|---|---|---|
width | px | 300 | Logical width (shape coordinates). |
height | px | 150 | Logical height. |
canvas2d(width: 200, height: 100) { circle(cx: 50, cy: 50, r: 40, fill: "#8b5cf6", label: "Dot") }scene3d
A WebGL 3D scene, written like React Three Fiber: camera, lights, objects (mesh, primitives, text3d, model), groups, particles and html content.
| Attribute | Takes | Default | Does |
|---|---|---|---|
width | px | 300 | Logical width (without a size class). |
height | px | 150 | Logical height. |
background | colour | dark grey | The colour it clears to; transparent lets the page show through. Without it, a bg-* class shows through. |
fog | number | 0 | Fog density (towards the background colour). |
backdrop | preset | — | An animated shader behind the scene (aurora, plasma, …). |
backdrop-colors | "c1 c2 …" | — | The backdrop's palette. |
backdrop-intensity | number | 1 | The backdrop's brightness. |
backdrop-speed | number | 1 | The backdrop's speed. |
controls | orbit | — | Drag, wheel and arrow keys orbit the camera. |
scene3d(class: "h-96 w-full", controls: "orbit") {
camera(position: "0 1 5")
mesh { sphereGeometry(args: "1") meshStandardMaterial(color: "hotpink") }
}shader
A full-surface animated fragment shader: a preset or your own GLSL. Reacts to the pointer.
| Attribute | Takes | Default | Does |
|---|---|---|---|
preset | name | mesh-gradient | mesh-gradient, aurora, plasma, galaxy, waves, synthwave, liquid, topography, rays, grid-glow, silk. |
fragment | GLSL | — | Your own: a main writing out_color, with u_time, u_resolution, u_mouse, u_color[4], u_intensity, fbm, vnoise, u_map… |
colors | "c1 c2 c3 c4" | — | The palette (u_color[0..3]). |
speed | number | 1 | Time multiplier. |
intensity | number | 1 | Brightness (u_intensity). |
texture | text | "" | Path to an image file |
detail | "normal" | "high" | "normal" | high renders at up to 2× density, for fine lines such as rain; normal keeps a small pixel budget, which suits smooth gradients. |
shader(preset: "aurora", colors: "#000 #8b5cf6 #22d3ee", class: "absolute inset-0")particles2d
An interactive 2D particle background: drifting shapes joined by lines, reacting to hover and clicks. Decorative unless it has a label.
| Attribute | Takes | Default | Does |
|---|---|---|---|
count | number | 80 | How many particles (per density area). |
density | number | false | 800 | Thousand square pixels per count particles; false keeps count fixed. |
color | colours | random | "#94a3b8" | Colours, space-separated (each particle picks one). |
shape | circle square triangle polygon star image | circle | Shapes, space-separated. |
sides | number | 5 | Polygon sides, star points. |
stroke | colour | — | Outline colour. |
stroke-width | px | 0 | Outline width. |
image | url | — | Image for shape: "image" (an SVG takes the particle's colour). |
image-width | number | 1 | Image width, for its aspect ratio. |
image-height | number | 1 | Image height, for its aspect ratio. |
opacity | 0–1 | 0.5 | Opacity. |
opacity-random | boolean | false | Random opacity up to opacity. |
opacity-speed | number | 0 | Pulse speed (0: none). |
opacity-min | 0–1 | 0.1 | Lowest pulsing opacity. |
opacity-sync | boolean | false | Pulse together. |
size | px | 3 | Radius. |
size-random | boolean | true | Random radius up to size. |
size-speed | number | 0 | Pulse speed (0: none). |
size-min | px | 0.1 | Smallest pulsing radius. |
size-sync | boolean | false | Pulse together. |
links | boolean | true | Lines between nearby particles. |
link-distance | px | 150 | How near. |
link-color | colour | "#94a3b8" | Line colour. |
link-opacity | 0–1 | 0.4 | Opacity of the shortest lines. |
link-width | px | 1 | Line width. |
move | boolean | true | Drift. |
speed | number | 2 | Drift speed. |
direction | none top top-right right bottom-right bottom bottom-left left top-left | none | Drift direction. |
random-speed | boolean | false | Vary speed between particles. |
straight | boolean | false | Move exactly in direction. |
edge | out | bounce | out | At the edges: wrap round, or bounce. |
collide | boolean | false | Bounce off each other. |
attract | boolean | false | Linked particles pull together. |
attract-x | number | 3000 | Horizontal pull (smaller is stronger). |
attract-y | number | 3000 | Vertical pull (smaller is stronger). |
detect | window | canvas | window | Where the pointer is followed. |
hover | grab bubble repulse | none | grab | Hover effects. |
click | push remove bubble repulse | none | push | Click effects. |
grab-distance | px | 140 | Reach of grab. |
grab-opacity | 0–1 | 1 | Opacity of grab lines. |
bubble-distance | px | 200 | Reach of bubble. |
bubble-size | px | 40 | Radius to bubble to. |
bubble-opacity | 0–1 | 0.8 | Opacity to bubble to. |
bubble-duration | seconds | 0.4 | A click's bubble time. |
repulse-distance | px | 200 | Reach of repulse. |
repulse-duration | seconds | 0.4 | A click's repulse time. |
push | number | 4 | Particles a click adds. |
remove | number | 2 | Particles a click removes. |
seed | number | 1 | Random seed. |
particles2d(class: "absolute inset-0 -z-10", color: "#38bdf8", hover: "repulse", click: "push")canvas2d shapes
Inside canvas2d(width, height, label): shapes drawn on a 2D canvas. A label makes a shape part of the accessibility tree.
rect
A rectangle, optionally rounded.
| Attribute | Takes | Default | Does |
|---|---|---|---|
x | px | 0 | Left. |
y | px | 0 | Top. |
w | px | 0 | Width. |
h | px | 0 | Height. |
r | px | 0 | Corner radius. |
rect(x: 10, y: 10, w: 80, h: 40, r: 8, fill: "#22d3ee")circle
A circle.
| Attribute | Takes | Default | Does |
|---|---|---|---|
cx | px | 0 | Centre x. |
cy | px | 0 | Centre y. |
r | px | 0 | Radius. |
circle(cx: 50, cy: 50, r: 20, fill: "red")arc
An arc or ring segment (degrees, clockwise from the top).
| Attribute | Takes | Default | Does |
|---|---|---|---|
cx | px | 0 | Centre x. |
cy | px | 0 | Centre y. |
r | px | 0 | Outer radius. |
inner | px | 0 | Inner radius (a ring when above 0). |
start | degrees | 0 | Start angle. |
end | degrees | 360 | End angle. |
arc(cx: 50, cy: 50, r: 40, inner: 30, end: 270, fill: "#8b5cf6")line
A straight line.
| Attribute | Takes | Default | Does |
|---|---|---|---|
x1 | px | 0 | Start x. |
y1 | px | 0 | Start y. |
x2 | px | 0 | End x. |
y2 | px | 0 | End y. |
line(x1: 0, y1: 0, x2: 100, y2: 50, stroke: "white", line-width: 2)path
A polyline or polygon through points, optionally smoothed.
| Attribute | Takes | Default | Does |
|---|---|---|---|
points | "x,y x,y …" | — | Its points. |
closed | flag | — | Close it into a polygon. |
smooth | flag | — | Curve through the points (Catmull-Rom). |
path(points: "0,50 50,10 100,50", smooth: true, stroke: "#22d3ee")text
Text drawn on the canvas.
| Attribute | Takes | Default | Does |
|---|---|---|---|
x | px | 0 | Anchor x. |
y | px | 0 | Baseline y. |
size | px | 14 | Font size. |
align | left | center | right | left | Alignment at the anchor. |
weight | CSS weight | — | Font weight. |
text(x: 50, y: 20, align: "center", fill: "white") "Hello"scene3d objects
Inside scene3d(width, height, label): the camera, lights, meshes and materials of a WebGL scene.
camera
The scene's camera.
Also written perspectiveCamera.
| Attribute | Takes | Default | Does |
|---|---|---|---|
position | "x y z" | 0 0 5 | Where it is (also x, y, z). |
target | "x y z" | 0 0 0 | What it looks at (also tx, ty, tz). |
fov | degrees | 60 | Vertical field of view. |
camera(position: "0 1 6", fov: 45)light
The key (directional) light, and the hemisphere ambient. cast-shadow gives it shadows.
Also written directionalLight.
| Attribute | Takes | Default | Does |
|---|---|---|---|
position | "x y z" | — | Direction it shines from (also x, y, z). |
color | colour | white | Its colour. |
intensity | number | 1 | Its brightness. |
ambient | 0–1 | — | Ambient (hemisphere) light amount. |
sky | colour | — | Ambient colour from above. |
ground | colour | — | Ambient colour from below. |
directionalLight(position: "2 3 4", intensity: 1.2)ambientLight
Even light from everywhere.
| Attribute | Takes | Default | Does |
|---|---|---|---|
intensity | 0–1 | 0.5 | How much. |
color | colour | — | Its colour (sky and ground). |
ambientLight(intensity: 0.4)hemisphereLight
Ambient light shading from a sky colour to a ground colour.
| Attribute | Takes | Default | Does |
|---|---|---|---|
sky | colour | — | From above (or color). |
ground | colour | — | From below. |
intensity | 0–1 | — | How much. |
hemisphereLight(sky: "#bde0fe", ground: "#3a2e1f")pointLight
A light at a point (up to four per scene). cast-shadow gives it shadows (a cube map, six passes).
| Attribute | Takes | Default | Does |
|---|---|---|---|
position | "x y z" | — | Where it is. |
color | colour | white | Its colour. |
intensity | number | 1 | Its brightness. |
distance | units | 0 | Where it fades out (0: falls off with distance). |
pointLight(position: "2 2 2", color: "#f472b6", intensity: 2)spotLight
A cone of light from a point towards a target (up to four per scene). cast-shadow gives it shadows.
| Attribute | Takes | Default | Does |
|---|---|---|---|
position | "x y z" | 0 4 0 | Where it is (also x, y, z). |
target | "x y z" | 0 0 0 | What it points at (also tx, ty, tz). |
color | colour | white | Its colour. |
intensity | number | 1 | Its brightness. |
distance | units | 0 | Where it fades out (0: falls off with distance). |
angle | degrees | 30 | Half-angle of the cone. |
penumbra | 0–1 | 0.2 | How much of the cone's edge fades. |
x | number | — | Position x. |
y | number | — | Position y. |
z | number | — | Position z. |
tx | number | — | Target x. |
ty | number | — | Target y. |
tz | number | — | Target z. |
spotLight(position: "-2 4 2", angle: 30, penumbra: 0.3, cast-shadow: true)particles
A GPU particle field.
| Attribute | Takes | Default | Does |
|---|---|---|---|
count | number | — | How many. |
radius | units | — | How far they spread. |
shape | galaxy | ring | shell | disc | box | — | Their arrangement. |
color | colour | — | Colour (mixed towards color2). |
color2 | colour | — | Second colour. |
size | px | — | Point size. |
speed | number | — | How fast they move. |
seed | number | — | Random seed. |
position | "x y z" | — | Centre (also x, y, z). |
particles(count: 400, radius: 5, shape: "shell", color: "#a78bfa")group
Groups objects under one transform.
| Attribute | Takes | Default | Does |
|---|---|---|---|
position | "x y z" | — | Offset of everything in it. |
rotation | "x y z" (degrees) | — | Rotation of everything in it. |
scale | number | "x y z" | 1 | Scale of everything in it. |
group(rotation: "0 30 0") { … }mesh
An object: a geometry child (boxGeometry, sphereGeometry, … or a text3d) and a material child (meshStandardMaterial, shaderMaterial). Without a geometry it's a unit cube. Takes @click and pointer events, and html children.
mesh(position: "0 1 0", @click: buy, label: "Lamp") {
torusKnotGeometry(args: "1 0.3")
meshStandardMaterial(color: "hotpink", roughness: 0.3)
}cube
A cube (shorthand for mesh { boxGeometry }).
| Attribute | Takes | Default | Does |
|---|---|---|---|
size | units | 1 | Edge length. |
cube(size: 2, color: "#22d3ee", spin-y: 30)sphere
A UV sphere.
| Attribute | Takes | Default | Does |
|---|---|---|---|
radius | units | 1 | Its radius. |
sphere(radius: 1, color: "hotpink")plane
A flat rectangle in the XY plane, facing +z, as three.js. Turn it with rotate-x: -90 to make a floor.
| Attribute | Takes | Default | Does |
|---|---|---|---|
width | units | size | Along x. |
height | units | size | Along y. |
size | units | 4 | Sets both. |
plane(size: 10, y: -1, rotate-x: -90)torus
A ring torus.
| Attribute | Takes | Default | Does |
|---|---|---|---|
radius | units | 1 | Ring radius. |
tube | units | 0.4 | Tube radius. |
torus(radius: 1, tube: 0.3)torus-knot
A (p, q) torus knot.
| Attribute | Takes | Default | Does |
|---|---|---|---|
radius | units | 1 | Size. |
tube | units | 0.4 | Tube radius. |
p | number | 2 | Windings round the axis. |
q | number | 3 | Windings through the hole. |
torus-knot(radius: 1, tube: 0.3, p: 2, q: 3)icosphere
A geodesic sphere.
| Attribute | Takes | Default | Does |
|---|---|---|---|
radius | units | 1 | Its radius. |
detail | 0–5 | 0 | Subdivisions. |
icosphere(radius: 1.2, detail: 3, wobble: 0.3)cylinder
A capped cylinder along y.
| Attribute | Takes | Default | Does |
|---|---|---|---|
radius | units | 1 | Its radius. |
height | units | 1 | Its height. |
cylinder(radius: 0.5, height: 2)cone
A capped cone along y, apex up.
| Attribute | Takes | Default | Does |
|---|---|---|---|
radius | units | 1 | Base radius. |
height | units | 1 | Its height. |
cone(radius: 0.5, height: 1)boxGeometry
A box's geometry, inside a mesh.
| Attribute | Takes | Default | Does |
|---|---|---|---|
args | "size" | 1 | args: "…" (three.js constructor arguments) |
boxGeometry(args: "1.5")sphereGeometry
A sphere's geometry, inside a mesh.
| Attribute | Takes | Default | Does |
|---|---|---|---|
args | "radius" | 1 | args: "…" (three.js constructor arguments) |
sphereGeometry(args: "1")planeGeometry
A plane's geometry, inside a mesh: args: "width height", as three.js (one number makes a square). It lies in the XY plane, facing +z.
| Attribute | Takes | Default | Does |
|---|---|---|---|
args | "width height" | 1 1 | args: "…" (three.js constructor arguments) |
planeGeometry(args: "16 9")torusGeometry
A torus's geometry, inside a mesh.
| Attribute | Takes | Default | Does |
|---|---|---|---|
args | "radius tube" | 1 0.4 | args: "…" (three.js constructor arguments) |
torusGeometry(args: "1 0.3")torusKnotGeometry
A torus knot's geometry, inside a mesh.
| Attribute | Takes | Default | Does |
|---|---|---|---|
args | "radius tube _ _ p q" | 1 0.4 _ _ 2 3 | args: "…" (three.js constructor arguments) |
torusKnotGeometry(args: "1.1 0.34 128 32 2 3")icosahedronGeometry
A geodesic sphere's geometry, inside a mesh.
| Attribute | Takes | Default | Does |
|---|---|---|---|
args | "radius detail" | 1 0 | args: "…" (three.js constructor arguments) |
icosahedronGeometry(args: "1 2")cylinderGeometry
A cylinder's geometry, inside a mesh.
| Attribute | Takes | Default | Does |
|---|---|---|---|
args | "top bottom height" | 1 1 1 | args: "…" (three.js constructor arguments) |
cylinderGeometry(args: "0.5 0.5 2")coneGeometry
A cone's geometry, inside a mesh.
| Attribute | Takes | Default | Does |
|---|---|---|---|
args | "radius height" | 1 1 | args: "…" (three.js constructor arguments) |
coneGeometry(args: "0.5 1")meshStandardMaterial
The built-in lit material: hemisphere ambient, Blinn-Phong, rim light, gradients, textures, fog. With preset, a shader preset drawn on the object instead.
| Attribute | Takes | Default | Does |
|---|---|---|---|
color | colour | white | Base colour. |
color2 | colour | — | Gradient to this colour, bottom to top. |
roughness | 0–1 | — | 0 glossy, 1 matte. |
metalness | 0–1 | 0 | Adds a metallic rim. |
shininess | number | 32 | Specular exponent. |
rim | number | 0 | Fresnel rim-light strength. |
rim-color | colour | white | Rim-light colour. |
emissive | 0–1 | 0 | Self-illumination (also emissive-intensity). |
wobble | number | 0 | Animated noise displacement. |
opacity | 0–1 | 1 | Opacity. |
map | url | — | Base-colour texture (also texture; wrap, filter, flip-y). |
preset | name | — | Draw a shader preset on the object (colors, intensity). |
meshStandardMaterial(color: "#8b5cf6", color2: "#22d3ee", roughness: 0.25, metalness: 0.6)meshPhysicalMaterial
Physically based shading, metallic-roughness (as glTF, whose models use it): GGX highlights, the hemisphere ambient as a blurred environment, and texture maps. Tangents for normal maps come from the uvs.
Also written physicalMaterial, pbrMaterial, pbr.
| Attribute | Takes | Default | Does |
|---|---|---|---|
color | colour | white | Base colour (albedo). |
metallic | 0–1 | 0 | 0 dielectric, 1 metal (also metalness). |
roughness | 0–1 | 0.5 | 0 mirror-like, 1 matte. |
emissive | colour | number | — | Emitted colour, or how much the base colour glows. |
emissive-intensity | number | 1 | Strength of the emitted colour. |
opacity | 0–1 | 1 | Opacity. |
env-intensity | number | 1 | How strongly it reflects the sky and ground ambient. |
map | url | — | Base-colour (albedo) texture. |
metallic-roughness-map | url | — | Roughness in green, metalness in blue (glTF's packing). |
roughness-map | url | — | Roughness from its green channel. |
metallic-map | url | — | Metalness from its blue channel. |
normal-map | url | — | Tangent-space normals. |
normal-scale | number | 1 | Normal map strength. |
occlusion-map | url | — | Ambient occlusion from its red channel. |
occlusion-strength | 0–1 | 1 | How much the occlusion map darkens. |
emissive-map | url | — | Emitted colour texture. |
meshPhysicalMaterial(color: "#e9b44c", metallic: 1, roughness: 0.3)shaderMaterial
Your own GLSL. A source without #version gets a prelude (only what you don't declare): a_position, a_normal, a_uv, a_color; u_size (the mesh's size in world units), u_mvp, u_model, u_view, u_projection, u_normal_matrix, u_time, u_resolution (the canvas's, in device pixels), u_camera, u_color, u_opacity, u_map, the lights; snoise, weft_lambert(n, world), weft_skin(), out_color. Preset-style code (fbm, u_color[i]) gets the preset library. Uniforms come from uniform children or a uniforms record.
Also written rawShaderMaterial.
| Attribute | Takes | Default | Does |
|---|---|---|---|
fragment | GLSL | — | The fragment shader (pass it from scope; inline braces need { }). |
vertex | GLSL | — | The vertex shader (default passes v_uv, v_normal, v_world, v_position, v_color). |
preset | name | — | Use a shader preset as the fragment shader. |
uniforms | record | — | Uniforms from scope (numbers, colours, lists, {src} textures). |
attributes | record | — | Per-vertex data by name ({size, data}). |
texture | url | — | Shorthand for a u_map texture uniform. |
colors | "c1 c2 …" | — | The palette u_color[4] for preset-style code. |
intensity | number | — | u_intensity. |
opacity | 0–1 | 1 | Opacity (makes it transparent). |
transparent | flag | — | Blend it (drawn after opaque objects). |
side | front | back | double | front | Which faces draw. |
blending | normal | additive | normal | How it blends. |
depth-write | flag | — | Write depth (off when transparent). |
shaderMaterial(fragment: lava, transparent: true) {
uniform(name: "u_noise", texture: "/noise.png")
uniform(name: "u_tint", value: "#ff5a18")
}uniform
A shaderMaterial uniform.
| Attribute | Takes | Default | Does |
|---|---|---|---|
name | identifier | — | The uniform's name in the shader. |
value | number | colour | "x y z" | bool | — | Its value (a float, vecN, or bool). |
texture | url | — | A sampler2D texture instead. |
wrap | repeat | clamp | mirror | repeat | Texture wrapping. |
filter | linear | nearest | linear | Texture filtering. |
flip-y | flag | true | Flip the image's rows on upload. |
uniform(name: "u_amp", value: 0.3)attribute
Per-vertex data for a shaderMaterial.
| Attribute | Takes | Default | Does |
|---|---|---|---|
name | identifier | — | The attribute's name in the vertex shader. |
size | 1–4 | 1 | Components per vertex. |
values | "…" | list | — | The data (vertex count × size). |
attribute(name: "a_offset", size: 1, values: offsets)text3d
Text set in a font (TTF, OTF, WOFF, WOFF2, or a .wfont), flat or extruded, with the font's kerning. Needs weft's fonts feature for font files. Its text is its accessible label. With a material child, put the text inside the block.
Also written text3D, Text3D.
| Attribute | Takes | Default | Does |
|---|---|---|---|
font | url | — | The font. |
text | string | — | The text (or the element's own text). |
size | units per em | 1 | Size. |
depth | units | 0 | Extrusion (0 is flat). |
bevel | units | 0 | Bevel on the front and back edges. |
align | left | center | right | center | Alignment. |
line-height | ems | 1.2 | Line spacing. |
letter-spacing | ems | 0 | Extra space between letters. |
curve | ems | 0.01 | How closely curves are followed (smaller is smoother). |
text3d(font: "/fonts/Inter.woff2", size: 0.8, depth: 0.2, bevel: 0.02) {
"Hello"
meshStandardMaterial(color: "#fff")
}model
A model file: glTF/GLB (meshes, materials, textures, node and skeletal animation), OBJ+MTL, STL, PLY, an SVG drawing (its shapes as meshes, flat or extruded), or a .wmodel. Needs weft's models feature for model files. A material child replaces its own.
Also written gltf.
| Attribute | Takes | Default | Does |
|---|---|---|---|
src | url | — | The file. |
animation | name | index | — | The clip to play. |
animation-speed | number | 1 | Playback speed. |
loop | bool | true | Repeat the clip (once stops at the end). |
node | name | — | Only this node and what's under it (an SVG shape by its id). |
depth | number | 0 | SVG: extrude the shapes this thick (the drawing's longer side is 1); flat at 0. |
bevel | number | 0 | SVG: round the extruded edges by this much. |
curve | number | 0.001 | SVG: how far flattened curves may stray (smaller is smoother). |
model(src: "/models/fox.glb", animation: "Run", scale: 0.02)html
Real DOM in the scene (Weft UI components and all): pinned to a point facing the screen, or on a plane in perspective with transform. Inside an object it rides on it.
Also written Html.
| Attribute | Takes | Default | Does |
|---|---|---|---|
position | "x y z" | 0 0 0 | Where it is. |
rotation | "x y z" (degrees) | — | Its rotation (planes). |
scale | number | 1 | Its scale. |
transform | flag | — | Lay it on a plane in the scene (100 CSS px per unit). |
distance-factor | number | — | Pinned: natural size at this distance, scaling with distance. Plane: × the 100 px per unit. |
center | bool | true | Centre it on its point. |
occlude | flag | — | Hide it while an object is in front. |
class | Tailwind classes | — | Classes for its layer. |
html(position: "0 1.5 0", occlude: true) { Card { Button(@click: buy) "Buy" } }HTML elements
Any HTML tag can be used. These are the ones the language server describes:
| Element | Is |
|---|---|
a | A link. |
article | A self-contained piece of content. |
aside | Tangential content. |
button | A button. |
div | A generic block. |
footer | A footer. |
form | A form (@submit; the page isn't reloaded). |
h1 | A top-level heading. |
h2 | A second-level heading. |
h3 | A third-level heading. |
h4 | A fourth-level heading. |
header | A header. |
img | An image (src, alt). |
input | A form field (type, value, @input). |
label | A form field's label. |
li | A list item. |
main | The page's main content. |
nav | Navigation. |
ol | A numbered list. |
p | A paragraph. |
section | A section. |
select | A drop-down (with options). |
span | Generic inline content. |
svg | SVG graphics (attributes pass through). |
table | A table. |
textarea | A multi-line text field. |
ul | A bulleted list. |
HTML attributes
On an HTML element, these attributes are written as text when they aren't null:
id, href, src, alt, value, placeholder, name, title, type, target, for, min, max, step, rows, cols, tabindex, autocomplete, inputmode, pattern, maxlength, minlength, colspan, rowspan, scope, abbr, datetime, lang, dir, rel, download, loading, decoding, poster, width, height, srcset, sizes, action, method, enctype, accept, list, form, headers, start, popover, popovertarget, spellcheck, draggable, enterkeyhint, allow, referrerpolicy, sandbox, srcdoc, preload, media, cite, crossorigin, frameborder, allowfullscreen, usemap, shape, coords, kind, srclang, content, charset, integrity.
These flags are written with no value when truthy, and left out otherwise:
checked, disabled, readonly, required, autofocus, hidden, inert, open, selected, multiple, controls, muted, loop, autoplay, playsinline, novalidate, reversed.
class, style, role, label (as aria-label), aria-* and data-* are written too, and gap, padding, margin, color and background go into style. Anything else is left out, except inside svg, where every attribute passes through.