File size: 998 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Swipeable

This component is used to add horizontal swipe controls to a list of elements (pages).

## Example Usage

```js
import Swipeable from 'calypso/components/swipeable';

function Pager() {
	const [ currentPage, setCurrentPage ] = useState( 0 );
	return (
		<Swipeable
			onPageSelect={ ( index ) => {
				setCurrentPage( index );
			} }
			currentPage={ currentPage }
			pageClassName="example-page-component-class"
		>
			<div>Page 1</div>
			<div>Page 2</div>
			<div>Page 3</div>
		</Swipeable>
	);
}
```

## Props

- `onPageSelect` - (function) Function that runs when the page is selected on using a swipe. Useful for updating the current page.
- `currentPage` - (number) Index of the currently selected/shown page.
- `hasDynamicHeight` - (bool) Whether height should be changed dynamically.
- `pageClassName` - _optional_ (string) Optional class attribute of the page component.
- `containerClassName` - _optional_ (string) Optional class attribute of the page container component.