Skip to content

JSON schema ​

InsigneSlider.create(target, spec) replaces the children of target with slides built from spec and starts a slider. Any option can be placed at the top level or under options.

ts
InsigneSlider.create(target: HTMLElement | string, spec: SliderSpec): InsigneSlider

SliderSpec ​

FieldTypeDescription
slides(SlideSpec | string)[]Required. A string is shorthand for { bg: string }.
optionsOptionsOptions (also accepted at the top level).
any optione.g. effect, autoplay…

SlideSpec ​

FieldTypeDescription
bgstring | BgSpecBackground image or video.
layersLayerSpec[]Elements on top, in order.
contentClassstringWrap the layers in a div with this class (for positioning).
htmlstringTrusted HTML inserted after the background, before the layers.
classNamestringClass of the slide element.
stylestring | Record<string, string | number>Inline style (camelCase or CSS names, --custom properties).
attrsRecord<string, string>Extra attributes on the slide.
kenBurnsstring | booleanKen Burns for this slide.

BgSpec ​

FieldTypeDefaultDescription
srcstring—Image URL (video URL with video: true).
srcset, sizesstring—Responsive sources.
altstring""Alternative text.
focusstring"50% 50%"Focal point.
safestring—Safe area "l t w h".
fit"smart" | "cover" | "contain"smartFit mode.
videobooleanfalseRender a muted, looping <video>.
posterstring—Video poster (also used by WebGL transitions).
lazybooleanfalseUse data-src (load near the active slide).

LayerSpec ​

FieldTypeDescription
tagstringElement name. Default div, or a when href is set.
textstringText content (safe: textContent).
htmlstringTrusted HTML (ignored when text is set).
hrefstringLink target.
className, style, attrsAs for slides.
in, out, split, delayLayer animation (data-in, data-out, data-split, data-delay).
parallaxstring | numberdata-parallax.
childrenLayerSpec[]Nested layers.

Example ​

json
{
  "effect": "fade",
  "autoplay": 6000,
  "kenBurns": "alternate",
  "slides": [
    {
      "bg": { "src": "/img/hall.jpg", "alt": "Main hall", "focus": "40% 35%" },
      "html": "<div class=\"shade\"></div>",
      "contentClass": "copy",
      "layers": [
        { "tag": "small", "text": "Season opening", "in": "fade" },
        { "tag": "h2", "text": "Opening night", "in": "lines-up" },
        { "tag": "a", "text": "Tickets", "href": "/tickets", "className": "btn", "in": "rise", "delay": 600 }
      ]
    },
    "/img/stage.jpg"
  ]
}

Security ​

Strings in text, alt and attributes are inserted as text, never parsed as HTML. Only html fields are parsed — never fill them with user input.

Insigne Slider v1.0.0 · Free for any use with visible attribution · Atıf ile her kullanım için ücretsiz