Gathering detailed insights and metrics for re-resizable
Gathering detailed insights and metrics for re-resizable
Gathering detailed insights and metrics for re-resizable
Gathering detailed insights and metrics for re-resizable
📏 A resizable component for React.
npm install re-resizable
Typescript
Module System
Node Version
NPM Version
90.5
Supply Chain
94.6
Quality
86.2
Maintenance
100
Vulnerability
100
License
Updated on 04 Dec 2024
Minified
Minified + Gzipped
TypeScript (95.1%)
JavaScript (3.36%)
HTML (0.89%)
Shell (0.52%)
CSS (0.13%)
Cumulative downloads
Total Downloads
Last day
4.1%
Compared to previous day
Last week
-7.2%
Compared to previous week
Last month
14.6%
Compared to previous month
Last year
40.9%
Compared to previous year
51
📏 A resizable component for React.
CodeSandbox
CodeSandbox(TypeScript)
CodeSandbox(With hooks)
1$ npm install --save re-resizable
defaultSize
1import { Resizable } from 're-resizable'; 2 3<Resizable 4 defaultSize={{ 5 width: 320, 6 height: 200, 7 }} 8> 9 Sample with default size 10</Resizable>
If you only want to set the width, you can do so by providing just the width property. The height property will automatically be set to auto, which means it will adjust 100% of its parent's height:
1import { Resizable } from 're-resizable'; 2 3<Resizable 4 defaultSize={{ 5 width: 320 6 }} 7> 8 Sample with default size 9</Resizable>
size
If you use size
props, please manage state by yourself.
1import { Resizable } from 're-resizable'; 2 3<Resizable 4 size={{ width: this.state.width, height: this.state.height }} 5 onResizeStop={(e, direction, ref, d) => { 6 this.setState({ 7 width: this.state.width + d.width, 8 height: this.state.height + d.height, 9 }); 10 }} 11> 12 Sample with size 13</Resizable>
defaultSize?: { width?: (number | string), height?: (number | string) };
Specifies the width
and height
that the dragged item should start at.
For example, you can set 300
, '300px'
, 50%
.
If both defaultSize
and size
omitted, set 'auto'
.
defaultSize
will be ignored when size
set.
size?: { width?: (number | string), height?: (number | string) };
The size
property is used to set the size of the component.
For example, you can set 300
, '300px'
, 50%
.
Use size
if you need to control size state by yourself.
className?: string;
The className
property is used to set the custom className
of a resizable component.
style?: { [key: string]: string };
The style
property is used to set the custom style
of a resizable component.
minWidth?: number | string;
The minWidth
property is used to set the minimum width of a resizable component. Defaults to 10px.
It accepts viewport as well as parent relative units. For example, you can set 300
, 50%
, 50vw
or 50vh
.
Same type of values can be applied to minHeight
, maxWidth
and maxHeight
.
minHeight?: number | string;
The minHeight
property is used to set the minimum height of a resizable component. Defaults to 10px.
maxWidth?: number | string;
The maxWidth
property is used to set the maximum width of a resizable component.
maxHeight?: number | string
;The maxHeight
property is used to set the maximum height of a resizable component.
grid?: [number, number];
The grid
property is used to specify the increments that resizing should snap to. Defaults to [1, 1]
.
gridGap?: [number, number];
The gridGap
property is used to specify any gaps between your grid cells that should be accounted for when resizing. Defaults to [0, 0]
.
The value provided for each axis will always add the grid gap amount times grid cells spanned minus one.
snap?: { x?: Array<number>, y?: Array<number> };
The 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
.
snapGap?: number
The 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.
resizeRatio?: number | [number, number];
The 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.
For [number, number] means [resizeRatioX, resizeRatioY], more precise control.
lockAspectRatio?: boolean | number;
The lockAspectRatio
property is used to lock aspect ratio.
Set to true
to lock the aspect ratio based on the initial size.
Set to a numeric value to lock a specific aspect ratio (such as 16/9
).
If set to numeric, make sure to set initial height/width to values with correct aspect ratio.
If omitted, set false
.
lockAspectRatioExtraWidth?: number;
The lockAspectRatioExtraWidth
property enables a resizable component to maintain an aspect ratio plus extra width.
For instance, a video could be displayed 16:9 with a 50px side bar.
If omitted, set 0
.
lockAspectRatioExtraHeight?: number;
The lockAspectRatioExtraHeight
property enables a resizable component to maintain an aspect ratio plus extra height.
For instance, a video could be displayed 16:9 with a 50px header bar.
If omitted, set 0
.
bounds?: ('window' | 'parent' | HTMLElement);
Specifies resize boundaries.
boundsByDirection?: boolean;
By default max dimensions based on left and top element position.
Width grow to right side, height grow to bottom side.
Set true
for detect max dimensions by direction.
For example: enable boundsByDirection
when resizable component stick on right side of screen and you want resize by left handler;
false
by default.
handleStyles?: HandleStyles;
The handleStyles
property is used to override the style of one or more resize handles.
Only the axis you specify will have its handle style replaced.
If you specify a value for right
it will completely replace the styles for the right
resize handle,
but other handle will still use the default styles.
handleClasses?: HandleClassName;
The handleClasses
property is used to set the className of one or more resize handles.
handleComponent?: HandleComponent;
The 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..
handleWrapperStyle?: { [key: string]: string };
The handleWrapperStyle
property is used to override the style of resize handles wrapper.
handleWrapperClass?: string;
The handleWrapperClass
property is used to override the className of resize handles wrapper.
enable?: ?Enable | false;
The enable
property is used to set the resizable permission of a resizable component.
The permission of top
, right
, bottom
, left
, topRight
, bottomRight
, bottomLeft
, topLeft
direction resizing.
If omitted, all resizer are enabled.
If 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 }
.
onResizeStart?: ResizeStartCallBack;
ResizeStartCallBack
type is below.
1type ResizeStartCallback = ( 2 e: SyntheticMouseEvent<HTMLDivElement> | SyntheticTouchEvent<HTMLDivElement>, 3 dir: ResizableDirection, 4 refToElement: HTMLDivElement, 5) => void;
Calls when resizable component resize start.
onResize?: ResizeCallback;
scale?: number
;The 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)
).
as?: string | React.ComponentType
;By default the Resizable
component will render a div
as a wrapper. The as
property is used to change the element used.
ResizeCallback
type is below.
1type ResizeCallback = ( 2 event: MouseEvent | TouchEvent, 3 direction: ResizableDirection, 4 refToElement: HTMLDivElement, 5 delta: NumberSize, 6) => void;
Calls when resizable component resizing.
onResizeStop?: ResizeCallback;
ResizeCallback
type is below.
1type ResizeCallback = ( 2 event: MouseEvent | TouchEvent, 3 direction: ResizableDirection, 4 refToElement: HTMLDivElement, 5 delta: NumberSize, 6) => void;
Calls when resizable component resize stop.
updateSize(size: { width: number | string, height: number | string }): void
Update component size.
grid
, snap
, max/minWidth
, max/minHeight
props is ignored, when this method called.
1class YourComponent extends Component { 2 3 // ... 4 5 update() { 6 this.resizable.updateSize({ width: 200, height: 300 }); 7 } 8 9 render() { 10 return ( 11 <Resizable ref={c => { this.resizable = c; }}> 12 example 13 </Resizable> 14 ); 15 } 16 17 // ... 18}
If you have a feature request, please add it as an issue or make a pull request.
If you have a bug to report, please reproduce the bug in CodeSandbox to help us easily isolate it.
1npm test
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
9 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 8
Reason
Found 7/25 approved changesets -- score normalized to 2
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
44 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-12-02
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More