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

@atawi/react-popover

v1.0.8

Published

A fully-featured, accessible, and customizable popover component for React applications

Downloads

246

Readme

codecov License: MIT

React Popover Component

A lightweight, fully-featured, accessible, and customizable popover component for React apps.

Features

  • 🎯 12 placement options with smart auto-positioning
  • 🎨 Smooth animations and transitions
  • 🔄 Multiple trigger types (click, hover, focus)
  • 📱 Responsive and mobile-friendly
  • ♿ Accessible (WAI-ARIA compliant)
  • 🎛️ Controlled and uncontrolled modes
  • 🎯 Auto-placement to stay within viewport
  • 🖌️ Highly customizable styling
  • 📦 TypeScript support
  • ⚡ Optimized performance
  • ❌ No external dependencies

API documentation website

Installation

npm install @atawi/react-popover

Basic Usage

import { Popover } from "@atawi/react-popover";
import "@atawi/react-popover/dist/style.css"; // Optional: Import default styles

function App() {
  return (
    <Popover
      trigger={<button>Click me</button>}
      content={<div>Popover content</div>}
      placement="top"
    />
  );
}

Props

| Prop | Type | Default | Description | | -------------------- | ------------------------------------ | --------- | ------------------------------------- | | trigger | ReactNode | - | The element that triggers the popover | | content | ReactNode | - | The content to display in the popover | | placement | PopoverPlacement | 'top' | Preferred placement of the popover | | offset | number | 8 | Distance between trigger and popover | | className | string | '' | Class name for the popover wrapper | | containerClassName | string | '' | Class name for the container | | contentClassName | string | '' | Class name for the content wrapper | | open | boolean | - | Control popover visibility externally | | onOpenChange | (open: boolean) => void | - | Callback when visibility changes | | style | CSSProperties | - | Additional styles for the popover | | autoPlacement | boolean | false | Enable automatic repositioning | | animated | boolean | false | Enable enter/exit animations | | triggerType | PopoverTrigger \| PopoverTrigger[] | 'click' | How to trigger the popover | | hoverDelay | number | 200 | Delay before showing on hover | | closeDelay | number | 400 | Delay before hiding on hover out | | closeOnScroll | boolean | false | Close popover when window is scrolled | | closeOnResize | boolean | false | Close popover when window is resized |

Examples

Basic Popover

<Popover
  trigger={<button>Click me</button>}
  content="Simple popover content"
  placement="top"
/>

With Auto-placement

<Popover
  trigger={<button>Hover me</button>}
  content="Content that stays in viewport"
  placement="top"
  autoPlacement
  triggerType="hover"
/>

Animated Popover

<Popover
  trigger={<button>Animated</button>}
  content="Smooth animation"
  placement="right"
  animated
/>

Multiple Triggers

<Popover
  trigger={<button>Interactive</button>}
  content="Accessible content"
  placement="bottom"
  triggerType={["hover", "focus"]}
/>

Controlled Mode

function ControlledExample() {
  const [open, setOpen] = useState(false);

  return (
    <Popover
      trigger={<button>Controlled</button>}
      content="Controlled content"
      open={open}
      onOpenChange={setOpen}
    />
  );
}

Custom Styling

<Popover
  trigger={<button>Styled</button>}
  content="Custom styled content"
  className="custom-popover"
  contentClassName="custom-content"
  style={{ maxWidth: "300px" }}
/>

Placement Options

The placement prop accepts the following values:

  • top | top-start | top-end
  • bottom | bottom-start | bottom-end
  • left | left-start | left-end
  • right | right-start | right-end

Trigger Types

The triggerType prop accepts:

  • 'click' - Opens on click/tap
  • 'hover' - Opens on mouse hover
  • 'focus' - Opens on focus (keyboard navigation)
  • Array of the above for multiple triggers

Styling

The component uses CSS modules and provides several class names for customization:

  • .container - The root container
  • .trigger - The trigger wrapper
  • .content - The popover content wrapper
  • .contentInner - The inner content container
  • .animated - Applied when animations are enabled
  • .enter - Applied during enter animation
  • .exit - Applied during exit animation

Accessibility

The component follows WAI-ARIA guidelines:

  • Proper ARIA attributes
  • Keyboard navigation support
  • Focus management
  • Screen reader friendly

Browser Support

  • Chrome (latest)
  • Firefox (latest)
  • Safari (latest)
  • Edge (latest)
  • IE11 (with polyfills)

Contributing

Contributions are welcome! Please read our contributing guidelines before submitting a pull request.

License

MIT © Atawi