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

@thanhnn/react-resizable

v1.0.11

Published

A modern React component library for creating resizable elements with TypeScript support

Downloads

14

Readme

@thanhnn/react-resizable

A modern, accessible, and customizable React component library for creating resizable elements with TypeScript.
Perfect for dashboards, editors, modals, and any dynamic layout requiring user-resizable components.

NPM version
Live Demo ↗ Ask DeepWiki


Table of Contents


✨ Features

  • 🧩 Composable & Flexible – Headless design lets you style freely.
  • ⚙️ Fully Typed – Built with TypeScript for great DX.
  • Accessible – ARIA attributes, keyboard support, and screen reader-friendly.
  • 🎯 Precise Constraints – Control min/max dimensions and aspect ratio.
  • 🔗 Keyboard + Mouse + Touch – Works on all input devices.
  • 🔄 Controlled & Uncontrolled Modes – Choose how you manage state.

📦 Installation

npm install @thanhnn/react-resizable
# or
yarn add @thanhnn/react-resizable
# or
pnpm add @thanhnn/react-resizable

🚀 Demo

Live demo: https://thanhnn-react-resizable.vercel.app
Explore:

  • Basic resizable behavior
  • Custom handles and styling
  • Multiple handles
  • Aspect ratio locking
  • Controlled/Uncontrolled usage
  • useResizable hook

🛠️ Usage

Basic

import { Resizable } from '@thanhnn/react-resizable';

<Resizable>
  <Resizable.Content>Your content</Resizable.Content>
  <Resizable.Handle />
</Resizable>;

Controlled

const [size, setSize] = useState({ width: 300, height: 200 });

<Resizable value={size} onChange={(w, h) => setSize({ width: w, height: h })}>
  <Resizable.Content>Your content</Resizable.Content>
  <Resizable.Handle direction="bottom-right" />
</Resizable>;

Multiple Handles

<Resizable minWidth={200} minHeight={200}>
  <Resizable.Content>Your content</Resizable.Content>
  <Resizable.Handle direction="top" />
  <Resizable.Handle direction="right" />
  <Resizable.Handle direction="bottom" />
  <Resizable.Handle direction="left" />
  <Resizable.Handle direction="top-right" />
  <Resizable.Handle direction="bottom-right" />
  <Resizable.Handle direction="bottom-left" />
  <Resizable.Handle direction="top-left" />
</Resizable>

Custom Styling

<Resizable minWidth={200} minHeight={200}>
  <Resizable.Content className="bg-gray-100 rounded-lg shadow-lg p-4">
    Custom styled content
  </Resizable.Content>
  <Resizable.Handle
    direction="bottom-right"
    className="w-4 h-4 bg-blue-500 rounded-full hover:bg-blue-600"
  />
</Resizable>

Aspect Ratio

<Resizable minWidth={200} minHeight={200} aspectRatio>
  <Resizable.Content>Aspect-ratio locked</Resizable.Content>
  <Resizable.Handle direction="bottom-right" />
</Resizable>

With useResizable Hook

const { width, height, getResizeHandleProps } = useResizable({
  minWidth: 200,
  minHeight: 200,
  triggerMode: 'resize',
});

<div style={{ width, height }}>
  Custom content
  <div {...getResizeHandleProps('bottom-right')} />
</div>;

With Next.js

'use client';

import { Resizable } from '@thanhnn/react-resizable';

export default function Page() {
  return (
    <Resizable minWidth={300} minHeight={200}>
      <Resizable.Content className="p-4">Next.js ready</Resizable.Content>
      <Resizable.Handle direction="bottom-right" />
    </Resizable>
  );
}

Using asChild

Render the Resizable component as its direct child element, merging props and behavior. Useful for applying resizable functionality to existing components without extra wrappers. Requires @radix-ui/react-slot to be installed.

import { Resizable } from '@thanhnn/react-resizable';

<Resizable asChild>
  <button className="my-resizable-button">
    Resizable Button
    <Resizable.Handle />
  </button>
</Resizable>;

📘 API Reference

<Resizable />

| Prop | Type | Default | Description | | ------------- | ----------------------------------- | ---------- | ------------------------ | | value | { width: number; height: number } | – | Controlled size | | minWidth | number | 50 | Minimum width (px) | | minHeight | number | 50 | Minimum height (px) | | maxWidth | number | Infinity | Maximum width (px) | | maxHeight | number | Infinity | Maximum height (px) | | aspectRatio | boolean | false | Lock aspect ratio | | triggerMode | 'resize' | 'end' | 'both' | 'resize' | When to trigger onChange | | onChange | (w: number, h: number) => void | – | Resize callback | | asChild | boolean | false | Render as direct child |

triggerMode options:

  • 'resize': (Default) onChange triggered continuously during resizing
  • 'end': onChange triggered only once at the end of resize
  • 'both': onChange triggered during resize and again at the end

<Resizable.Content />

| Prop | Type | Default | Description | | --------- | --------- | ------- | ---------------------- | | asChild | boolean | false | Render as direct child |

<Resizable.Handle />

| Prop | Type | Default | Description | | ----------- | ------------------------------------------------------------------------------------------------------ | -------------- | ------------------------------ | | direction | 'top' | 'right' | 'bottom' | 'left' | 'top-right' | 'bottom-right' | 'bottom-left' | 'top-left' | 'bottom-right' | Direction of the resize handle | | asChild | boolean | false | Render as direct child |

All components accept div props like className, style, id, etc.


⌨️ Keyboard Navigation

  • Enter: Start resizing
  • Escape: Cancel resizing
  • Shift: Hold Shift for lock aspect ratio

♿ Accessibility

Built with accessibility in mind:

  • Proper ARIA roles
  • Focusable handles
  • Keyboard support
  • Touch device support

🌐 Browser Support

  • ✅ Chrome (latest)
  • ✅ Firefox (latest)
  • ✅ Safari (latest)
  • ✅ Edge (latest)

🧑‍💻 Development

git clone https://github.com/nnthanh01061999/react-resizable.git
cd react-resizable
pnpm install
pnpm storybook  # Launch Storybook
pnpm build      # Build the library

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  • Fork the repository
  • Create your feature branch (git checkout -b feature/amazing-feature)
  • Commit your changes (git commit -m 'Add some amazing feature')
  • Push to the branch (git push origin feature/amazing-feature)
  • Open a Pull Request

🪪 License

MIT © @nnthanh01061999