Soft Silk Login

A thin sign in form over satin cloth. The pointer presses into the cloth like a palm and a wave runs off along the folds.

Press the cloth with the pointer, a faster hand makes a bigger wave. Type any email and password and press Log in: one wide fold runs across.

Download

What you can change

Change a number, save, and reload the page to see the difference.

SILKcolors

The cloth, the shade in the folds, the soft sheen and the line of light on the crests, each as red, green, blue.

FOLD0.07

How deep the folds are.

SOFT1

How soft the light is, higher is flatter.

SILK_PALM70

How wide the pressing hand is, in pixels.

SILK_PRESS0.1

How hard it presses.

SILK_FADE0.97

How long a wave runs, closer to 1 runs longer. Keep it below 1.

Add it to your site

The sign in page of a studio, a portfolio or a product, anywhere the first screen can afford a little motion.

  1. CSS

    Paste into your stylesheet, or inside a <style> tag in <head>.

    /* page shell, only needed while this file is the whole page */
  2. HTML

    Put it where the effect should appear on your page.

    <!-- login start -->
    <main class="ss">
      <section class="ss-door">
        <canvas class="ss-silk" aria-hidden="true"></canvas>
        <div class="ss-gate">
          <h1 class="ss-display ss-fold">Log in</h1>
          <form class="ss-form" novalidate data-busy="Logging in" data-label="Logged in" data-done="Welcome back. Change this line or send people to their page.">
            <label class="ss-label" for="ss-user">Email<input class="ss-field" id="ss-user" name="email" type="email" autocomplete="username" placeholder="you@example.com" data-need="Enter your email."></label>
            <label class="ss-label" for="ss-pass">Password<input class="ss-field" id="ss-pass" name="password" type="password" autocomplete="current-password" placeholder="Password" data-need="Enter your password."></label>
            <button class="ss-btn" type="submit">Log in</button>
            <p class="ss-note" role="status"></p>
          </form>
        </div>
      </section>
    </main>
    <!-- login end -->
  3. JavaScript

    Paste right before the closing </body> tag, inside <script></script>.

    /* Soft Silk Login by @codinvisual · t.me/CodinVisual · free for your own site, don't resell this file */
    (() => {
    const root = document.querySelector('.ss');
    if (!root) return;
    
    const SILK = { cloth: [247, 240, 230], shade: [196, 176, 158], sheen: [255, 246, 236], glint: [214, 158, 132] };
    const FOLD = .07, SOFT = 1, SILK_PALM = 70, SILK_PRESS = .1, SILK_FADE = .97, SILK_PIXELS = 1.6e6;
    
    const reduce = matchMedia('(prefers-reduced-motion: reduce)').matches;
    root.classList.add('ss-js');
    const $ = (s, el = root) => el.querySelector(s);
    const $$ = (s, el = root) => [...el.querySelectorAll(s)];
    const clamp = (x, a = 0, b = 1) => Math.min(b, Math.max(a, x));
    const wait = ms => new Promise(r => setTimeout(r, ms));
    
    /* silk: a satin cloth with soft folds lies over the top of the page; the pointer presses into it like a palm and a wave runs off along the folds */
    const cloths = [];
    $$('.ss-silk').forEach(cv => {
      if (reduce) return;
      const host = cv.parentNode;
      const gl = cv.getContext('webgl2', { alpha: false, antialias: false, depth: false });
      if (!gl || !(gl.getExtension('EXT_color_buffer_float') || gl.getExtension('EXT_color_buffer_half_float'))) return;
      const VERT = `#version 300 es
    in vec2 a;
    uniform vec2 px;
    out vec2 uv, l, r, t, b;
    void main() {
    uv = a * .5 + .5;
    l = uv - vec2(px.x, 0.); r = uv + vec2(px.x, 0.);
    t = uv + vec2(0., px.y); b = uv - vec2(0., px.y);
    gl_Position = vec4(a, 0., 1.);
    }`;
      const HEAD = '#version 300 es\nprecision highp float;\nprecision highp sampler2D;\nin vec2 uv, l, r, t, b;\nout vec4 o;\n';
      const rgb = c => c.map(v => (v / 255).toFixed(3)).join(', ');
      const SRC = {
        drop: 'uniform sampler2D src; uniform vec2 at; uniform float ratio, size, amt;\nvoid main() {\n  vec4 s = texture(src, uv); vec2 p = uv - at; p.x *= ratio;\n  float k = max(0., 1. - length(p) / size);\n  o = vec4(s.r + (.5 - .5 * cos(k * 3.14159)) * amt, s.g, 0., 1.);\n}',
        // cloth is stiff and heavy: a wave runs off and dies fast
        wave: 'uniform sampler2D src; uniform float fade;\nvoid main() {\n  vec4 s = texture(src, uv);\n  float avg = .25 * (texture(src, l).r + texture(src, r).r + texture(src, t).r + texture(src, b).r);\n  float v = (s.g + (avg - s.r) * 1.2) * fade;\n  o = vec4((s.r + v + (avg - s.r) * .12) * .996, v, 0., 1.);\n}',
        show: `uniform sampler2D wave; uniform vec2 wpx; uniform float now, ratio;
    const vec3 IVORY = vec3(${rgb(SILK.cloth)}), DEEP = vec3(${rgb(SILK.shade)}), SHEEN = vec3(${rgb(SILK.sheen)}), GLINT = vec3(${rgb(SILK.glint)});
    const vec2 DIR = normalize(vec2(1., .38));
    // the folds: long soft ridges running across the cloth, slowly breathing
    float folds(vec2 p) {
    float s = dot(p, DIR), q = dot(p, vec2(-DIR.y, DIR.x));
    // many long folds, each one wanders a little along its length; the crest is narrower than the hollow, like real cloth
    float w = q * 7.4 + 1.3 * sin(s * 1.1 + now * .05) + .55 * sin(s * 2.4 - q * .9 + 1.7) + .3 * sin(s * 4.1 + q * 1.7);
    float crest = pow(.5 + .5 * sin(w), 1.6);
    return crest + .18 * sin(w * 2.1 + s * 1.3 + now * .04) + .1 * sin(dot(p, vec2(.5, .86)) * 4.3 + 1.3);
    }
    float height(vec2 u) { return folds(u * vec2(ratio, 1.)) * ${FOLD.toFixed(3)} + texture(wave, u).r; }
    void main() {
    vec2 e = wpx * 1.5;
    float h = height(uv), hx = height(uv + vec2(e.x, 0.)) - height(uv - vec2(e.x, 0.)), hy = height(uv + vec2(0., e.y)) - height(uv - vec2(0., e.y));
    vec3 n = normalize(vec3(-hx / (2. * e.x * ratio), -hy / (2. * e.y), 1. / ${SOFT.toFixed(2)}));
    vec3 L = normalize(vec3(-.42, .58, .7)), H = normalize(L + vec3(0., 0., 1.));
    // satin: a broad soft sheen and a narrow line of light along the crest of each fold
    vec3 T = normalize(vec3(DIR, 0.) - n * dot(n, vec3(DIR, 0.)));
    float th = dot(T, H), along = pow(sqrt(max(1. - th * th, 0.)), 90.), broad = pow(max(dot(n, H), 0.), 8.);
    float diff = clamp(dot(n, L), 0., 1.), cave = smoothstep(.05, .85, h / ${FOLD.toFixed(3)});
    vec3 c = mix(DEEP, IVORY, pow(diff, 1.4) * .85 + .15) * mix(.62, 1., cave);
    c += SHEEN * broad * .3 + GLINT * along * .7 * (.25 + .75 * cave);
    o = vec4(c, 1.);
    }`,
      };
      const shader = (type, src) => { const s = gl.createShader(type); gl.shaderSource(s, src); gl.compileShader(s); return s; };
      const vs = shader(gl.VERTEX_SHADER, VERT);
      const P = {};
      for (const name in SRC) {
        const p = gl.createProgram();
        gl.attachShader(p, vs); gl.attachShader(p, shader(gl.FRAGMENT_SHADER, HEAD + SRC[name]));
        gl.bindAttribLocation(p, 0, 'a'); gl.linkProgram(p);
        if (!gl.getProgramParameter(p, gl.LINK_STATUS)) return;
        const u = {};
        for (let i = 0; i < gl.getProgramParameter(p, gl.ACTIVE_UNIFORMS); i++) { const n = gl.getActiveUniform(p, i).name; u[n] = gl.getUniformLocation(p, n); }
        P[name] = { p, u };
      }
      gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer());
      gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]), gl.STATIC_DRAW);
      gl.enableVertexAttribArray(0); gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);
      function target(w, h, id) {
        const tex = gl.createTexture();
        gl.activeTexture(gl.TEXTURE0 + id); gl.bindTexture(gl.TEXTURE_2D, tex);
        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
        gl.texImage2D(gl.TEXTURE_2D, 0, gl.RG16F, w, h, 0, gl.RG, gl.HALF_FLOAT, null);
        const fbo = gl.createFramebuffer();
        gl.bindFramebuffer(gl.FRAMEBUFFER, fbo); gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tex, 0);
        gl.viewport(0, 0, w, h); gl.clearColor(0, 0, 0, 1); gl.clear(gl.COLOR_BUFFER_BIT);
        return { id, fbo, w, h, px: [1 / w, 1 / h] };
      }
      let sea, ratio = 1;
      function build() {
        const w = host.clientWidth, h = host.clientHeight;
        if (!w || !h) return false;
        ratio = w / h;
        const k = Math.min(devicePixelRatio || 1, 2, Math.sqrt(SILK_PIXELS / (w * h)));
        cv.width = Math.round(w * k); cv.height = Math.round(h * k);
        const sh = Math.round(clamp(h / 5, 60, 170)), sw = Math.round(clamp(w / 5, 40, 380));
        const a = target(sw, sh, 0), b = target(sw, sh, 1);
        sea = { read: a, write: b, swap() { [sea.read, sea.write] = [sea.write, sea.read]; } };
        return gl.checkFramebufferStatus(gl.FRAMEBUFFER) === gl.FRAMEBUFFER_COMPLETE;
      }
      if (!build()) return;
      root.classList.add('ss-laid');
      function run(name, to, set) {
        const { p, u } = P[name];
        gl.useProgram(p);
        if (u.px) gl.uniform2f(u.px, ...(to ? to.px : [1 / cv.width, 1 / cv.height]));
        set(u);
        gl.bindFramebuffer(gl.FRAMEBUFFER, to ? to.fbo : null);
        gl.viewport(0, 0, to ? to.w : cv.width, to ? to.h : cv.height);
        gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
      }
      const presses = [];
      const press = (x, y, size, amt) => presses.push([x, y, size, amt]);
      let shown = true, running = false, last = 0, acc = 0, start = 0, palm = null, sweep = -1;
      function frame(now) {
        if (!shown || document.hidden) { running = false; return; }
        const t = now / 1000, dt = Math.min(t - last, .1); last = t;
        if (!start) start = t;
        // the palm keeps a soft dent where it rests on the cloth
        if (palm) press(palm[0], palm[1], SILK_PALM / host.clientHeight, -SILK_PRESS * dt * 2);
        // a slow fold runs across once when the page opens, and again when someone scrolls
        if (sweep >= 0) { for (let i = 0; i < 14; i++) press(sweep, (i + .5) / 14, .16, .008); sweep = sweep > 1.1 ? -1 : sweep + dt * .9; }
        while (presses.length) {
          const [x, y, size, amt] = presses.shift();
          run('drop', sea.write, u => { gl.uniform1i(u.src, sea.read.id); gl.uniform2f(u.at, x, y); gl.uniform1f(u.ratio, ratio); gl.uniform1f(u.size, size); gl.uniform1f(u.amt, amt); });
          sea.swap();
        }
        acc = Math.min(acc + dt * 100, 5);
        for (; acc >= 1; acc--) { run('wave', sea.write, u => { gl.uniform1i(u.src, sea.read.id); gl.uniform1f(u.fade, SILK_FADE); }); sea.swap(); }
        run('show', null, u => { gl.uniform1i(u.wave, sea.read.id); gl.uniform2f(u.wpx, ...sea.read.px); gl.uniform1f(u.now, t); gl.uniform1f(u.ratio, ratio); });
        requestAnimationFrame(frame);
      }
      const wake = () => { if (running || !shown || document.hidden) return; running = true; requestAnimationFrame(t => { last = t / 1000; frame(t); }); };
      const spot = e => { const r = cv.getBoundingClientRect(); return [(e.clientX - r.left) / r.width, 1 - (e.clientY - r.top) / r.height]; };
      let px = -1, py = -1, pt = 0;
      host.addEventListener('pointermove', e => {
        const [x, y] = spot(e), now = performance.now() / 1000;
        if (px >= 0) {
          const H = host.clientHeight, far = Math.hypot((x - px) * ratio, y - py) * H, speed = far / Math.max(now - pt, 1 / 120);
          // stroking the cloth: the faster the hand, the bigger the wave it pushes ahead
          if (far > 2) press(x, y, SILK_PALM * 1.4 / H, -Math.min(.02 + speed / 14000, .1) * SILK_PRESS * 3);
        }
        palm = e.pointerType === 'mouse' ? [x, y] : palm;
        px = x; py = y; pt = now;
      });
      host.addEventListener('pointerleave', () => { px = -1; palm = null; });
      host.addEventListener('pointercancel', () => { px = -1; palm = null; });
      // a touch presses a dent that springs back when the finger lifts
      host.addEventListener('pointerdown', e => {
        if (e.target.closest('a, button, input, textarea, label')) return;
        const [x, y] = spot(e);
        press(x, y, SILK_PALM * 1.6 / host.clientHeight, -SILK_PRESS * .5);
        if (e.pointerType !== 'mouse') palm = [x, y];
        px = x; py = y; pt = performance.now() / 1000;
      });
      host.addEventListener('pointerup', e => { if (e.pointerType !== 'mouse') palm = null; });
      let top = scrollY, lastSweep = 0;
      addEventListener('scroll', () => {
        const d = Math.abs(scrollY - top); top = scrollY;
        if (shown && d > 4 && sweep < 0 && last - lastSweep > 2) { sweep = 0; lastSweep = last; }
      }, { passive: true });
      cloths.push({
        host,
        fold(cx, cy) { const r = cv.getBoundingClientRect(); press((cx - r.left) / r.width, 1 - (cy - r.top) / r.height, .26, -SILK_PRESS * 6); },
      });
      new ResizeObserver(() => { if (cv.width && Math.abs(host.clientWidth / host.clientHeight - ratio) > .01) build(); }).observe(host);
      new IntersectionObserver(([e]) => { shown = e.isIntersecting; wake(); }).observe(cv);
      document.addEventListener('visibilitychange', wake);
      wake();
    });
    
    /* headlines: a fold runs along the line and the letters come out of the blur behind it */
    $$('.ss-fold').forEach(el => {
      if (reduce) return;
      el.innerHTML = el.textContent.trim().split(' ').map(w => `<span class="ss-wd">${[...w].map(c => `<span class="ss-ch">${c}</span>`).join('')}</span>`).join(' ');
      const chars = $$('.ss-ch', el), box = el.getBoundingClientRect();
      chars.forEach(c => { const r = c.getBoundingClientRect(); c.style.transitionDelay = `${Math.round(150 + (r.left - box.left) / Math.max(box.width, 1) * 900)}ms`; });
      requestAnimationFrame(() => requestAnimationFrame(() => chars.forEach(c => c.classList.add('ss-on'))));
    });
    
    /* a form that went through: one wide fold runs from its button; on the cloth it is a real wave */
    function fold(btn) {
      if (reduce) return;
      const r = btn.getBoundingClientRect(), x = r.left + r.width / 2, y = r.top + r.height / 2;
      const cloth = cloths.find(c => { const h = c.host.getBoundingClientRect(); return x > h.left && x < h.right && y > h.top && y < h.bottom; });
      if (cloth) { cloth.fold(x, y); return; }
      const cv = document.createElement('canvas'), c = cv.getContext('2d'), k = Math.min(devicePixelRatio || 1, 2);
      cv.className = 'ss-fold-ring'; cv.width = innerWidth * k; cv.height = innerHeight * k;
      root.append(cv);
      const far = Math.hypot(Math.max(x, innerWidth - x), Math.max(y, innerHeight - y)), t0 = performance.now();
      requestAnimationFrame(function run(now) {
        const u = clamp((now - t0) / 1700), rad = 20 + (1 - (1 - u) ** 3) * far, a = (1 - u) * .5;
        c.setTransform(k, 0, 0, k, 0, 0); c.clearRect(0, 0, innerWidth, innerHeight);
        // a fold is a soft light on its crest and a soft shade right behind it
        const g = c.createRadialGradient(x, y, Math.max(0, rad - 46), x, y, rad + 10);
        g.addColorStop(0, 'rgba(60, 40, 25, 0)'); g.addColorStop(.55, `rgba(60, 40, 25, ${(a * .35).toFixed(3)})`);
        g.addColorStop(.8, `rgba(255, 248, 238, ${a.toFixed(3)})`); g.addColorStop(1, 'rgba(255, 248, 238, 0)');
        c.fillStyle = g; c.beginPath(); c.arc(x, y, rad + 10, 0, Math.PI * 2); c.fill();
        if (u < 1) requestAnimationFrame(run); else cv.remove();
      });
    }
    
    /* the form: checks the fields, waits for the server, then one wide fold runs from the button */
    $$('.ss-form').forEach(form => {
      const btn = $('.ss-btn', form), note = $('.ss-note', form), fields = $$('.ss-field', form);
      form.addEventListener('submit', async e => {
        e.preventDefault();
        const bad = fields.find(f => !f.value.trim() || f.type === 'email' && !/^\S+@\S+\.\S+$/.test(f.value.trim()));
        fields.forEach(f => f.classList.toggle('ss-bad', f === bad));
        form.classList.toggle('ss-form-bad', !!bad);
        if (bad) {
          note.textContent = bad.type === 'email' && bad.value.trim() ? 'That does not look like an email. Try one like name@example.com.' : bad.dataset.need || 'Fill in this field first.';
          bad.focus();
          return;
        }
        btn.disabled = true; btn.textContent = form.dataset.busy || 'Sending';
        // a real server request goes here, for example:
        // await fetch('/api/login', { method: 'POST', body: new FormData(form) });
        await wait(700);
        fields.forEach(f => { f.disabled = true; });
        btn.textContent = form.dataset.label || 'Sent';
        form.classList.add('ss-sent');
        note.textContent = form.dataset.done || 'Thank you. We will write back soon.';
        fold(btn);
      });
      fields.forEach(f => f.addEventListener('input', () => { form.classList.remove('ss-form-bad'); f.classList.remove('ss-bad'); note.textContent = ''; }));
    });
    })();

Connect it to your backend

The form sends nothing until you connect it. Search for a real server request goes here, put your fetch() there and remove the timer on the next line.

Good to know

Tilda, Webflow, WordPress

Press Copy all code at the top and paste it into one HTML block.

Tilda

Add block, Other, T123 HTML code. Paste and save. Check the published page, the editor preview does not run scripts.

Webflow

Add panel, Embed. Paste, then Save & Close. Custom code runs on the published site.

WordPress

Add block, Custom HTML. Paste and press Update.

More in Sign in & forms

See all
Copied