01Panel slide toggle — a basic panel interpolating position from an open state
Once the panel is in its open state, its off-screen horizontal position interpolates in to its on-screen value, and the closed state retraces the same value in reverse.
Best forA shopping site's left-side product filter panel, a search-results condition panel
transformclassList.toggletransition

<main class="stage" id="stage">
<button class="trigger" id="trigger" type="button" aria-expanded="false" aria-controls="panel">
Open filters
</button>
<aside class="panel is-demo" id="panel" aria-hidden="true">
<p class="panel__title">Filter</p>
<div class="panel__row">
<span class="chip">Color</span>
<span class="chip">Size</span>
</div>
<div class="panel__row">
<span class="chip">Price range</span>
<span class="chip">Material</span>
</div>
</aside>
</main>@use "../../../../site/static/demo-tokens" as *;
$duration: $dur-enter;
$easing: $ease-spring;
$color: $subject-cream;
@include stage($stage-ink);
.stage {
position: relative;
overflow: hidden;
}
.trigger {
border: 0;
border-radius: $r-pill;
padding: $sp-3 $sp-6;
font-family: inherit;
font-weight: 600;
font-size: clamp(13px, 4vmin, 16px);
line-height: 1;
color: $stage-ink;
background: $color;
cursor: pointer;
}
.panel {
box-sizing: border-box;
position: absolute;
left: 0;
top: 0;
bottom: 0;
width: min(64vw, 200px);
padding: $sp-6 $sp-4;
display: flex;
flex-direction: column;
gap: $sp-3;
background: $color;
color: $stage-ink;
box-shadow: $shadow-raised;
transform: translateX(-100%);
transition: transform $duration $easing;
}
.panel__title {
margin: 0;
font-weight: 600;
font-size: 14px;
line-height: 1.2;
}
.panel__row {
display: flex;
gap: $sp-2;
flex-wrap: wrap;
}
.chip {
padding: $sp-1 $sp-3;
border-radius: $r-pill;
background: rgba($stage-ink, .1);
font-weight: 500;
font-size: 11px;
line-height: 1.4;
}
.stage.is-open .panel {
transform: translateX(0);
}
.panel.is-demo {
animation-name: panel-loop;
animation-duration: $dur-loop;
animation-timing-function: $easing;
animation-iteration-count: infinite;
}
@keyframes panel-loop {
0%, 100% { transform: translateX(-100%); }
18%, 72% { transform: translateX(0); }
90% { transform: translateX(-100%); }
}
@media (max-width: 340px) {
.panel { width: 78vw; padding: $sp-4 $sp-3; gap: $sp-2; }
.trigger { padding: $sp-2 $sp-4; }
}
@media (prefers-reduced-motion: reduce) {
.panel { transition: none; }
.panel.is-demo { animation: none; transform: translateX(0); opacity: .96; }
}html, body {
margin: 0;
overflow: hidden;
}
.stage {
box-sizing: border-box;
min-height: 100vh;
display: grid;
place-items: center;
margin: 0;
background: #17141a;
font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
padding: clamp(8px, 4vw, 24px);
}
.stage {
position: relative;
overflow: hidden;
}
.trigger {
border: 0;
border-radius: 999px;
padding: 12px 24px;
font-family: inherit;
font-weight: 600;
font-size: clamp(13px, 4vmin, 16px);
line-height: 1;
color: #17141a;
background: #fff7e6;
cursor: pointer;
}
.panel {
box-sizing: border-box;
position: absolute;
left: 0;
top: 0;
bottom: 0;
width: min(64vw, 200px);
padding: 24px 16px;
display: flex;
flex-direction: column;
gap: 12px;
background: #fff7e6;
color: #17141a;
box-shadow: 0 14px 24px rgba(23, 20, 26, 0.32);
transform: translateX(-100%);
transition: transform 600ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.panel__title {
margin: 0;
font-weight: 600;
font-size: 14px;
line-height: 1.2;
}
.panel__row {
display: flex;
gap: 8px;
flex-wrap: wrap;
}
.chip {
padding: 4px 12px;
border-radius: 999px;
background: rgba(23, 20, 26, 0.1);
font-weight: 500;
font-size: 11px;
line-height: 1.4;
}
.stage.is-open .panel {
transform: translateX(0);
}
.panel.is-demo {
animation-name: panel-loop;
animation-duration: 2s;
animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1);
animation-iteration-count: infinite;
}
@keyframes panel-loop {
0%, 100% {
transform: translateX(-100%);
}
18%, 72% {
transform: translateX(0);
}
90% {
transform: translateX(-100%);
}
}
@media (max-width: 340px) {
.panel {
width: 78vw;
padding: 16px 12px;
gap: 8px;
}
.trigger {
padding: 8px 16px;
}
}
@media (prefers-reduced-motion: reduce) {
.panel {
transition: none;
}
.panel.is-demo {
animation: none;
transform: translateX(0);
opacity: 0.96;
}
}// Filter 패널 열림·닫힘을 하나의 불(boolean) 값으로만 들고, 그 값을 transform 위치(0 또는 -100%)로 바꿔 CSS transition 이 보간한다.
// 계산 겹: 열림 여부 → translateX 보간(transition). 실사용 클릭 리스너 있음.
(function () {
var stage = document.getElementById('stage');
var trigger = document.getElementById('trigger');
var panel = document.getElementById('panel');
if (!stage || !trigger || !panel) return;
function setOpen(open) {
stage.classList.toggle('is-open', open);
trigger.setAttribute('aria-expanded', String(open));
panel.setAttribute('aria-hidden', String(!open));
}
trigger.addEventListener('click', function () {
panel.classList.remove('is-demo');
setOpen(!stage.classList.contains('is-open'));
});
})();import { useEffect, useRef } from "react";
import styles from "./PanelSlideToggle.module.scss";
// 필터 패널 열림닫힘을 하나의 불(boolean) 값으로만 들고, 그 값을 transform 위치(0 또는 -100%)로 바꿔 CSS transition 이 보간한다.
// 계산 겹: 열림 여부 -> translateX 보간(transition). 실사용 클릭 리스너 있음.
export default function PanelSlideToggle() {
const stageRef = useRef<HTMLElement>(null);
const triggerRef = useRef<HTMLButtonElement>(null);
const panelRef = useRef<HTMLElement>(null);
useEffect(() => {
const stage = stageRef.current;
const trigger = triggerRef.current;
const panel = panelRef.current;
if (!stage || !trigger || !panel) return;
function setOpen(open: boolean) {
stage!.classList.toggle(styles["is-open"], open);
trigger!.setAttribute("aria-expanded", String(open));
panel!.setAttribute("aria-hidden", String(!open));
}
function onClick() {
panel!.classList.remove(styles["is-demo"]);
setOpen(!stage!.classList.contains(styles["is-open"]));
}
trigger.addEventListener("click", onClick);
return () => {
trigger.removeEventListener("click", onClick);
};
}, []);
return (
<main ref={stageRef} className={styles.stage}>
<button
ref={triggerRef}
className={styles.trigger}
type="button"
aria-expanded="false"
aria-controls="panel"
>
필터 열기
</button>
<aside ref={panelRef} className={`${styles.panel} ${styles["is-demo"]}`} aria-hidden="true">
<p className={styles.panel__title}>필터</p>
<div className={styles.panel__row}>
<span className={styles.chip}>색상</span>
<span className={styles.chip}>사이즈</span>
</div>
<div className={styles.panel__row}>
<span className={styles.chip}>가격대</span>
<span className={styles.chip}>소재</span>
</div>
</aside>
</main>
);
}01 Panel slide toggle — a basic panel interpolating position from an open state — Measured area 41.968% · moving frames 10/23Original by GODRICH · SCSS and React ship in the zip · 9 Filter UI Patterns (Panel Slide to Chip Remove)
The post this demo lives in
9 Filter UI Patterns (Panel Slide to Chip Remove)Filter ui hides several small jobs. One of nine recomputes chip-row width once a chip disappears, one scales a badge by See all demos in this post
If you like this effect - similar demos
Transitions01 Slide overshoot — a cart panel whose open position value passes its target before settling backCart Drawer UI Patterns: 9 Motion Techniques
Transitions01 Active-indicator slide-morph toggle — when the selected tab changes, the highlight's position and width values shift together from the old spot to the new oneCSS Bottom Navigation Bar: 9 Transition Patterns
Transitions08 Circle reveal from the icon9 CSS Hamburger Menu Animations, No Library