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-pill

v0.0.1

Published

A customizable pill component for React Native projects, created with Expo. Supports custom labels, colors, and icons.

Downloads

70

Readme

React Native Pill Component

A customizable pill component for React Native projects, created with Expo. This package allows you to easily create pill-shaped buttons or tags, with support for custom icons, colors, and rounded styling.

Features

  • Customizable labels, colors, and icons.
  • Click and long-press event handling.
  • Easy integration with Expo and React Native projects.
  • Supports rounded borders.

Installation

Prerequisites

  • You need Node.js and npm or yarn installed.
  • Make sure you have expo installed globally:
npm install -g expo-cli

Install the Package

To install the package, run:

npm install react-native-pill

Or if you're using yarn:

yarn add react-native-pill

Usage

Here is an example of how to use the Pill component in your React Native project:

import React, { useState } from "react";
import { StyleSheet, View, Text } from "react-native";
import Pill from "react-native-pill"; // Import the Pill component
import Ionicons from "@expo/vector-icons/Ionicons";

const App = () => {
const [data, setData] = useState([
{
label: "Task 1",
backgroundColor: "#C2BB00",
icon: <Ionicons name="checkmark-circle" size={20} color="white" />,
},
{
label: "Search",
backgroundColor: "#3498db",
icon: <Ionicons name="search" size={20} color="white" />,
},
{
label: "Gallery",
backgroundColor: "#ED8B16",
icon: <Ionicons name="image" size={20} color="white" />,
},
]);

const pressHandler = (label: string, index: number) => {
alert(\`Pressed: \${label}\`);
};

const deleteHandler = (label: string, index: number) => {
setData((prevData) => prevData.filter((\_, i) => i !== index));
};

return (
<View style={styles.container}>
<Text style={styles.title}>React Native Pill Component Example</Text>
<Pill
        data={data}
        pressHandler={pressHandler}
        deleteHandler={deleteHandler}
        rounded
      />
</View>
);
};

const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: "center",
alignItems: "center",
padding: 20,
},
title: {
fontSize: 20,
fontWeight: "bold",
marginBottom: 20,
},
});

export default App;

Props

| Prop | Type | Required | Default | Description | | ----------------- | -------------------------- | -------- | --------- | --------------------------------------------------------------- | | data | Array<PillItem> | Yes | - | Array of pill items containing label, color, and optional icon. | | pressHandler | (label, index) => void | No | - | Function called when a pill is pressed. | | deleteHandler | (label, index) => void | No | - | Function called when a pill is long-pressed to delete. | | rounded | boolean | No | false | Controls whether pills have rounded borders. |

`PillItem` Object

Each item in the `data` array should have the following structure:

| Key | Type | Description | | ------------------- | ------------------- | ------------------------------------------ | | label | string | The text label displayed inside the pill. | | backgroundColor | string | (Optional) Background color for the pill. | | icon | React.ReactNode | (Optional) An icon component for the pill. |

Example App

You can find an example app demonstrating the usage of the pill component in the example folder. To run it, use:

cd example
npm install
expo start

Contributing

Feel free to submit issues and pull requests. Contributions are always welcome!

npm test

License

MIT License.

Feedback

If you have any questions, suggestions, or feedback, feel free to open an issue or contribute to this project. We'd love to hear from you!