|
Download wp-calypso/packages/components/src/swipeable/README.md from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 998 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/packages/components/src/swipeable/README.md
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/packages/components/src/swipeable/README.md
-
curl -L -o README.md https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/packages/components/src/swipeable/README.md
998 Bytes
Swipeable
This component is used to add horizontal swipe controls to a list of elements (pages).
Example Usage
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.