{"id":26685932,"url":"https://github.com/bokuweb/react-resizable-box","last_synced_at":"2025-03-26T11:01:13.289Z","repository":{"id":2525797,"uuid":"46756447","full_name":"bokuweb/re-resizable","owner":"bokuweb","description":"📏  A resizable component for React.","archived":false,"fork":false,"pushed_at":"2025-03-24T19:38:17.000Z","size":35764,"stargazers_count":2550,"open_issues_count":86,"forks_count":224,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-03-24T20:32:55.211Z","etag":null,"topics":["react","react-component","resizable","resize"],"latest_commit_sha":null,"homepage":"https://bokuweb.github.io/re-resizable/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bokuweb.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["bokuweb"]}},"created_at":"2015-11-24T00:22:05.000Z","updated_at":"2025-03-24T14:40:50.000Z","dependencies_parsed_at":"2024-01-06T07:59:20.031Z","dependency_job_id":"7ca0e627-94f7-4a83-a30a-ac142bf3d24b","html_url":"https://github.com/bokuweb/re-resizable","commit_stats":{"total_commits":851,"total_committers":59,"mean_commits":"14.423728813559322","dds":0.7132784958871916,"last_synced_commit":"da458ab823949ee1090316a3d50950ff89a04a7d"},"previous_names":["bokuweb/react-resizable-box"],"tags_count":101,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bokuweb%2Fre-resizable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bokuweb%2Fre-resizable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bokuweb%2Fre-resizable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bokuweb%2Fre-resizable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bokuweb","download_url":"https://codeload.github.com/bokuweb/re-resizable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245641426,"owners_count":20648641,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["react","react-component","resizable","resize"],"created_at":"2025-03-26T11:01:12.948Z","updated_at":"2025-03-26T11:01:13.254Z","avatar_url":"https://github.com/bokuweb.png","language":"TypeScript","readme":"\u003cp align=\"center\"\u003e\u003cimg src =\"https://github.com/bokuweb/re-resizable/blob/master/logo.png?raw=true\" /\u003e\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e📏 A resizable component for React.\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\u003cimg src=\"https://github.com/bokuweb/re-resizable/workflows/Continuous%20Integration/badge.svg\" alt=\"Build Status\" /\u003e\n\u003ca href=\"https://www.npmjs.com/package/re-resizable\"\u003e\n\u003cimg src=\"https://img.shields.io/npm/v/re-resizable.svg\" alt=\"Build Status\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/package/re-resizable\"\u003e\n\u003cimg src=\"https://img.shields.io/npm/dm/re-resizable.svg\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://renovatebot.com/\"\u003e\n\u003cimg src=\"https://img.shields.io/badge/renovate-enabled-brightgreen.svg\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/prettier/prettier\"\u003e\n\u003cimg src=\"https://img.shields.io/badge/styled_with-prettier-ff69b4.svg\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## Table of Contents\n\n- [Screenshot](#Screenshot)\n- [Live Demo](#live-demo)\n  - [Storybook](#storybook)\n  - [CodeSandbox](#codesandbox)\n- [Install](#install)\n- [Usage](#usage)\n- [Props](#props)\n- [Instance API](#instance-api)\n  - [updateSize(size: { width: number | string, height: number | string }): void](#updateSize-void)\n- [Test](#test)\n- [Related](#related)\n\n## Screenshot\n\n![screenshot](https://github.com/bokuweb/re-resizable/blob/master/docs/screenshot.gif?raw=true)\n\n## Live Demo\n\n### Storybook\n\n[Storybook](http://bokuweb.github.io/re-resizable/)\n\n### CodeSandbox\n\n[![Edit xp9p7272m4](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/xp9p7272m4)  \n[CodeSandbox](https://codesandbox.io/s/xp9p7272m4)  \n[CodeSandbox(TypeScript)](https://codesandbox.io/s/1vwo2p4l64)   \n[CodeSandbox(With hooks)](https://codesandbox.io/s/blissful-joliot-d3unx)\n\n## Install\n\n```sh\n$ npm install --save re-resizable\n```\n\n## Usage\n\n### Example with `defaultSize`\n\n```javascript\nimport { Resizable } from 're-resizable';\n\n\u003cResizable\n  defaultSize={{\n    width: 320,\n    height: 200,\n  }}\n\u003e\n  Sample with default size\n\u003c/Resizable\u003e\n```\n\nIf you only want to set the width, you can do so by providing just the width property. \nThe height property will automatically be set to auto, which means it will adjust 100% of its parent's height:\n\n```javascript\nimport { Resizable } from 're-resizable';\n\n\u003cResizable\n  defaultSize={{\n    width: 320\n  }}\n\u003e\n  Sample with default size\n\u003c/Resizable\u003e\n```\n### Example with `size`\n\nIf you use `size` props, please manage state by yourself.\n\n```javascript\nimport { Resizable } from 're-resizable';\n\n\u003cResizable\n  size={{ width: this.state.width, height: this.state.height }}\n  onResizeStop={(e, direction, ref, d) =\u003e {\n    this.setState({\n      width: this.state.width + d.width,\n      height: this.state.height + d.height,\n    });\n  }}\n\u003e\n  Sample with size\n\u003c/Resizable\u003e\n```\n\n## Props\n\n#### `defaultSize?: { width?: (number | string), height?: (number | string) };`\n\nSpecifies the `width` and `height` that the dragged item should start at.\nFor example, you can set `300`, `'300px'`, `50%`.\nIf both `defaultSize` and `size` omitted, set `'auto'`.\n\n`defaultSize` will be ignored when `size` set.\n\n#### `size?: { width?: (number | string), height?: (number | string) };`\n\nThe `size` property is used to set the size of the component.\nFor example, you can set `300`, `'300px'`, `50%`.\n\nUse `size` if you need to control size state by yourself.\n\n#### `className?: string;`\n\nThe `className` property is used to set the custom `className` of a resizable component.\n\n#### `style?: { [key: string]: string };`\n\nThe `style` property is used to set the custom `style` of a resizable component.\n\n#### `minWidth?: number | string;`\n\nThe `minWidth` property is used to set the minimum width of a resizable component. Defaults to 10px.\n\nIt accepts viewport as well as parent relative units. For example, you can set `300`, `50%`, `50vw` or `50vh`.\n\nSame type of values can be applied to `minHeight`, `maxWidth` and `maxHeight`.\n\n#### `minHeight?: number | string;`\n\nThe `minHeight` property is used to set the minimum height of a resizable component. Defaults to 10px.\n\n#### `maxWidth?: number | string;`\n\nThe `maxWidth` property is used to set the maximum width of a resizable component.\n\n#### `maxHeight?: number | string`;\n\nThe `maxHeight` property is used to set the maximum height of a resizable component.\n\n#### `grid?: [number, number];`\n\nThe `grid` property is used to specify the increments that resizing should snap to. Defaults to `[1, 1]`.\n\n#### `gridGap?: [number, number];`\n\nThe `gridGap` property is used to specify any gaps between your grid cells that should be accounted for when resizing. Defaults to `[0, 0]`.\nThe value provided for each axis will always add the grid gap amount times grid cells spanned minus one.\n\n#### `snap?: { x?: Array\u003cnumber\u003e, y?: Array\u003cnumber\u003e };`\n\nThe `snap` property is used to specify absolute pixel values that resizing should snap to. `x` and `y` are both optional, allowing you to only include the axis you want to define. Defaults to `null`.\n\n#### `snapGap?: number`\n\nThe `snapGap` property is used to specify the minimum gap required in order to move to the next snapping target. Defaults to `0` which means that snap targets are always used.\n\n#### `resizeRatio?: number | [number, number];`\n\nThe `resizeRatio` property is used to set the number of pixels the resizable component scales by compared to the number of pixels the mouse/touch moves. Defaults to `1` (for a 1:1 ratio). The number set is the left side of the ratio, `2` will give a 2:1 ratio.\n\nFor [number, number] means [resizeRatioX, resizeRatioY], more precise control.\n\n#### `lockAspectRatio?: boolean | number;`\n\nThe `lockAspectRatio` property is used to lock aspect ratio.\nSet to `true` to lock the aspect ratio based on the initial size.\nSet to a numeric value to lock a specific aspect ratio (such as `16/9`).\nIf set to numeric, make sure to set initial height/width to values with correct aspect ratio.\nIf omitted, set `false`.\n\n#### `lockAspectRatioExtraWidth?: number;`\n\nThe `lockAspectRatioExtraWidth` property enables a resizable component to maintain an aspect ratio plus extra width.\nFor instance, a video could be displayed 16:9 with a 50px side bar.\nIf omitted, set `0`.\n\n#### `lockAspectRatioExtraHeight?: number;`\n\nThe `lockAspectRatioExtraHeight` property enables a resizable component to maintain an aspect ratio plus extra height.\nFor instance, a video could be displayed 16:9 with a 50px header bar.\nIf omitted, set `0`.\n\n#### `bounds?: ('window' | 'parent' | HTMLElement);`\n\nSpecifies resize boundaries.\n\n#### `boundsByDirection?: boolean;`\n\nBy default max dimensions based on left and top element position.\nWidth grow to right side, height grow to bottom side.\nSet `true` for detect max dimensions by direction.\nFor example: enable `boundsByDirection` when resizable component stick on right side of screen and you want resize by left handler;\n\n`false` by default.\n\n#### `handleStyles?: HandleStyles;`\n\nThe `handleStyles` property is used to override the style of one or more resize handles.\nOnly the axis you specify will have its handle style replaced.\nIf you specify a value for `right` it will completely replace the styles for the `right` resize handle,\nbut other handle will still use the default styles.\n\n#### `handleClasses?: HandleClassName;`\n\nThe `handleClasses` property is used to set the className of one or more resize handles.\n\n#### `handleComponent?: HandleComponent;`\n\nThe `handleComponent` property is used to pass a React Component to be rendered as one or more resize handle. For example, this could be used to use an arrow icon as a handle..\n\n#### `handleWrapperStyle?: { [key: string]: string };`\n\nThe `handleWrapperStyle` property is used to override the style of resize handles wrapper.\n\n#### `handleWrapperClass?: string;`\n\nThe `handleWrapperClass` property is used to override the className of resize handles wrapper.\n\n#### `enable?: ?Enable | false;`\n\nThe `enable` property is used to set the resizable permission of a resizable component.\n\nThe permission of `top`, `right`, `bottom`, `left`, `topRight`, `bottomRight`, `bottomLeft`, `topLeft` direction resizing.\nIf omitted, all resizer are enabled.\nIf you want to permit only right direction resizing, set `{ top:false, right:true, bottom:false, left:false, topRight:false, bottomRight:false, bottomLeft:false, topLeft:false }`.\n\n#### `onResizeStart?: ResizeStartCallBack;`\n\n`ResizeStartCallBack` type is below.\n\n```javascript\ntype ResizeStartCallback = (\n  e: SyntheticMouseEvent\u003cHTMLDivElement\u003e | SyntheticTouchEvent\u003cHTMLDivElement\u003e,\n  dir: ResizableDirection,\n  refToElement: HTMLDivElement,\n) =\u003e void;\n```\n\nCalls when resizable component resize start.\n\n#### `onResize?: ResizeCallback;`\n\n#### `scale?: number`;\n\nThe `scale` property is used in the scenario where the resizable element is a descendent of an element using css scaling (e.g. - `transform: scale(0.5)`).\n\n#### `as?: string | React.ComponentType`;\n\nBy default the `Resizable` component will render a `div` as a wrapper. The `as` property is used to change the element used.\n\n### Basic\n\n`ResizeCallback` type is below.\n\n```javascript\ntype ResizeCallback = (\n  event: MouseEvent | TouchEvent,\n  direction: ResizableDirection,\n  refToElement: HTMLDivElement,\n  delta: NumberSize,\n) =\u003e void;\n```\n\nCalls when resizable component resizing.\n\n#### `onResizeStop?: ResizeCallback;`\n\n`ResizeCallback` type is below.\n\n```javascript\ntype ResizeCallback = (\n  event: MouseEvent | TouchEvent,\n  direction: ResizableDirection,\n  refToElement: HTMLDivElement,\n  delta: NumberSize,\n) =\u003e void;\n```\n\nCalls when resizable component resize stop.\n\n## Instance API\n\n#### * `updateSize(size: { width: number | string, height: number | string }): void`\n\nUpdate component size.\n\n`grid`, `snap`, `max/minWidth`, `max/minHeight` props is ignored, when this method called.\n\n- for example\n\n```javascript\nclass YourComponent extends Component {\n\n  // ...\n\n  update() {\n    this.resizable.updateSize({ width: 200, height: 300 });\n  }\n\n  render() {\n    return (\n      \u003cResizable ref={c =\u003e { this.resizable = c; }}\u003e\n        example\n      \u003c/Resizable\u003e\n    );\n  }\n\n  // ...\n}\n```\n\n## Contribute\n\nIf you have a feature request, please add it as an issue or make a pull request.\n\nIf you have a bug to report, please reproduce the bug in [CodeSandbox](https://codesandbox.io/s/ll587k677z) to help us easily isolate it.\n\n## Test\n\n``` sh\nnpm test\n```\n\n## Related\n\n- [react-rnd](https://github.com/bokuweb/react-rnd)\n- [react-sortable-pane](https://github.com/bokuweb/react-sortable-pane)\n","funding_links":["https://github.com/sponsors/bokuweb"],"categories":["UI Components","Uncategorized","\u003csummary\u003eUI Components\u003c/summary\u003e","Demos","React [🔝](#readme)"],"sub_categories":["Miscellaneous","Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbokuweb%2Freact-resizable-box","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbokuweb%2Freact-resizable-box","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbokuweb%2Freact-resizable-box/lists"}