npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-carousel-picker

v2.0.3

Published

A cross-platform wheel picker component for React Native in pure Javascript.

Downloads

304

Readme

React Native Carousel Picker

A cross-platform carousel picker component for React Native in pure Javascript. (iOS wheel Picker for Android & iOS)

Features

  • 100% Javascript
  • Highly customizable

Demo

Demo Image Demo Image

Installation

Open a Terminal in the project root and run:

npm install react-native-carousel-picker

We're done! Now you can build and run the app on your device/simulator.

Quick Start

import React, { useState } from "react";
import { View } from "react-native";
import CarouselPicker from "react-native-carousel-picker";

const App = () => {
    // Set the initial indices for each column.
    const [selectedIndices, setSelectedIndices] = useState({ col1: 0, col2: 0, col3: 0 });

    // Sample items for each column.
    const items = {
        col1: [...Array(10).keys()].map((index) => `Col1 Item ${index + 1}`),
        col2: [...Array(10).keys()].map((index) => `Col2 Item ${index + 1}`),
        col3: [...Array(10).keys()].map((index) => `Col3 Item ${index + 1}`),
    };

    // Update the selected indices state when an item is selected.
    const handleSelected = (column, index) => {
        setSelectedIndices(prevState => ({
            ...prevState,
            [column]: index
        }));
    };

    return (
        <View style={{ flex: 1, backgroundColor: 'white', justifyContent: 'center' }}>
            <CarouselPicker
                onSelected={handleSelected}
                items={items}
                selectedIndices={selectedIndices}
            />
        </View>
    );
};

export default App;

Props

onSelected (required)

Callback which is called on carousel picker change, receives the column & index of the new selected item as argument. The current selected index state needs to be updated when it's called, otherwise the change is dropped.

selectedIndices (required)

This is the current selected indices that needs to be updated when the picker change. You can use this property to update the selected item. Default value is {}.

itemHeight (optional)

Height of each item of the picker needs to be upper to zero. The global height of the container depends on the height of each item. Default value is 40.

countVisibleItems (optional)

The minimum number of visible items to be displayed. The global height of the container depends on the number of visible items. Default value is 2

items (optional)

An array of string items that needs to be displayed. This array can be updated any time, the picker will refresh its content according to the new array. Default value is [].

backgroundColor (optional)

Define background of the carousel picker. Default value is undefined.

selectedMarkBackgroundColor (optional)

Define color of the selected mark. Default value is #4DB6AC.

selectedMarkBorderRadius (optional)

Define border radius of the selected mark. Default value is 8.

selectedMarkMarginHorizontal (optional)

Define the horizontal margin of the selected mark. Default value is 20.

selectedMarkHeight (optional)

Define the size of the selected mark. Default value is 1.

itemTextStyle (optional)

Define the text style of each displayed item. Default value is undefined.

containerStyle (optional)

Define the container style of the displayed picker. Default value is {}.

selectedItemTextStyle (optional)

Define the text style of each selected item. Default value is { fontWeight: 'bold', color: '#37474F' }.

unselectedItemTextStyle (optional)

Define the text style of each selected item. Default value is { fontWeight: 'normal', color: '#ADADAD' }.

Accessibility labels

The component provides some accessilibility labels, the general format is picker:<accessibility label>

Items of the picker

Accessibility label for Item 0 would be picker:Item 0