06Filter chips clearing one by one
Three active filter chips cut out from the left 180ms apart, and the clear-filters pill in the panel below rises just as they go.
Best forFor a list that is empty because of filters, not because of missing data, so the reader can undo them
scaleXsteps(1, end)animation-delay

<main class="stage">
<section class="fc is-demo">
<ul class="fc__chips" id="fc-chips">
<li><button class="fc__chip" type="button" data-chip="1">Free shipping<span class="fc__x" aria-hidden="true">×</span><span class="fc__sr">Remove filter</span></button></li>
<li><button class="fc__chip" type="button" data-chip="2">Under 50,000 KRW<span class="fc__x" aria-hidden="true">×</span><span class="fc__sr">Remove filter</span></button></li>
<li><button class="fc__chip" type="button" data-chip="3">Ships today<span class="fc__x" aria-hidden="true">×</span><span class="fc__sr">Remove filter</span></button></li>
</ul>
<div class="fc__panel">
<ul class="fc__rows" id="fc-rows" hidden>
<li class="fc__row">Candle holder</li>
<li class="fc__row">Linen curtain</li>
<li class="fc__row">Wooden tray</li>
</ul>
<div class="fc__empty" id="fc-empty">
<span class="fc__icon" aria-hidden="true"><svg viewBox="0 0 256 256" width="1em" height="1em"><g fill="currentColor"><path d="M221.9 61.38L152 136v58.65a8 8 0 0 1-3.56 6.66l-32 21.33A8 8 0 0 1 104 216v-80L34.1 61.38A8 8 0 0 1 40 48h176a8 8 0 0 1 5.9 13.38" opacity=".2"/><path d="M230.6 49.53A15.81 15.81 0 0 0 216 40H40a16 16 0 0 0-11.81 26.76l.08.09L96 139.17V216a16 16 0 0 0 24.87 13.32l32-21.34a16 16 0 0 0 7.13-13.32v-55.49l67.74-72.32l.08-.09a15.8 15.8 0 0 0 2.78-17.23m-84.42 81.05A8 8 0 0 0 144 136v58.66L112 216v-80a8 8 0 0 0-2.16-5.47L40 56h176Z"/></g></svg></span>
<p class="fc__msg" id="fc-msg" data-fmt="{n} filters · 0 items match" aria-live="polite">0 items match</p>
<button class="fc__clear" type="button" id="fc-clear">Clear filters</button>
</div>
</div>
</section>
</main>@use "../../../../site/static/demo-tokens" as *;
$duration: $dur-loop;
$easing: $ease-pop;
$color: $subject-ink;
@include stage($stage-yellow);
.fc {
box-sizing: border-box;
width: min(248px, 86vw);
display: flex;
flex-direction: column;
gap: $sp-2;
font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
color: $color;
}
.fc__chips {
margin: 0;
padding: 0;
list-style: none;
display: flex;
flex-wrap: wrap;
gap: $sp-1;
min-height: 22px;
}
.fc__chips li[hidden] { display: none; }
.fc__chip {
position: relative;
height: 22px;
margin: 0;
padding: 0 $sp-2;
display: inline-flex;
align-items: center;
gap: $sp-1;
border: 1px solid rgba(23, 20, 26, .2);
border-radius: $r-pill;
background: rgba(255, 255, 255, .82);
color: $color;
font-family: inherit;
font-size: 10px;
font-weight: 700;
cursor: pointer;
transform-origin: left center; // 규칙8: 칩 left변으로 꺼짐
}
.fc__chip:focus-visible { outline: 2px solid $color; outline-offset: 2px; }
.fc__x {
font-size: 11px;
line-height: 1;
color: rgba(23, 20, 26, .72); // AA 4.5 (blog-design)
}
.fc__sr {
position: absolute;
width: 1px;
height: 1px;
overflow: hidden;
clip-path: inset(50%);
white-space: nowrap;
}
.fc__panel {
position: relative;
box-sizing: border-box;
height: 88px;
padding: $sp-2;
border-radius: $r-card;
background: rgba(255, 255, 255, .52);
overflow: hidden;
}
.fc__rows {
margin: 0;
padding: 0;
list-style: none;
display: flex;
flex-direction: column;
gap: $sp-2;
}
.fc__rows[hidden] { display: none; }
.fc__row {
height: 20px;
padding: 0 $sp-2;
display: flex;
align-items: center;
border-radius: $r-sm;
background: rgba(255, 255, 255, .86);
font-size: 11px;
font-weight: 600;
}
.fc__empty {
position: absolute;
inset: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: $sp-1;
}
.fc__empty[hidden] { display: none; }
.fc__icon {
display: block;
font-size: 26px;
line-height: 0;
color: rgba(23, 20, 26, .62);
}
.fc__msg {
margin: 0;
font-size: 10px;
line-height: 12px;
font-weight: 700;
}
.fc__clear {
height: 22px;
margin: 0;
padding: 0 $sp-3;
border: 0;
border-radius: $r-pill;
background: $color;
color: $subject-cream;
font-family: inherit;
font-size: 10px;
font-weight: 700;
cursor: pointer;
}
.fc__clear:focus-visible { outline: 2px solid $color; outline-offset: 2px; }
// ── 자동 루프: 칩이 왼쪽부터 차례로 꺼졌다 켜진다. 사라짐은 steps(1,end) 로 한 프레임에 컷 ──
.fc.is-demo .fc__chip { animation: fc-off $duration steps(1, end) infinite; }
.fc.is-demo li:nth-child(2) .fc__chip { animation-delay: 180ms; }
.fc.is-demo li:nth-child(3) .fc__chip { animation-delay: 360ms; }
@keyframes fc-off {
0%, 32% { opacity: 1; transform: scaleX(1); }
33%, 74% { opacity: 0; transform: scaleX(.2); }
75%, 100% { opacity: 1; transform: scaleX(1); }
}
.fc.is-demo .fc__clear { animation: fc-call $duration $easing infinite; }
@keyframes fc-call {
0%, 44% { transform: translateY(4px) scale(.86); opacity: 0; }
58%, 70% { transform: translateY(0) scale(1); opacity: 1; }
84%, 100% { transform: translateY(4px) scale(.86); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
.fc.is-demo .fc__chip,
.fc.is-demo .fc__clear { animation: none !important; }
}html, body {
margin: 0;
overflow: hidden;
}
.stage {
box-sizing: border-box;
min-height: 100vh;
display: grid;
place-items: center;
margin: 0;
background: #ffd23f;
font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
padding: clamp(8px, 4vw, 24px);
}
.fc {
box-sizing: border-box;
width: min(248px, 86vw);
display: flex;
flex-direction: column;
gap: 8px;
font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
color: #17141a;
}
.fc__chips {
margin: 0;
padding: 0;
list-style: none;
display: flex;
flex-wrap: wrap;
gap: 4px;
min-height: 22px;
}
.fc__chips li[hidden] {
display: none;
}
.fc__chip {
position: relative;
height: 22px;
margin: 0;
padding: 0 8px;
display: inline-flex;
align-items: center;
gap: 4px;
border: 1px solid rgba(23, 20, 26, 0.2);
border-radius: 999px;
background: rgba(255, 255, 255, 0.82);
color: #17141a;
font-family: inherit;
font-size: 10px;
font-weight: 700;
cursor: pointer;
transform-origin: left center;
}
.fc__chip:focus-visible {
outline: 2px solid #17141a;
outline-offset: 2px;
}
.fc__x {
font-size: 11px;
line-height: 1;
color: rgba(23, 20, 26, 0.72);
}
.fc__sr {
position: absolute;
width: 1px;
height: 1px;
overflow: hidden;
clip-path: inset(50%);
white-space: nowrap;
}
.fc__panel {
position: relative;
box-sizing: border-box;
height: 88px;
padding: 8px;
border-radius: 16px;
background: rgba(255, 255, 255, 0.52);
overflow: hidden;
}
.fc__rows {
margin: 0;
padding: 0;
list-style: none;
display: flex;
flex-direction: column;
gap: 8px;
}
.fc__rows[hidden] {
display: none;
}
.fc__row {
height: 20px;
padding: 0 8px;
display: flex;
align-items: center;
border-radius: 8px;
background: rgba(255, 255, 255, 0.86);
font-size: 11px;
font-weight: 600;
}
.fc__empty {
position: absolute;
inset: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 4px;
}
.fc__empty[hidden] {
display: none;
}
.fc__icon {
display: block;
font-size: 26px;
line-height: 0;
color: rgba(23, 20, 26, 0.62);
}
.fc__msg {
margin: 0;
font-size: 10px;
line-height: 12px;
font-weight: 700;
}
.fc__clear {
height: 22px;
margin: 0;
padding: 0 12px;
border: 0;
border-radius: 999px;
background: #17141a;
color: #fff7e6;
font-family: inherit;
font-size: 10px;
font-weight: 700;
cursor: pointer;
}
.fc__clear:focus-visible {
outline: 2px solid #17141a;
outline-offset: 2px;
}
.fc.is-demo .fc__chip {
animation: fc-off 2s steps(1, end) infinite;
}
.fc.is-demo li:nth-child(2) .fc__chip {
animation-delay: 180ms;
}
.fc.is-demo li:nth-child(3) .fc__chip {
animation-delay: 360ms;
}
@keyframes fc-off {
0%, 32% {
opacity: 1;
transform: scaleX(1);
}
33%, 74% {
opacity: 0;
transform: scaleX(0.2);
}
75%, 100% {
opacity: 1;
transform: scaleX(1);
}
}
.fc.is-demo .fc__clear {
animation: fc-call 2s cubic-bezier(0.2, 1.4, 0.4, 1) infinite;
}
@keyframes fc-call {
0%, 44% {
transform: translateY(4px) scale(0.86);
opacity: 0;
}
58%, 70% {
transform: translateY(0) scale(1);
opacity: 1;
}
84%, 100% {
transform: translateY(4px) scale(0.86);
opacity: 0;
}
}
@media (prefers-reduced-motion: reduce) {
.fc.is-demo .fc__chip,
.fc.is-demo .fc__clear {
animation: none !important;
}
}// 실제 동작: 칩의 x 로 조건을 하나씩 뗀다. 셋 다 떼면 목록이 돌아오고, 남아 있으면 0건 카드가 나온다.
var card = document.querySelector('.fc');
var chips = [].slice.call(document.querySelectorAll('.fc__chip'));
var rows = document.getElementById('fc-rows');
var empty = document.getElementById('fc-empty');
var msg = document.getElementById('fc-msg');
var clear = document.getElementById('fc-clear');
function paint() {
var left = chips.filter(function (c) { return !c.parentElement.hidden; }).length;
rows.hidden = left > 0;
empty.hidden = left === 0;
msg.textContent = msg.dataset.fmt.replace('{n}', left);
}
chips.forEach(function (c) {
c.addEventListener('click', function () {
card.classList.remove('is-demo');
c.parentElement.hidden = true;
paint();
});
});
clear.addEventListener('click', function () {
card.classList.remove('is-demo');
chips.forEach(function (c) { c.parentElement.hidden = false; });
paint();
});import { useState } from "react";
import type { CSSProperties } from "react";
import styles from "./FilterClearedCard.module.scss";
export type FilterClearedCardProps = {
filters?: string[];
rows?: string[];
removeLabel?: string;
fmt?: string;
clearLabel?: string;
duration?: number;
easing?: string;
color?: string;
};
type Vars = CSSProperties & { "--duration"?: string; "--easing"?: string; "--color"?: string };
export default function FilterClearedCard({
filters = ["Free shipping", "Under 50,000 KRW", "Ships today"],
rows = ["Candle holder", "Linen curtain", "Wooden tray"],
removeLabel = "Remove filter",
fmt = "{n} filters · 0 items match",
clearLabel = "Clear filters",
duration = 2000,
easing = "cubic-bezier(.2,1.4,.4,1)",
color = "#17141a",
}: FilterClearedCardProps) {
const [on, setOn] = useState(filters.map(() => true));
const [loop, setLoop] = useState(true);
const vars: Vars = { "--duration": `${duration}ms`, "--easing": easing, "--color": color };
const left = on.filter(Boolean).length;
function drop(i: number) {
setLoop(false);
setOn(on.map((v, k) => (k === i ? false : v)));
}
return (
<section className={`${styles.fc} ${loop ? styles.isDemo : ""}`} style={vars}>
<ul className={styles.chips}>
{filters.map((f, i) => on[i] && (
<li key={f}>
<button className={styles.chip} type="button" onClick={() => drop(i)}>
{f}
<span className={styles.x} aria-hidden="true">×</span>
<span className={styles.sr}>{removeLabel}</span>
</button>
</li>
))}
</ul>
<div className={styles.panel}>
{left === 0 ? (
<ul className={styles.rows}>
{rows.map((r) => <li className={styles.row} key={r}>{r}</li>)}
</ul>
) : (
<div className={styles.empty}>
<span className={styles.icon} aria-hidden="true">
<svg viewBox="0 0 256 256" width="1em" height="1em">
<g fill="currentColor">
<path d="M221.9 61.38L152 136v58.65a8 8 0 0 1-3.56 6.66l-32 21.33A8 8 0 0 1 104 216v-80L34.1 61.38A8 8 0 0 1 40 48h176a8 8 0 0 1 5.9 13.38" opacity=".2" />
<path d="M230.6 49.53A15.81 15.81 0 0 0 216 40H40a16 16 0 0 0-11.81 26.76l.08.09L96 139.17V216a16 16 0 0 0 24.87 13.32l32-21.34a16 16 0 0 0 7.13-13.32v-55.49l67.74-72.32l.08-.09a15.8 15.8 0 0 0 2.78-17.23m-84.42 81.05A8 8 0 0 0 144 136v58.66L112 216v-80a8 8 0 0 0-2.16-5.47L40 56h176Z" />
</g>
</svg>
</span>
<p className={styles.msg} aria-live="polite">{fmt.replace("{n}", String(left))}</p>
<button
className={styles.clear}
type="button"
onClick={() => { setLoop(false); setOn(filters.map(() => false)); }}
>
{clearLabel}
</button>
</div>
)}
</div>
</section>
);
}06 Filter chips clearing one by one — Measured area 4.229% · moving frames 9/23Original by GODRICH · SCSS and React ship in the zip · 9 Empty State UI Design Cards Drawn in Pure CSS
The post this demo lives in
9 Empty State UI Design Cards Drawn in Pure CSSEmpty state UI design fills the space a list would occupy when there is no data to put in it. One of these nine is blank See all demos in this post
If you like this effect - similar demos
Lists & tables06 Per-column filters that leave a pill behind9 Data Table UI Patterns — Drag, Resize, Select
Lists & tables02 Type icons with indent guides9 File Tree CSS Views — Folders That Really Open
Lists & tables09 Chain-burst check marker — stacking a delay value so checks pop in cascadeCSS List Style: 9 Marker Design Patterns