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

@leafygreen-ui/resizable

v0.1.3

Published

LeafyGreen UI Kit Resizable

Readme

Resizable

npm (scoped)

View on MongoDB.design

Installation

PNPM

pnpm add @leafygreen-ui/resizable

Yarn

yarn add @leafygreen-ui/resizable

NPM

npm install @leafygreen-ui/resizable

Overview

Resizable is an internal hook that provides resizable functionality to an element. It allows you to specify the position of the resizer and provides props to attach to the resizable element. The hook supports both mouse and keyboard interactions for resizing elements.

Usage

import { useResizable, Position } from '@leafygreen-ui/resizable';

const MyComponent = () => {
  const { getResizerProps, size, resizableRef } = useResizable({
    enabled: true,
    initialSize: 300,
    minSize: 200,
    maxSize: 600,
    position: Position.Right,
    onResize: newSize => {
      console.log('New size:', newSize);
    },
  });

  return (
    <div ref={resizableRef} style={{ width: size, height: '100%' }}>
      {/* Your content here */}
      <div {...getResizerProps()} />
    </div>
  );
};

Props

useResizable

| Prop | Type | Description | Default | | ------------- | ---------------------------------------------- | ---------------------------------------------------------------------- | ------- | | enabled | boolean | Whether the resizable feature is enabled | true | | initialSize | number | The initial size of the resizable element | - | | minSize | number | The minimum size the resizable element can be resized to | - | | maxSize | number | The maximum size the resizable element can be resized to | - | | onResize | (size: number) => void | Callback function that is called when the resizable element is resized | - | | position | 'left' | 'right' | 'top' | 'bottom' | The position of the resizer handle | - |

Return Values

The useResizable hook returns an object with the following properties:

| Name | Type | Description | | ----------------- | ---------------------------------------------- | ----------------------------------------------------------------- | | size | number | The current size of the resizable element | | setSize | React.Dispatch<React.SetStateAction<number>> | Function to programmatically set the size of the element | | isResizing | boolean | Indicates whether the element is currently being resized | | getResizerProps | () => ResizerProps \| undefined | Function that returns props to be spread onto the resizer element | | resizableRef | React.RefObject<HTMLElement> | Ref object to be attached to the resizable element |

Position

The Position enum defines where the resizer handle should be placed:

import { Position } from '@leafygreen-ui/resizable';

// Available positions
Position.Left; // Resizable element is on the left
Position.Right; // Resizable element is on the right
Position.Top; // Resizable element is on the top
Position.Bottom; // Resizable element is on the bottom

Examples

Horizontal Resizing (Left/Right)

import { useResizable, Position } from '@leafygreen-ui/resizable';

const HorizontalResizablePanel = () => {
  const { getResizerProps, size, resizableRef } = useResizable({
    initialSize: 300,
    minSize: 200,
    maxSize: 600,
    position: Position.Left,
  });

  return (
    <div ref={resizableRef} style={{ width: size }}>
      <div>Resizable Panel Content</div>
      <div
        {...getResizerProps()}
        style={{
          position: 'absolute',
          right: 0,
          top: 0,
        }}
      />
    </div>
  );
};

Vertical Resizing (Top/Bottom)

import { useResizable, Position } from '@leafygreen-ui/resizable';

const VerticalResizablePanel = () => {
  const { getResizerProps, size, resizableRef } = useResizable({
    initialSize: 200,
    minSize: 100,
    maxSize: 500,
    position: Position.Top,
  });

  return (
    <div ref={resizableRef} style={{ height: size }}>
      <div>Resizable Panel Content</div>
      <div
        {...getResizerProps()}
        style={{
          position: 'absolute',
          bottom: 0,
          left: 0,
        }}
      />
    </div>
  );
};

Accessibility

The resizer element receives the appropriate ARIA attributes for keyboard navigation:

  • tabIndex={0} for keyboard focus
  • Arrow keys can be used to resize once focused
  • ARIA attributes for screen readers indicating resizable functionality

Keyboard Support

When the resizer is focused, the following keyboard interactions are supported:

| Key | Action | | ------------ | --------------------------------------------------------------------------------- | | ArrowLeft | Position.Right: Increase the size Position.Left: Decrease the size | | ArrowRight | Position.Right: Decrease the size Position.Left: Increases the size | | ArrowUp | Position.Top: Decrease the size Position.Bottom: Increases the size | | ArrowDown | Position.Top: Increases the size Position.Bottom: Decrease the size |