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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@versini/ui-toggle

v6.1.1

Published

[![npm version](https://img.shields.io/npm/v/@versini/ui-toggle?style=flat-square)](https://www.npmjs.com/package/@versini/ui-toggle) ![npm package minimized gzipped size](<https://img.shields.io/bundlejs/size/%40versini%2Fui-toggle?style=flat-square&labe

Readme

@versini/ui-toggle

npm version npm package minimized gzipped size

An accessible and customizable React toggle switch component built with TypeScript and TailwindCSS.

The Toggle component provides an intuitive switch interface for binary choices with comprehensive accessibility features and customizable styling options.

Table of Contents

Features

  • ♿ Accessible: WCAG compliant with proper ARIA attributes and keyboard navigation
  • 🎨 Customizable: Multiple sizes, themes, and styling options
  • 🔧 TypeScript: Fully typed with comprehensive prop definitions
  • 🌲 Tree-shakeable: Lightweight and optimized for bundle size
  • ⌨️ Keyboard Friendly: Full keyboard navigation support

Installation

npm install @versini/ui-toggle

Note: This component requires TailwindCSS and the @versini/ui-styles plugin for proper styling. See the installation documentation for complete setup instructions.

Usage

Basic Toggle

import { Toggle } from "@versini/ui-toggle";

function App() {
  const [enabled, setEnabled] = useState(false);

  return (
    <Toggle
      label="Enable notifications"
      checked={enabled}
      onChange={setEnabled}
    />
  );
}

Toggle with Description

import { Toggle } from "@versini/ui-toggle";

function App() {
  return (
    <Toggle
      label="Dark mode"
      labelHidden={false}
      helperText="Switch between light and dark theme"
      checked={darkMode}
      onChange={setDarkMode}
    />
  );
}

Label Position

import { Toggle } from "@versini/ui-toggle";

function App() {
  return (
    <div className="space-y-4">
      {/* Default - label on the right */}
      <Toggle label="Notifications" checked={enabled} onChange={setEnabled} />

      {/* Label on the left */}
      <Toggle
        label="Notifications"
        labelPosition="left"
        checked={enabled}
        onChange={setEnabled}
      />
    </div>
  );
}

Examples

Settings Panel

import { Toggle } from "@versini/ui-toggle";

function SettingsPanel() {
  const [settings, setSettings] = useState({
    notifications: true,
    autoSave: false,
    darkMode: true
  });

  return (
    <div className="space-y-4">
      <Toggle
        label="Push notifications"
        checked={settings.notifications}
        onChange={(checked) =>
          setSettings({ ...settings, notifications: checked })
        }
      />
      <Toggle
        label="Auto-save"
        checked={settings.autoSave}
        onChange={(checked) => setSettings({ ...settings, autoSave: checked })}
      />
      <Toggle
        label="Dark mode"
        checked={settings.darkMode}
        onChange={(checked) => setSettings({ ...settings, darkMode: checked })}
      />
    </div>
  );
}

API

Toggle Props

| Prop | Type | Default | Description | | --------------- | ----------------------------------------------- | ---------- | ----------------------------------------------------------------- | | label | string | - | Visible (or aria) label for the toggle (required). | | name | string | - | Form field name (required). | | onChange | (checked: boolean) => void | - | Callback fired when checked state changes. | | checked | boolean | false | Controlled checked state. | | focusMode | "dark" \| "light" \| "system" \| "alt-system" | "system" | Focus ring color mode. | | labelHidden | boolean | false | Visually hide the label (still accessible). | | labelPosition | "left" \| "right" | "right" | Position of the label relative to the toggle. | | mode | "dark" \| "light" \| "system" \| "alt-system" | "system" | Color mode/theme. | | noBorder | boolean | false | Remove outer border styling. | | narrow | boolean | false | Render the toggle in narrow style (smaller height, longer width). | | noHaptic | boolean | false | Disable haptic feedback on toggle (mobile devices). | | className | string | - | Extra classes for wrapper. | | labelMode | "dark" \| "light" \| "system" \| "alt-system" | - | Label color mode. |

The component renders a native checkbox input – you can pass standard input attributes via spreading if extending.