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 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-toggly

v1.3.1

Published

A highly customizable and themeable toggle switch component for React, built with TypeScript and styled-components. Supports multiple themes like iOS, Bootstrap, and Tailwind CSS, and allows for custom icons, accessibility features, and controlled/uncontr

Readme

react-toggly

A highly customizable and themeable toggle switch component for React, built with TypeScript. Supports multiple themes like iOS, Bootstrap, and Tailwind CSS, and allows for custom icons, accessibility features, and controlled/uncontrolled behavior.

Demo Link

Features

  • Multiple Themes: Choose from ios, bootstrap, or tailwind themes
  • Custom Icons: Add custom icons for checked and unchecked states
  • Accessibility: Full ARIA support for better accessibility
  • Controlled/Uncontrolled: Works as both controlled and uncontrolled component
  • Labels: Support for left and right labels (text or icons)
  • Disabled State: Easily disable the toggle
  • TypeScript Support: Fully typed for better developer experience

Installation

npm install react-toggly
# or
yarn add react-toggly

Styles

To use the component styles, import them in your application:

// Import the styles in your app's entry point (e.g., App.js or index.js)
import 'react-toggly/dist/styles.css';

Changelog

See CHANGELOG.md for a list of changes and version history.

Usage

Basic Usage

import ToggleSwitch from 'react-toggly';

function App() {
  const [isChecked, setIsChecked] = React.useState(false);

  const handleToggle = (e) => {
    setIsChecked(e.target.checked);
  };

  return (
    <ToggleSwitch
      isChecked={isChecked}
      onToggleChange={handleToggle}
      toggleTheme="ios"
    />
  );
}

With Labels

<ToggleSwitch
  isChecked={isChecked}
  onToggleChange={handleToggle}
  leftLabel="Off"
  rightLabel="On"
/>

With Custom Icons

<ToggleSwitch
  isChecked={isChecked}
  onToggleChange={handleToggle}
  customIcons={{
    checked: <span>✓</span>,
    unchecked: <span>✕</span>
  }}
/>

Different Themes

// iOS theme (default)
<ToggleSwitch toggleTheme="ios" />

// Bootstrap theme
<ToggleSwitch toggleTheme="bootstrap" />

// Tailwind theme
<ToggleSwitch toggleTheme="tailwind" />

Uncontrolled Component

<ToggleSwitch
  defaultIsChecked={true}
  onToggleChange={(e) => console.log('Toggle changed:', e.target.checked)}
/>

Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | isChecked | boolean | - | Controlled state of the toggle | | defaultIsChecked | boolean | false | Initial state for uncontrolled usage | | onToggleChange | (e: ChangeEvent) => void | - | Change event handler | | toggleTheme | 'ios' \| 'bootstrap' \| 'tailwind' | 'ios' | Visual theme | | leftLabel | ReactNode | - | Label on the left side | | rightLabel | ReactNode | - | Label on the right side | | customIcons | { checked?: ReactNode, unchecked?: ReactNode } | - | Custom icons | | isDisabled | boolean | false | Disable the toggle | | containerClassName | string | - | Additional container class | | inputName | string | - | Input name attribute | | inputId | string | - | Input id attribute | | ariaLabel | string | - | ARIA label | | ariaLabelledBy | string | - | ARIA labelledby |

Contributing

We welcome contributions! Please see our Contributing Guide for details on how to:

  • Set up the development environment
  • Submit pull requests
  • Follow our coding standards
  • Contribute to documentation

License

MIT