Inline Reversible Removal
原位可撤销移除
The removed item leaves a placeholder in its own row where the user can still restore it.
Where to use it
Keep the location of removed rows recognizable in dense lists. Keep the restore action at the item’s former position when a dense list makes the location important.
Practical example
In a campaign schedule, removing Friday’s announcement leaves a short placeholder in its original time slot. Restore puts the announcement back into that slot, while Finalize releases the space.
AI prompt
Add inline reversible removal to [list]. Keep a stable placeholder until the user restores or finalizes, snapshot the unchanged row data, and focus the available action whenever the state changes.
Example code
Save the standalone HTML as a file and open it in your browser. It uses the same code as the preview.
View HTML
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Inline Reversible Removal</title>
<style>
:root {
color-scheme: dark;
--demo-bg: #171629;
--demo-ink: #f8f5ff;
--demo-accent: #b9a6ff;
--demo-muted: #bfbbd3;
font-family: system-ui, sans-serif;
color: var(--demo-ink);
background: var(--demo-bg);
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 0; }
button, input { font: inherit; }
.demo {
display: grid;
place-items: center;
align-content: center;
min-height: 100vh;
padding: 14px;
overflow: hidden;
background: radial-gradient(ellipse at 50% 24%, #28233f, var(--demo-bg) 78%);
}
.demo-button {
border: 1px solid #ffffff3d;
border-radius: 7px;
background: #ffffff12;
color: var(--demo-ink);
padding: 6px 11px;
font-size: 12px;
cursor: pointer;
}
:focus-visible {
outline: 2px solid var(--demo-accent);
outline-offset: 3px;
}
.ui { width: min(100%, 238px); display: grid; gap: 8px; position: relative; font-size: 12px; line-height: 1.35; }
.ui .surface { min-width: 0; border: 1px solid #676591; border-radius: 10px; background: #282744; padding: 8px; }
.ui .bar { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.ui .actions { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 5px; }
.ui .muted { color: #cecae9; font-size: 11px; }
.ui .center { text-align: center; }
.ui .mono { font: 11px ui-monospace, monospace; font-variant-numeric: tabular-nums; }
.ui p { margin: 0; }
.ui .button { min-height: 30px; padding: 4px 7px; border-radius: 7px; border: 1px solid #79779f; background: #3d3a60; color: #f9f5ff; font-size: 11px; font-weight: 650; cursor: pointer; }
.ui .button:hover { background: #4e4976; }
.ui .primary { background: #c5eeec; border-color: #dafaee; color: #17213b; }
.ui .primary:hover { background: #e3fff9; }
.ui .button:disabled { opacity: .6; cursor: default; }
.ui .field { min-width: 0; width: 100%; border: 1px solid #79779f; border-radius: 6px; background: #1b1a31; color: #faf5ff; padding: 5px 7px; font-size: 12px; }
.ui .field::placeholder { color: #c2bcdd; }
.ui input[type="range"] { accent-color: #b8ebe0; width: 100%; min-width: 0; margin: 0; }
.ui button { font: inherit; }
.ui [hidden] { display: none !important; }
.ui progress { accent-color: #b8ebe0; }
@media (prefers-reduced-motion: reduce) {
.ui *, .ui *::after, .ui *::before { transition-duration: 0s !important; animation-duration: 0s !important; scroll-behavior: auto !important; }
}
.removal-slot{min-height:54px}.ui .pending{border-style:dashed;background:#2e314d;border-color:#aab4c6;display:grid;gap:3px;padding:3px 5px}.pending p{text-align:center}.ui .original{min-height:45px}.pending .button{min-height:23px}
</style>
</head>
<body>
<main class="demo">
<div class="ui"><div class="surface muted">Field sketches</div><div class="removal-slot"><div class="surface bar original"><span>Sunset notes</span><button type="button" class="button remove">Remove</button></div><div class="surface pending" hidden><p class="muted">Row set aside</p><div class="actions"><button type="button" class="button primary restore">Restore</button><button type="button" class="button finalize">Finalize</button></div></div></div><div class="bar"><p class="muted" role="status">2 entries</p><button class="button reset" type="button" hidden>Reset</button></div></div>
</main>
<script>
const slot = document.querySelector('.removal-slot');
const original = slot.querySelector('.original');
const pending = slot.querySelector('.pending');
const remove = original.querySelector('.remove');
const restore = pending.querySelector('.restore');
const reset = document.querySelector('.reset');
const status = document.querySelector('[role=status]');
function set(state) {
original.hidden = state !== 'visible'; pending.hidden = state !== 'pending'; slot.hidden = state === 'removed'; reset.hidden = state !== 'removed';
status.textContent = state === 'visible' ? "2 entries" : state === 'pending' ? "Removal pending" : "1 entry";
(state === 'visible' ? remove : state === 'pending' ? restore : reset).focus();
}
remove.addEventListener('click', () => set('pending'));
restore.addEventListener('click', () => set('visible'));
pending.querySelector('.finalize').addEventListener('click', () => set('removed'));
reset.addEventListener('click', () => set('visible'));
</script>
</body>
</html>Original example by UI Skills