Skip to content

SwipeCell ​

Reveal a row of action buttons by swiping a list item horizontally: the default slot is the content layer (the list item body) and slot="actions" is the action button group (the host places button / oas-button elements). Swiping the content layer toward inline-start reveals the inline-end action area; releasing snaps to open or closed based on the drag threshold. oas-open / oas-close are dispatched once each when the open / closed state settles (programmatic open attribute changes dispatch them too). An item can also carry a group on the other side (slot="actions-start", see "Two-Sided Swipe")—the two sides open exclusively on the same item.

Basic Usage ​

A single swipe item: put the content in the default slot and the action button in slot="actions". Swipe left (LTR) to reveal the right-hand action area and release to snap.

Single swipe item

Swipe left to see actions
Delete

side: Actions on the Left (Swipe Right) ​

By default actions attach to the inline-end side (right in LTR, revealed by swiping left); side="start" moves them to inline-start (left in LTR, revealed by swiping right). side is an interaction choice orthogonal to text direction—in RTL both the side and the swipe direction mirror automatically. Note: when the same item also has slot="actions-start", side is ignored and slot="actions" always stays on inline-end (this slot is for the single-group case).

side="start": swipe right

Swipe right for actions
Edit

Multiple Buttons ​

slot="actions" accepts multiple buttons: the component measures their total width and reveals the whole row on swipe (each button clicks independently):

Edit + Delete

Swipe left to reveal two actions
EditDelete

Two-Sided Swipe (Actions on Both Sides) ​

An item can carry an action group on each side at once: slot="actions" on inline-end (left-swipe in LTR) and slot="actions-start" on inline-start (right-swipe in LTR). A single gesture drags both ways and can cross zero to switch sides end-to-end; only one side opens per item. The open-side attribute reflects the current side (start / end), and oas-open's detail carries { side }.

Left-swipe Delete / Right-swipe Archive

Swipe left for Delete, swipe right for Archive
ArchiveDelete

Single-Open Exclusion & Events ​

At most one swipe item is open within the same document at a time: once an item settles open it broadcasts and automatically closes any other open item. Clicking empty space, scrolling a container, or pressing Esc also closes the current item. The feedback area below shows the most recent oas-open / oas-close.

Multiple swipe items + event feedback

Item one
Edit
Item two
Edit
Item three
Delete
Swipe any item to see event feedback

Threshold / Disabled / Programmatic Open ​

threshold sets the release snap distance (default 40px; a drag beyond it snaps open, otherwise it bounces back); disabled disables all gestures; open is readable and writable for controlled or programmatic open/close (true when either side is open). Programmatic open changes dispatch oas-open / oas-close; the open-side attribute (or same-named property) selects/reads which side opens—setting open-side together with open opens that side, and detail.side reports which.

threshold and disabled

Threshold 100px: drag farther to snap open
Delete
Disabled: gestures have no effect
Delete

Programmatic open

Initially open: the action area is already revealed
Edit
Toggle open

Keyboard & Accessibility ​

  • The action area is role="group" with an accessible name (i18n swipeCell.actionsLabel); with two sides, each group has its own.
  • Action buttons are natively tabbable in the DOM: focusing into the matching side's action area opens that side automatically, so keyboard users can see and operate the buttons without a swipe gesture.
  • Press Esc to close an open item; under prefers-reduced-motion the snap has no transition.
  • The component does not change the role or semantics of the content layer; screen readers read it using the structure provided by the host.

API ​

oas-swipe-cell ​

Attributes ​

AttributeDescriptionTypeDefault
disabledDisable all gesturesboolean—
openOpen state (read/write; true when either side is open; programmatic changes dispatch oas-open / oas-close)boolean—
open-sideCurrent/target open side: start / end; set together with open to open that side, read back to reflect the current side'' | 'start' | 'end'—
sideSide the actions attach to: end (default, inline-end—right in LTR / left in RTL, swipe toward inline-start) / start (inline-start, swipe toward inline-end—rightward in LTR); orthogonal to text direction, mirrors automatically in RTL; ignored when the item also has actions-startstringend
thresholdRelease snap threshold (px); a drag beyond it snaps open, otherwise it bounces closed——

Events ​

EventDescription
oas-closeDispatched when the closed state settles (gesture, outside click, scroll, Esc, or programmatic open change)
oas-openDispatched when the open state settles (gesture or programmatic open change); detail: { side } reports the side

Slots ​

NameDescription
defaultContent layer (list item body); the component does not change its semantics
actionsAction button group (placed on the inline-end side; role=group + aria-label)
actions-startSecond action button group (placed on the inline-start side, revealed by swiping right; opens exclusively with actions on the same item)

CSS Variables ​

CSS VariableDefault
--oas-swipe-cell-actions-bgvar(--oas-color-bg-hover)
--oas-swipe-cell-bgvar(--oas-color-bg)
--oas-swipe-cell-offset0px

Released under the MIT OR Apache-2.0 License.