
Research
Security News
The Growing Risk of Malicious Browser Extensions
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
**React Pill** is a customizable pill-style component that you can use to create tab-like elements in your React application. It is simple, lightweight, and easy to integrate, providing a clean and modern look for navigation or item selection.
React Pill is a customizable pill-style component that you can use to create tab-like elements in your React application. It is simple, lightweight, and easy to integrate, providing a clean and modern look for navigation or item selection.
You can install react-pill
via NPM:
npm install react-pill
Or with Yarn:
yarn add react-pill
Here's how you can use the Pill
component in your React project:
import React from "react";
import Pill from "react-pill";
const App = () => {
const data = [
{ label: "Tab 1", bgcolor: "#ffcccb" },
{ label: "Tab 2", bgcolor: "#b0e57c" },
{ label: "Tab 3", bgcolor: "#87ceeb", icon: "📌" },
];
const handleSelect = (event, index) => {
console.log(`Selected Pill: ${index}`);
};
const handleClose = (index) => {
console.log(`Closed Pill: ${index}`);
};
return (
<div>
<Pill
data={data}
onSelect={handleSelect}
onClose={handleClose}
rounded={true}
wrapperClassName="pill-container"
itemClassName="custom-pill"
/>
</div>
);
};
export default App;
Prop | Type | Description |
---|---|---|
data | array | Array of pill data objects, each with properties label , bgcolor , and icon . |
onClose | function | Function called when the close button is clicked. Receives the index of the pill. |
onSelect | function | Function called when a pill is selected. Receives the event and the index of the pill. |
rounded | boolean | If true , pills will have rounded corners. |
itemClassName | string | Custom class for individual pills. |
wrapperClassName | string | Custom class for the pill container. |
In the example above:
data
prop provides the labels, colors, and optional icons for each pill.onSelect
and onClose
props handle user interactions.You can style the pills using your own CSS. Here are the default classes you can override:
.defaultPill
: The base pill styling..rounded
: Adds rounded corners..closeButton
: Styles the close button..iconContainer
: Wraps the icon inside the pill.You can create your own Pill.css
to modify the appearance as desired:
.defaultPill {
padding: 10px;
border: none;
cursor: pointer;
}
.rounded {
border-radius: 20px;
}
.closeButton {
background: none;
border: none;
cursor: pointer;
margin-left: 10px;
}
To build the package, run:
npm run build
To run the tests:
npm test
Contributions are welcome! If you have ideas or suggestions, feel free to open an issue or create a pull request.
MIT License. Feel free to use, modify, and share it!
FAQs
**React Pill** is a customizable pill-style component that you can use to create tab-like elements in your React application. It is simple, lightweight, and easy to integrate, providing a clean and modern look for navigation or item selection.
The npm package react-pill receives a total of 47 weekly downloads. As such, react-pill popularity was classified as not popular.
We found that react-pill demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.