Жидкие вкладки
Нижняя панель вкладок, где выделение это капля жидкости. Две пружины догоняют вкладку, передняя быстрее, и капля тянется между ними.
- Навигация
- Бесплатно
- svg filter
- spring
- Добавлен 14 сентября 2026
<style>
.app { position: relative; width: min(400px, 94vw); height: 480px; border-radius: 34px; overflow: hidden; isolation: isolate;
background: radial-gradient(circle at 50% 30%, rgba(60,110,255,.20), transparent 60%), #0B0D13;
box-shadow: inset 0 0 0 1px rgba(255,255,255,.09); }
/* the colour wash under the bar, it slides to the active tab so the glass has something to pick up */
.wash { position: absolute; left: 0; bottom: 0; width: 100%; height: 190px; pointer-events: none;
background: radial-gradient(180px 150px at var(--wx, 50%) 100%, var(--tint, #2C6BFF), transparent 70%); opacity: .34;
transition: background .45s ease, opacity .45s ease; }
.pages { position: absolute; inset: 24px 0 96px; }
.page { position: absolute; inset: 0; padding: 0 26px; opacity: 0; transform: translateY(26px); pointer-events: none; }
.page.on { opacity: 1; transform: none; pointer-events: auto; transition: opacity .32s cubic-bezier(.23, 1, .32, 1), transform .32s cubic-bezier(.23, 1, .32, 1); }
.page.out { opacity: 0; transform: translateY(-18px); transition: opacity .13s ease, transform .3s cubic-bezier(.23, 1, .32, 1); }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .06em; color: #A0AABE; }
h2 { margin: 6px 0 16px; font-size: 27px; letter-spacing: -.02em; }
.hero { height: 112px; border-radius: 20px; padding: 16px; box-sizing: border-box; display: flex; flex-direction: column; justify-content: flex-end;
background: linear-gradient(135deg, #2C6BFF, #6FA0FF); }
.hero small { font-size: 11px; font-weight: 600; letter-spacing: .06em; opacity: .75; }
.hero b { font-size: 17px; }
.field { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: 18px; background: rgba(255,255,255,.08); color: rgba(235,240,250,.6); font-size: 14px; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 18px; }
.grid i { height: 92px; border-radius: 16px; display: block; }
.row { display: flex; align-items: center; gap: 14px; margin-top: 14px; }
.row i { width: 40px; height: 40px; border-radius: 10px; flex: none; }
.row div { flex: 1; }
.row p { height: 7px; border-radius: 4px; background: rgba(235,240,250,.8); margin: 0 0 7px; }
.row p + p { width: 60%; background: rgba(235,240,250,.38); }
.row span { color: rgba(235,240,250,.45); }
.stats { display: flex; gap: 12px; margin-top: 22px; }
.stats div { flex: 1; padding: 12px 0; border-radius: 16px; background: rgba(255,255,255,.07); text-align: center; }
.stats b { display: block; font-size: 20px; }
.stats small { font-size: 11px; font-weight: 600; letter-spacing: .06em; color: #A0AABE; }
.me { display: flex; align-items: center; gap: 16px; }
.me i { width: 68px; height: 68px; border-radius: 50%; background: linear-gradient(135deg, #6FA0FF, #B07CFF); }
.me b { display: block; font-size: 22px; }
.me span { color: #A0AABE; font-size: 13px; }
/* the floating glass bar and the capsule inside it */
.bar, .pill {
backdrop-filter: blur(18px) saturate(180%);
background: rgba(150, 170, 205, 0.10);
}
.bar { position: absolute; left: 50%; bottom: 44px; transform: translateX(-50%); display: flex; width: 304px; height: 58px; padding: 0; border-radius: 29px;
box-shadow: 0 18px 40px -16px rgba(0,0,0,.8), inset 0 1px 0 rgba(255,255,255,.35); }
.pill { position: absolute; left: 0; top: 8px; width: 54px; height: 42px; border-radius: 21px; pointer-events: none;
background: rgba(10, 132, 255, .22); box-shadow: inset 0 1px 0 rgba(255,255,255,.5), 0 6px 18px -8px rgba(10,132,255,.9); }
.tab { flex: 1; border: 0; background: none; color: rgba(190,200,220,.62); display: grid; place-items: center; cursor: pointer;
transition: color .2s ease, transform .12s cubic-bezier(.23, 1, .32, 1); }
.tab:active { transform: scale(.9); }
.tab[aria-selected="true"] { color: #fff; }
.tab svg { width: 22px; height: 22px; }
.tab:focus-visible { outline: 2px solid #5AA9FF; outline-offset: -6px; border-radius: 20px; }
.label { position: absolute; left: 0; bottom: 18px; width: 100%; text-align: center; font-size: 12px; font-weight: 600; color: rgba(180,190,210,.75); }
@media (prefers-reduced-motion: reduce) {
.page.on, .page.out { transition: opacity .15s ease; transform: none; }
}
</style>
<div class="app">
<div class="wash"></div>
<div class="pages">
<section class="page on">
<div class="eyebrow">MONDAY 15 SEPTEMBER</div>
<h2>Today</h2>
<div class="hero"><small>FEATURED</small><b>Liquid glass, explained</b></div>
</section>
<section class="page">
<div class="field">🔍 Search effects</div>
<div class="grid">
<i style="background:linear-gradient(135deg,#38C98A,#6FE6C6)"></i>
<i style="background:linear-gradient(135deg,#B07CFF,#F08BD0)"></i>
<i style="background:linear-gradient(135deg,#FFB020,#FF7A45)"></i>
</div>
<div class="eyebrow" style="margin-top:18px">TRENDING</div>
</section>
<section class="page">
<h2 style="margin-top:0">Library</h2>
<div class="row"><i style="background:linear-gradient(135deg,#B07CFF,#F08BD0)"></i><div><p style="width:80%"></p><p></p></div><span>›</span></div>
<div class="row"><i style="background:linear-gradient(135deg,#FFB020,#FF7A45)"></i><div><p style="width:70%"></p><p></p></div><span>›</span></div>
<div class="row"><i style="background:linear-gradient(135deg,#2FC5E0,#7DE4FF)"></i><div><p style="width:60%"></p><p></p></div><span>›</span></div>
</section>
<section class="page">
<div class="me"><i></i><div><b>@codinvisual</b><span>Design engineer</span></div></div>
<div class="stats">
<div><b>128</b><small>EFFECTS</small></div>
<div><b>4.2k</b><small>STARS</small></div>
<div><b>96</b><small>FORKS</small></div>
</div>
</section>
</div>
<div class="bar" role="tablist" aria-label="Sections">
<div class="pill"></div>
<button class="tab" role="tab" aria-selected="true" aria-label="Today">
<svg viewBox="0 0 24 24" fill="currentColor"><path d="M3 11.5 12 4l9 7.5V21H3z"/></svg>
</button>
<button class="tab" role="tab" aria-selected="false" aria-label="Search">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><circle cx="11" cy="11" r="7"/><path d="m16.5 16.5 4 4"/></svg>
</button>
<button class="tab" role="tab" aria-selected="false" aria-label="Library">
<svg viewBox="0 0 24 24" fill="currentColor"><rect x="3" y="10" width="4" height="11" rx="2"/><rect x="10" y="4" width="4" height="17" rx="2"/><rect x="17" y="13" width="4" height="8" rx="2"/></svg>
</button>
<button class="tab" role="tab" aria-selected="false" aria-label="You">
<svg viewBox="0 0 24 24" fill="currentColor"><circle cx="12" cy="8" r="4"/><path d="M4 21c1.6-5 14.4-5 16 0z"/></svg>
</button>
</div>
<div class="label">Today</div>
</div>
<script>
const SPRING = { stiffness: 320, damping: 26 };
const STRETCH = 0.62;
const app = document.querySelector('.app');
const bar = app.querySelector('.bar');
const pill = app.querySelector('.pill');
const tabs = [...app.querySelectorAll('.tab')];
const pages = [...app.querySelectorAll('.page')];
const label = app.querySelector('.label');
const wash = app.querySelector('.wash');
const NAMES = ['Today', 'Search', 'Library', 'You'];
const TINT = ['#2C6BFF', '#38C98A', '#B07CFF', '#FF7A9A'];
const reduce = matchMedia('(prefers-reduced-motion: reduce)').matches;
// one spring per end of the capsule: the tail is softer, so the capsule stretches while it travels
const springs = () => ({
value: 0, velocity: 0, target: 0, cfg: SPRING,
to(x, cfg) { this.target = x; if (cfg) this.cfg = cfg; },
jump(x) { this.value = this.target = x; this.velocity = 0; },
step(dt) {
const { stiffness, damping } = this.cfg;
this.velocity += (stiffness * (this.target - this.value) - damping * this.velocity) * dt;
this.value += this.velocity * dt;
},
});
const head = springs(), tail = springs();
const centerOf = tab => tab.offsetLeft + tab.offsetWidth / 2 - bar.clientWidth / 2;
function select(i) {
const tab = tabs[i];
tabs.forEach((t, n) => t.setAttribute('aria-selected', n === i));
pages.forEach((p, n) => {
p.classList.toggle('on', n === i);
p.classList.toggle('out', n !== i);
});
label.textContent = NAMES[i];
wash.style.setProperty('--tint', TINT[i]);
wash.style.setProperty('--wx', (tab.offsetLeft + tab.offsetWidth / 2) / bar.clientWidth * 100 + '%');
head.to(centerOf(tab), SPRING);
tail.to(centerOf(tab), { ...SPRING,
stiffness: SPRING.stiffness * STRETCH });
if (reduce) { head.jump(centerOf(tab)); tail.jump(centerOf(tab)); draw(); }
}
function draw() {
const a = Math.min(head.value, tail.value), b = Math.max(head.value, tail.value);
const w = 54 + (b - a);
pill.style.width = w + 'px';
pill.style.transform = `translateX(${bar.clientWidth / 2 + (a + b) / 2 - w / 2}px)`;
}
let last = performance.now();
function frame(now) {
const dt = Math.min(1 / 30, (now - last) / 1000); last = now;
head.step(dt); tail.step(dt); draw();
requestAnimationFrame(frame);
}
tabs.forEach((tab, i) => tab.onclick = () => select(i));
bar.addEventListener('keydown', e => { // arrows move between tabs, like a real tab bar
const i = tabs.findIndex(t => t.getAttribute('aria-selected') === 'true');
if (e.key === 'ArrowRight') { tabs[(i + 1) % tabs.length].focus(); select((i + 1) % tabs.length); }
if (e.key === 'ArrowLeft') { tabs[(i + tabs.length - 1) % tabs.length].focus(); select((i + tabs.length - 1) % tabs.length); }
});
addEventListener('load', () => {
head.jump(centerOf(tabs[0])); tail.jump(centerOf(tabs[0]));
select(0); draw();
if (!reduce) requestAnimationFrame(frame);
});
</script>
Нажимайте на вкладки. Прыгните с первой на последнюю, так капля растянется сильнее всего.
Что можно поменять
Поменяйте число, сохраните файл и обновите страницу, разница будет видна сразу.
SPRING320 / 26Жёсткость и затухание передней части капли. Чем выше жёсткость, тем резче.
STRETCH0.6Насколько медленнее задняя часть капли. 0.3 тянется сильно, 1 не тянется совсем.
Как поставить на свой сайт
Поставьте внизу экрана приложения или в закреплённую шапку.
Комментарии в коде на английском, так файл понятен любому разработчику.
CSS
Вставьте в свой файл стилей или в тег <style> внутри <head>.
.app { position: relative; width: min(400px, 94vw); height: 480px; border-radius: 34px; overflow: hidden; isolation: isolate; background: radial-gradient(circle at 50% 30%, rgba(60,110,255,.20), transparent 60%), #0B0D13; box-shadow: inset 0 0 0 1px rgba(255,255,255,.09); } /* the colour wash under the bar, it slides to the active tab so the glass has something to pick up */ .wash { position: absolute; left: 0; bottom: 0; width: 100%; height: 190px; pointer-events: none; background: radial-gradient(180px 150px at var(--wx, 50%) 100%, var(--tint, #2C6BFF), transparent 70%); opacity: .34; transition: background .45s ease, opacity .45s ease; } .pages { position: absolute; inset: 24px 0 96px; } .page { position: absolute; inset: 0; padding: 0 26px; opacity: 0; transform: translateY(26px); pointer-events: none; } .page.on { opacity: 1; transform: none; pointer-events: auto; transition: opacity .32s cubic-bezier(.23, 1, .32, 1), transform .32s cubic-bezier(.23, 1, .32, 1); } .page.out { opacity: 0; transform: translateY(-18px); transition: opacity .13s ease, transform .3s cubic-bezier(.23, 1, .32, 1); } .eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .06em; color: #A0AABE; } h2 { margin: 6px 0 16px; font-size: 27px; letter-spacing: -.02em; } .hero { height: 112px; border-radius: 20px; padding: 16px; box-sizing: border-box; display: flex; flex-direction: column; justify-content: flex-end; background: linear-gradient(135deg, #2C6BFF, #6FA0FF); } .hero small { font-size: 11px; font-weight: 600; letter-spacing: .06em; opacity: .75; } .hero b { font-size: 17px; } .field { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: 18px; background: rgba(255,255,255,.08); color: rgba(235,240,250,.6); font-size: 14px; } .grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 18px; } .grid i { height: 92px; border-radius: 16px; display: block; } .row { display: flex; align-items: center; gap: 14px; margin-top: 14px; } .row i { width: 40px; height: 40px; border-radius: 10px; flex: none; } .row div { flex: 1; } .row p { height: 7px; border-radius: 4px; background: rgba(235,240,250,.8); margin: 0 0 7px; } .row p + p { width: 60%; background: rgba(235,240,250,.38); } .row span { color: rgba(235,240,250,.45); } .stats { display: flex; gap: 12px; margin-top: 22px; } .stats div { flex: 1; padding: 12px 0; border-radius: 16px; background: rgba(255,255,255,.07); text-align: center; } .stats b { display: block; font-size: 20px; } .stats small { font-size: 11px; font-weight: 600; letter-spacing: .06em; color: #A0AABE; } .me { display: flex; align-items: center; gap: 16px; } .me i { width: 68px; height: 68px; border-radius: 50%; background: linear-gradient(135deg, #6FA0FF, #B07CFF); } .me b { display: block; font-size: 22px; } .me span { color: #A0AABE; font-size: 13px; } /* the floating glass bar and the capsule inside it */ .bar, .pill { backdrop-filter: blur(18px) saturate(180%); background: rgba(150, 170, 205, 0.10); } .bar { position: absolute; left: 50%; bottom: 44px; transform: translateX(-50%); display: flex; width: 304px; height: 58px; padding: 0; border-radius: 29px; box-shadow: 0 18px 40px -16px rgba(0,0,0,.8), inset 0 1px 0 rgba(255,255,255,.35); } .pill { position: absolute; left: 0; top: 8px; width: 54px; height: 42px; border-radius: 21px; pointer-events: none; background: rgba(10, 132, 255, .22); box-shadow: inset 0 1px 0 rgba(255,255,255,.5), 0 6px 18px -8px rgba(10,132,255,.9); } .tab { flex: 1; border: 0; background: none; color: rgba(190,200,220,.62); display: grid; place-items: center; cursor: pointer; transition: color .2s ease, transform .12s cubic-bezier(.23, 1, .32, 1); } .tab:active { transform: scale(.9); } .tab[aria-selected="true"] { color: #fff; } .tab svg { width: 22px; height: 22px; } .tab:focus-visible { outline: 2px solid #5AA9FF; outline-offset: -6px; border-radius: 20px; } .label { position: absolute; left: 0; bottom: 18px; width: 100%; text-align: center; font-size: 12px; font-weight: 600; color: rgba(180,190,210,.75); } @media (prefers-reduced-motion: reduce) { .page.on, .page.out { transition: opacity .15s ease; transform: none; } }HTML
Поставьте в то место страницы, где должен быть эффект.
<div class="app"> <div class="wash"></div> <div class="pages"> <section class="page on"> <div class="eyebrow">MONDAY 15 SEPTEMBER</div> <h2>Today</h2> <div class="hero"><small>FEATURED</small><b>Liquid glass, explained</b></div> </section> <section class="page"> <div class="field">🔍 Search effects</div> <div class="grid"> <i style="background:linear-gradient(135deg,#38C98A,#6FE6C6)"></i> <i style="background:linear-gradient(135deg,#B07CFF,#F08BD0)"></i> <i style="background:linear-gradient(135deg,#FFB020,#FF7A45)"></i> </div> <div class="eyebrow" style="margin-top:18px">TRENDING</div> </section> <section class="page"> <h2 style="margin-top:0">Library</h2> <div class="row"><i style="background:linear-gradient(135deg,#B07CFF,#F08BD0)"></i><div><p style="width:80%"></p><p></p></div><span>›</span></div> <div class="row"><i style="background:linear-gradient(135deg,#FFB020,#FF7A45)"></i><div><p style="width:70%"></p><p></p></div><span>›</span></div> <div class="row"><i style="background:linear-gradient(135deg,#2FC5E0,#7DE4FF)"></i><div><p style="width:60%"></p><p></p></div><span>›</span></div> </section> <section class="page"> <div class="me"><i></i><div><b>@codinvisual</b><span>Design engineer</span></div></div> <div class="stats"> <div><b>128</b><small>EFFECTS</small></div> <div><b>4.2k</b><small>STARS</small></div> <div><b>96</b><small>FORKS</small></div> </div> </section> </div> <div class="bar" role="tablist" aria-label="Sections"> <div class="pill"></div> <button class="tab" role="tab" aria-selected="true" aria-label="Today"> <svg viewBox="0 0 24 24" fill="currentColor"><path d="M3 11.5 12 4l9 7.5V21H3z"/></svg> </button> <button class="tab" role="tab" aria-selected="false" aria-label="Search"> <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><circle cx="11" cy="11" r="7"/><path d="m16.5 16.5 4 4"/></svg> </button> <button class="tab" role="tab" aria-selected="false" aria-label="Library"> <svg viewBox="0 0 24 24" fill="currentColor"><rect x="3" y="10" width="4" height="11" rx="2"/><rect x="10" y="4" width="4" height="17" rx="2"/><rect x="17" y="13" width="4" height="8" rx="2"/></svg> </button> <button class="tab" role="tab" aria-selected="false" aria-label="You"> <svg viewBox="0 0 24 24" fill="currentColor"><circle cx="12" cy="8" r="4"/><path d="M4 21c1.6-5 14.4-5 16 0z"/></svg> </button> </div> <div class="label">Today</div> </div>JavaScript
Вставьте перед закрывающим тегом </body>, внутри <script></script>.
const SPRING = { stiffness: 320, damping: 26 }; const STRETCH = 0.62; const app = document.querySelector('.app'); const bar = app.querySelector('.bar'); const pill = app.querySelector('.pill'); const tabs = [...app.querySelectorAll('.tab')]; const pages = [...app.querySelectorAll('.page')]; const label = app.querySelector('.label'); const wash = app.querySelector('.wash'); const NAMES = ['Today', 'Search', 'Library', 'You']; const TINT = ['#2C6BFF', '#38C98A', '#B07CFF', '#FF7A9A']; const reduce = matchMedia('(prefers-reduced-motion: reduce)').matches; // one spring per end of the capsule: the tail is softer, so the capsule stretches while it travels const springs = () => ({ value: 0, velocity: 0, target: 0, cfg: SPRING, to(x, cfg) { this.target = x; if (cfg) this.cfg = cfg; }, jump(x) { this.value = this.target = x; this.velocity = 0; }, step(dt) { const { stiffness, damping } = this.cfg; this.velocity += (stiffness * (this.target - this.value) - damping * this.velocity) * dt; this.value += this.velocity * dt; }, }); const head = springs(), tail = springs(); const centerOf = tab => tab.offsetLeft + tab.offsetWidth / 2 - bar.clientWidth / 2; function select(i) { const tab = tabs[i]; tabs.forEach((t, n) => t.setAttribute('aria-selected', n === i)); pages.forEach((p, n) => { p.classList.toggle('on', n === i); p.classList.toggle('out', n !== i); }); label.textContent = NAMES[i]; wash.style.setProperty('--tint', TINT[i]); wash.style.setProperty('--wx', (tab.offsetLeft + tab.offsetWidth / 2) / bar.clientWidth * 100 + '%'); head.to(centerOf(tab), SPRING); tail.to(centerOf(tab), { ...SPRING, stiffness: SPRING.stiffness * STRETCH }); if (reduce) { head.jump(centerOf(tab)); tail.jump(centerOf(tab)); draw(); } } function draw() { const a = Math.min(head.value, tail.value), b = Math.max(head.value, tail.value); const w = 54 + (b - a); pill.style.width = w + 'px'; pill.style.transform = `translateX(${bar.clientWidth / 2 + (a + b) / 2 - w / 2}px)`; } let last = performance.now(); function frame(now) { const dt = Math.min(1 / 30, (now - last) / 1000); last = now; head.step(dt); tail.step(dt); draw(); requestAnimationFrame(frame); } tabs.forEach((tab, i) => tab.onclick = () => select(i)); bar.addEventListener('keydown', e => { // arrows move between tabs, like a real tab bar const i = tabs.findIndex(t => t.getAttribute('aria-selected') === 'true'); if (e.key === 'ArrowRight') { tabs[(i + 1) % tabs.length].focus(); select((i + 1) % tabs.length); } if (e.key === 'ArrowLeft') { tabs[(i + tabs.length - 1) % tabs.length].focus(); select((i + tabs.length - 1) % tabs.length); } }); addEventListener('load', () => { head.jump(centerOf(tabs[0])); tail.jump(centerOf(tabs[0])); select(0); draw(); if (!reduce) requestAnimationFrame(frame); });
Подключение к серверу
Найдите в обработчике клика строку your page switch goes here и показывайте там содержимое выбранной вкладки.
Tilda, Webflow, WordPress
Нажмите «Скопировать весь код» вверху и вставьте его в один HTML-блок.
Добавить блок, Другое, T123 HTML-код. Вставьте и сохраните. Проверяйте на опубликованной странице, в редакторе скрипты не запускаются.
Панель Add, Embed. Вставьте и нажмите Save & Close. Свой код работает на опубликованном сайте.
Добавить блок, Произвольный HTML. Вставьте и нажмите «Обновить».



