Delete Row
shadcn-htmx/delete-rowFreeComponent
A row/item delete affordance that confirms, sends DELETE, then fades out in place. One inherited declaration on the list host (hx-confirm:inherited / hx-target:inherited / hx-swap:inherited) covers every row, so each Delete button only needs hx-delete — no per-row wiring and no client-side list state. The server replies 200 with an empty body and the row simply disappears after a CSS opacity fade. Zero custom JS.
Live preview
live · rendered by the registry
Rendered by shadcn-htmx on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://shadcn-htmx.productdevbook.com/r/delete-row.jsonSource
1/** @jsxImportSource hono/jsx */2import type { PropsWithChildren } from "hono/jsx"3import { cn, type ClassValue } from "@/registry/lib/cn"4import { buttonClasses, type ButtonVariant, type ButtonSize } from "@/registry/ui/button"56// Delete Row — shadcn-htmx, htmx v4 + Tailwind v4.7//8// A row/item delete affordance that confirms, sends DELETE, then fades out9// in place. One inherited declaration on the list host covers every row —10// no per-row wiring, no client-side list state. The server answers the11// DELETE with a 200 and an empty body, so the row is swapped with nothing12// and simply disappears.13//14// Built on:15// repos/htmx/www/src/content/patterns/03-records/02-delete-in-place.md16// The canonical pattern: the <tbody> hoists hx-confirm / hx-target /17// hx-swap with the :inherited modifier; each Delete button only needs18// hx-delete. During the swap delay htmx adds the htmx-swapping class to19// the target row, which we use to drive a CSS opacity fade.20// repos/htmx/www/src/content/docs/03-features/08-attribute-inheritance.md:10,29-3221// htmx v4 inheritance is explicit — hoist an attribute to an ancestor22// with the `:inherited` modifier (e.g. hx-confirm:inherited).23// repos/htmx/www/src/content/reference/01-attributes/05-hx-delete.md:25-2924// Respond to DELETE with a 200 + empty body to remove the element (a25// 204 performs no swap).26// repos/htmx/www/src/content/reference/01-attributes/08-hx-target.md27// hx-target="closest tr" targets the row containing the button.28// repos/htmx/www/src/content/reference/01-attributes/07-hx-swap.md:21129// hx-swap="outerHTML swap:Nms" delays the removal by N ms, giving the30// fade transition time to play before the node is detached.31// repos/htmx/www/src/content/reference/01-attributes/22-hx-confirm.md32// hx-confirm prompts with window.confirm before issuing the request.33// repos/htmx/src/htmx.js:1304,139434// htmx adds `htmx-swapping` to the target before the swap delay and35// removes it after the swap — the hook our fade keys off.36//37// Native semantics:38// - The list host is a real <tbody> (default) so the rows live in a valid39// table model and AT users get row/column navigation for free.40// repos/mdn/files/en-us/web/html/reference/elements/tbody/index.md41// - The delete affordance is a real <button>, so Enter / Space activation42// and focus come from the platform; no role/tabindex needed.43// … truncated
More from shadcn-htmx
All 83 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | shadcn-htmx | Components | Free | no deps | |
| Active Searchactive-search | shadcn-htmx | Components | Free | no deps | |
| Alertalert | shadcn-htmx | Components | Free | no deps | |
| Alert Dialogalert-dialog | shadcn-htmx | Components | Free | no deps | |
| Aspect Ratioaspect-ratio | shadcn-htmx | Components | Free | no deps | |
| Auto Gridauto-grid | shadcn-htmx | Components | Free | no deps | |
| Autocompleteautocomplete | shadcn-htmx | Components | Free | no deps | |
| Autosize Textareaautosize-textarea | shadcn-htmx | Components | Free | no deps |
