Refrakt v1.0.0

Start here · Level 1

Your pictures, behind glass.

This is the short guide. Follow it top to bottom and you will have a working slider showing your images and your text, on your own page, in about fifteen minutes. You do not need to know WebGL. You do not need to change any settings. You will not open a single .json file.

Three guides, in order of depth. Each links on to the next — take them as far as you need and stop.

  1. Level 1 Start here Your pictures, your words, a look you like. Editing HTML only. You are here
  2. Level 2 Customizing Colours, height, autoplay, arrows and dots, clickable slides, video. Ready-made lines you paste and edit.
  3. Level 3 Reference manual Every option, the JavaScript API, events. The full contract, for developers.

Stuck on any of it? Email jawad.ahbab.turna@gmail.com — that reaches me, the developer who wrote the slider, not a ticket queue. Usually answered within a working day. What support covers.

01 What you downloaded

Unzip the download and you get three folders and two short text files. That is all there is:

ItemWhat it isYou'll use it…
README.txt A one-page version of this page, for anyone who opens the zip before finding the documentation. Never again, now that you're here.
CHANGELOG.md What's in this version, what the free updates will add, and the measured file sizes. When a new version lands.
demos/ Ten finished web pages built with the slider — a fashion lookbook, a corporate hero, a photo portfolio and so on. Constantly. This is where you'll start your own page from.
documentation/ These pages. Now.
refrakt/ The slider itself — the actual source code. Once, in step 2. After that you only copy two files out of it.

Keep the three folders together, side by side, exactly as they came out of the zip. The demo pages find the slider by looking one folder up, so moving them apart breaks those links.

02 Build it once

This download ships the complete source code of the slider rather than a pre-packed file. Turning that source into the two files your web page actually loads takes one command, and you only ever do it once.

You will need Node.js version 20 or newer — a free install from nodejs.org, about two minutes. It is needed for this build only. Nothing about your finished website depends on it, and your visitors never touch it.

Open a terminal (macOS: Terminal; Windows: PowerShell or Command Prompt), move into the refrakt folder from the download, and run three lines:

cd refrakt      # the folder that contains package.json
npm install     # downloads the build tools — about 30 seconds
npm run build   # builds the slider — about 5 seconds

When it finishes you will have a new folder, refrakt/dist/, containing:

FileWhat it's for
refrakt.umd.jsThe slider. This is the one you put on your page.
refrakt.cssIts stylesheet. You need this too.
refrakt.esm.jsThe same slider in a format for build tools like Vite or webpack. Ignore it unless you use one.

Those two files — refrakt.umd.js and refrakt.css — are the entire product as far as your website is concerned. Together they are around 40 KB compressed, and they load nothing else: no jQuery, no Three.js, no fonts, no CDN, no tracking. Copy them anywhere you like.

Never run a terminal command before? The build is safe to repeat — run it as often as you like, it always produces exactly the same result. If the third line reports an error, the common causes and their fixes are on the Troubleshooting page.

03 See it working

Open demos/index.html in your browser — just double-click the file. No web server, no setup. You will get a hub page linking to all ten demos.

Click through them and find the one closest to what you are building. That page is your starting point for everything below.

DemoBuilt for
Open atelierFashion lookbooks, design portfolios — a carousel of plates behind deep fluted glass
Open boardroomCorporate and SaaS home pages — calm, self-advancing, no distortion at rest
Open prism-noirDark editorial sites — heavy prism tear and a big numbered menu
Open darkroomPhotography portfolios — each frame develops up from white under film grain
Open frostHospitality, food and drink — slides cloud over, then resolve pin-sharp
Open eclipseProduct pages and luxury reveals — glass that relights as the pointer moves
Open spectraType-led editorial and events — RGB-echo headings over a sweeping prism band
Open client-safeVideo-first pages — self-hosted video and YouTube slides
vitrineThree independent sliders on one page
optics-labA live control panel — drag the sliders and watch the glass change

Seeing a dark screen that says "Build the library first"? Step 2 has not been run yet. Go back and run it.

04 Use your own pictures

This is the part everyone comes for, and it is genuinely one line of HTML per picture.

The one thing to understand

Every slide is a plain <figure> holding an ordinary <img> tag. That is it. The glass, the light and the refraction are applied on top of that image while the page runs — nothing is baked into the file. Your photograph stays a normal web image that you can open, edit and replace like any other.

<figure class="rf-slide">
  <img src="img/harbour.jpg" alt="Fishing boats at dawn">
</figure>

Change img/harbour.jpg to the path of your picture. Change the alt text to describe it. Save. Reload. That is your photograph, behind the glass.

Step by step

  1. Copy the demo folder you liked. If it was atelier, duplicate demos/atelier/ and rename the copy to whatever you want. Work in the copy, so the original stays intact for reference.

  2. Put your images somewhere. Easiest: make an img folder inside your copy and drop them in. JPG, PNG and WebP all work.

  3. Open index.html in a text editor and search for rf-slide. You will find one block per slide, one after another.

  4. Point each <img> at your file and rewrite its alt.

  5. Save and reload the page. Your pictures are in the glass.

What the demo markup looks like, and what to change

The demos use a slightly longer form than the one-liner above, because they are tuned for loading speed. Here is a real slide from demos/atelier/index.html with the parts you edit marked:

<figure class="rf-slide">
  <img src="../assets/img/atelier-1-lqip.jpg"          <!-- (1) tiny preview -->
       data-rf-src="../assets/img/atelier-1.jpg"        <!-- (2) the real photo -->
       alt="Soft-focus study of deep sienna fabric">    <!-- (3) describe it -->
  <figcaption class="rf-text">
    ...
  </figcaption>
</figure>
What it isWhat to do
(1) src A very small copy of the photo — around 30 px wide, a couple of kilobytes. It appears instantly while the real one downloads, so visitors never see an empty box. Optional. Skip it and put your real photo here instead — see below.
(2) data-rf-src The full-size photograph. Loaded only when it is about to be needed. Your image path goes here.
(3) alt A plain-English description of the picture, for screen readers and search engines. Always write one. One short sentence.

Don't want to make two versions of every photo?

Then don't. Delete the data-rf-src line and put your real photo in src. The slider uses whatever it is given:

<figure class="rf-slide">
  <img src="img/harbour.jpg" alt="Fishing boats at dawn">
</figure>

Everything else works identically. You give up one thing: the "frost-up" effect, where a slide starts clouded and clears as the full photo arrives. With a single image there is nothing to clear from, so the slide simply fades in instead. That is the whole trade-off. You can add the small previews later if you decide you want them — it is the same one line, put back.

Picture sizes

QuestionAnswer
How big should my images be?About 1600 px on the longest side. That is the sweet spot for a full-width slider.
Can I use my 4000 px camera files?You can, but don't. The slider caps every image at 2048 px internally — anything beyond that costs your visitors download time and shows nothing extra.
Do they all have to be the same shape?No. Each image is scaled to fill the slider and cropped on the overflowing side, exactly like CSS background-size: cover. Mixing portrait and landscape is fine; just keep the subject near the middle.
How many slides can I have?As many as you like. Only the slides near the visible one are loaded, so a 30-slide gallery opens as fast as a 3-slide one.
Portrait photos on phones?They work well. The slider fills whatever box you give it, so a tall container on phones and a wide one on desktop is a normal thing to do.

Want video slides, or a YouTube embed? Both are one attribute each — Customizing § video and YouTube has the lines you need.

05 Use your own words

Captions are plain HTML too. Each slide can carry a <figcaption class="rf-text">, and whatever you put inside it appears over the slide:

<figure class="rf-slide">
  <img src="img/harbour.jpg" alt="Fishing boats at dawn">

  <figcaption class="rf-text">
    <h2>Harbour, 5 a.m.</h2>
    <p>The fleet goes out before the light does.</p>
  </figcaption>
</figure>

Type your headline between the <h2> tags and your sentence between the <p> tags. Save, reload.

Things worth knowing

  • It is real text, not painted into the picture. Visitors can select and copy it, screen readers read it, search engines index it, and it stays sharp on every screen.
  • No caption? Leave the whole <figcaption> block out. The slide shows just the image.
  • Use whatever tags you want inside it — headings, paragraphs, a link, a button. It is ordinary HTML in an ordinary place.
  • Some demos use different tags. atelier, for instance, uses <span>s with classes like look-name so that page can style them its own way. Don't let it throw you: the text between the tags is still just text. Replace the words and leave the tags alone.
  • Keep it short. The caption sits over a moving image; a headline and one line reads far better than a paragraph.

Adding a link or a button

<figcaption class="rf-text">
  <h2>Autumn collection</h2>
  <p>Twenty-two pieces, cut in Florence.</p>
  <p><a href="/collections/autumn">See the collection</a></p>
</figcaption>

Links and buttons inside a caption stay clickable and keyboard-reachable — dragging the slider will not fire them by accident, and tabbing reaches them in the usual order.

Caption text hard to read against a busy photo? Add rf-scrim to the caption's class list — class="rf-text rf-scrim". That puts a soft, mostly-transparent panel behind the words so they stay legible over any image. More on caption colour →

06 Add or remove a slide

Slides appear in the order they are written. To add one, copy an entire <figure class="rf-slide">…</figure> block — opening tag to closing tag — paste it where you want it, and change the image and text. To remove one, delete the whole block. To reorder, move blocks around.

<div data-refrakt="atelier">

  <figure class="rf-slide">  <!-- slide 1 -->
    <img src="img/one.jpg" alt="…">
  </figure>

  <figure class="rf-slide">  <!-- slide 2 — copy this whole block to add another -->
    <img src="img/two.jpg" alt="…">
  </figure>

</div>

Nothing else needs updating. Dots, counters and the progress bar all count the slides themselves, so five figures give you five dots automatically.

07 Pick a different look

Every optical character — how deep the glass ribs run, how far colour splits when you drag, where the light sits, whether there is film grain — is bundled into a named preset. Switching between them means changing one word.

Find the container element that wraps your slides. It carries a data-refrakt attribute:

<div data-refrakt="atelier">

Change the word in the quotes. That is the whole operation.

<div data-refrakt="darkroom">

The eight looks

Write thisWhat you getSee it
client-safe The safe default. A faint ribbed texture, no dramatic distortion — photography stays photography. Start here if you are unsure. Open client-safe
atelier A carousel: the centre slide sharp, its neighbours dissolving into deep flutes. Warm and editorial. Open atelier
boardroom Calm and corporate. No distortion when still, a faint shimmer when dragged, advances on its own every 7 seconds. Open boardroom
prism-noir Full volume. Heavy prism tear, colours splitting hard, and a large numbered menu instead of arrows. Open prism-noir
frost Slides cloud over with frost as they cross, then resolve pin-sharp. Open frost
darkroom Each frame develops up from white under film grain, breathing slowly. Made for photographers. Open darkroom
spectra Type-led: headings fire an RGB echo in time with a wide prism band sweeping across the slide. Open spectra
eclipse The light follows your pointer, relighting glossy flutes in real time. Objects appear to turn under the cursor. Open eclipse

Presets change the optics, not the colours of your page. A demo's warm paper or black background comes from that demo's own CSS. If you switch atelier to darkroom and it looks odd, it is the page colours that need moving, not the preset — see Customizing § colours.

Want to feel what each control does before choosing? Open the optics-lab demo and drag the sliders. Every knob there is one of the settings in the reference, and the panel shows you the exact line to copy for whatever you land on.

08 Put it on your own page

Working inside a copied demo is the fastest way to start. When you are ready to move the slider into your own site, here is the entire recipe.

  1. Copy two files. Take refrakt.umd.js and refrakt.css out of refrakt/dist/ and put them next to your page — or in whatever assets or js folder you already use.

  2. Link the stylesheet in your <head>.

    <link rel="stylesheet" href="refrakt.css">
  3. Write your slider markup wherever you want it on the page.

  4. Add the script tag at the end of your <body>. Nothing else — no initialisation code, no $(document).ready.

    <script src="refrakt.umd.js"></script>

Here is a complete, working page. Copy it into a file called index.html, put three photos beside it in an img folder, and open it in a browser:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>My slider</title>
  <link rel="stylesheet" href="refrakt.css">
  <style>
    body { margin: 0; }
    #hero { height: 70vh; }   /* the slider fills whatever box you give it */
  </style>
</head>
<body>

  <div id="hero" data-refrakt="atelier">

    <figure class="rf-slide">
      <img src="img/one.jpg" alt="Fishing boats at dawn">
      <figcaption class="rf-text">
        <h2>Harbour, 5 a.m.</h2>
        <p>The fleet goes out before the light does.</p>
      </figcaption>
    </figure>

    <figure class="rf-slide">
      <img src="img/two.jpg" alt="Nets drying on the quay">
      <figcaption class="rf-text">
        <h2>Mending day</h2>
        <p>Every third Tuesday, the whole quay smells of tar.</p>
      </figcaption>
    </figure>

    <figure class="rf-slide">
      <img src="img/three.jpg" alt="The lighthouse in fog">
      <figcaption class="rf-text">
        <h2>Fog signal</h2>
        <p>Two blasts every ninety seconds, since 1904.</p>
      </figcaption>
    </figure>

  </div>

  <script src="refrakt.umd.js"></script>
</body>
</html>

Four rules, and there are no others

RuleWhy
The container needs data-refrakt It is how the script finds it. Leave the value empty (data-refrakt) to get the client-safe look, or name a preset.
Slides must be direct children with class="rf-slide" Wrapping them in an extra <div> hides them from the slider. A <figure> is conventional, but any element works.
The container needs a height The slider fills its box, and a box with no height is invisible. One CSS line — height: 70vh or aspect-ratio: 16/9 — is enough. This is the single most common reason a new slider shows nothing.
The <script> goes last It runs itself and picks up every data-refrakt element on the page — including several sliders at once, each with its own preset.

Using WordPress, Shopify, Webflow or a page builder? The same two files and the same markup apply. Upload the two files wherever that platform keeps assets, then paste the markup into a custom-HTML block. Refrakt is plain HTML, CSS and JavaScript with no framework and no page-level build step, so anywhere you can paste an <img> tag, this works.

09 If something looks wrong

Five things account for nearly every first-hour problem. Check these before anything else:

What you seeAlmost certainly
A dark panel saying "Build the library first" Step 2 has not been run. Run npm install then npm run build inside refrakt/.
Nothing at all — a blank gap where the slider should be The container has no height. Give it one in CSS.
Your images stacked down the page like an ordinary web page The script is not loading, or data-refrakt is missing from the container. Check the path in your <script src>.
Slides appear but look flat — no glass The stylesheet is not loading. Check the path in your <link>.
One slide is blank while the others work A wrong image path on that slide. Filenames are case-sensitive on most web servers, even though they aren't on your Mac or PC.

The quickest diagnosis is always the browser console. Press F12 (or I on a Mac) and read the Console tab. Refrakt announces every problem it detects there, prefixed with [Refrakt], in plain sentences — a mistyped option, an image that failed to load, a missing alt. It never fails silently, and it never throws an exception at you: a bad setting produces a different look, not a broken page.

The Troubleshooting page has the long version — every warning the engine can emit, what causes it, and what to do about it.

10 Where to go next

You now have your own pictures and your own words in a slider whose character you chose. Everything past this point is optional.