Skip to main content

Skeletons.Element

A generic DOM element skeleton — renders any HTML element by tag name. Use it when none of the other Skeletons primitives (Box, Button, Note) match the element you need.


Signature

Skeletons.Element(props, style?)
ParamTypeDescription
propsObject / StringElement options, or a plain string shorthand for content
styleObject / StringInline styles, or a class name shorthand

Common Props

PropTypeDescription
tagNameStringHTML tag to render — defaults to a wrapper element if omitted
classNameStringCSS class(es) to apply
contentStringInner text or HTML content
flowStringLayout direction (x, y, none, etc.)
sys_pnStringNamed part — enables onPartReady and ensurePart
uiHandlerWidgetRoutes interaction events to onUiEvent
serviceStringService name triggered on interaction
attrOptObjectHTML attributes set on the element (e.g. src, autoplay)
attributeObjectSame as attrOpt — alternative key
datasetObjectdata-* attributes
typeStringValue for the type attribute (e.g. on <source>)
preloadStringValue for the preload attribute
nameStringValue for the name attribute
styleObjectInline styles passed as second argument

Examples

A plain image element

Skeletons.Element({
tagName: "img",
attribute: { src: myImageUrl },
style: { display: "none" },
});

A named content area with flow

Skeletons.Element({
flow: "x",
className: `${fig}__recent-items`,
sys_pn: "recent-items",
content: myContent,
});

An interactive item with service

Skeletons.Element({
className: `${fig}__item`,
content: myContent,
service: "my-action",
uiHandler: ui,
});

A <source> element for audio/video

Skeletons.Element({
tagName: "source",
className: `${fig}__audio-source`,
sys_pn: "audio-src",
type: ui.mget("mimetype"),
preload: "auto",
attrOpt: { src: ui._url() },
});

A <video> element with dataset

Skeletons.Element({
tagName: "video",
className: `${fig}__video`,
sys_pn: "video",
attrOpt: { autoplay: "" },
dataset: {
status: "idle",
size: ui.mget("size"),
},
});

When to Use

Need a <img>, <video>, <audio>, <source>? → Skeletons.Element with tagName
Need a plain content container? → Skeletons.Element (no tagName)
Need a layout container with kids? → Skeletons.Box instead
Need a clickable icon button? → Skeletons.Button instead
Need inline text? → Skeletons.Note instead