API

The parts of tuckaway and the props they take.

Anatomy#

Import Tuckaway and put the parts together.

import * as Tuckaway from "tuckaway/react";

<Tuckaway.Group>
	<Tuckaway.Row>
		<Tuckaway.Actions side="start">
			<Tuckaway.Action />
		</Tuckaway.Actions>
		<Tuckaway.Content />
		<Tuckaway.Actions side="end">
			<Tuckaway.Action />
		</Tuckaway.Actions>
	</Tuckaway.Row>
</Tuckaway.Group>;

Components#

Group#

Keeps one row open among the rows inside it, separately from the rest of the page. It renders nothing of its own, and it's optional: rows outside a Group share one group for the whole page.

Row#

Holds the state. Takes div props.

PropTypeDefault
valuestringGenerated
dir"ltr" | "rtl"Read from the DOM
edgeGuardnumber24
commitMomentumnumber0.05

value identifies the row in its group, so keep it unique there. In a virtualized list, pass something stable, and a row that scrolls away open comes back open.

edgeGuard ignores swipes starting this many pixels from the leading screen edge, leaving them to the iOS back gesture. 0 turns it off.

commitMomentum is how many seconds of release speed count towards a full swipe. Raise it and a flick commits sooner, or set 0 to go by distance alone.

Content#

The part that moves. Takes div props, and takes focus so the keyboard works. See Keyboard.

Actions#

The panel on one side of the row. Takes div props.

PropTypeDefault
side"start" | "end"Required
widthnumber75 per action

side follows the writing direction, so start is on the right in a right-to-left layout. width is how far the row opens.

Action#

A button in the panel. Takes button props.

PropTypeDefault
onSelect() => voidRequired
commitbooleanfalse
shortcutstring | string[]-

A commit action is the one a full swipe runs. See Actions.

Data attributes#

AttributeOnValue
data-phaseRowidle, pending, dragging, settling, committing, committed
data-open-sideRowstart or end, when open
data-sideActionsstart or end
data-armedActionsPresent when letting go would commit
data-commitActionPresent on a commit action

Gestures#

A horizontal drag moves the row, and a vertical one still scrolls the page. Letting go past half of a panel's width opens it, and a quick flick counts for more than its distance. Past 60% of the row's width, letting go commits, and a fast flick gets there sooner once it's past the panel.

Tapping outside every row closes whichever is open. A press on another row closes the open one and does nothing else.

Good to know#