1.0.4 • Published 10 months ago

react-native-pagination-ui v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

Pagination Component for React Native

A customizable pagination component for React Native that supports page grouping and custom styling. Ideal for projects that need intuitive navigation across multiple pages.

Installation

You can install the component via npm:

npm install react-native-pagination-ui

Dependencies

npm i @expo/vector-icons

Usage

Import the Pagination component and use it in your React Native project:

import { useState } from 'react';
import { View } from 'react-native';
import { Pagination } from 'react-native-pagination-ui';

const App = () => {
  const [currentPage, setCurrentPage] = useState(1);

  const handlePageChange = (page: number) => {
    setCurrentPage(page);
    // Add your logic for handling page change
  };

  return (
    <View>
      <Pagination
        total={20}
        initialPage={currentPage}
        handlePageChange={handlePageChange}
        selectedItemColor='primary'
        defaultItemColor='default'
        itemSizes='lg'
      />
    </View>
  );
};

export default App;

Logo

Props

PropTypeDefaultDescription
totalnumberRequiredThe total number of pages.
initialPagenumberRequiredThe initial page to display.
handlePageChange(page: number) => voidRequiredCallback function triggered when the page is changed.
selectedItemColorPaginationColorsEnumprimaryThe color for the selected page.
defaultItemColorPaginationColorsEnumdefaultThe color for the unselected pages.
itemSizesPaginationSizesEnumlgSize of the pagination items (small, medium, large, extra-large).
iconPropsIconPropsInterface{ size: 18, color: '#000' }Properties for the pagination icons (ellipses).

Customization

Sizes

You can customize the size of the pagination buttons using the itemSizes prop. Available sizes:

  • sm: Small
  • md: Medium
  • lg: Large (default)
  • xl: Extra-large

Colors

Choose from predefined colors by using the selectedItemColor and defaultItemColor props:

  • primary: Blue
  • secondary: Purple
  • success: Green
  • danger: Red
  • warning: Orange
  • info: Cyan
  • default: Grey
  • light: White

Icon Props

You can pass custom properties to the icon using the iconProps prop, such as:

iconProps={{ size: 20, color: '#FF0000' }}

Example

<Pagination
  total={50}
  initialPage={1}
  handlePageChange={(page) => console.log('Current Page:', page)}
  selectedItemColor='success'
  defaultItemColor='light'
  itemSizes='md'
  iconProps={{ size: 16, color: '#123456' }}
/>

Keywords

  • react-native
  • pagination
  • ui
  • component
  • react
  • native
  • expo

Repository

https://github.com/Diego-Fdez/react-native-pagination-ui

Contributors

  • @Diego-Fdez

License

This project is licensed under the MIT License.

1.0.4

10 months ago

1.0.3

10 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago