1.0.18 • Published 10 months ago
easy-resize v1.0.18
Easy Resize
A React component that allows you to have an easily resizable container.
Installation
With npm
npm i easy-resizeWith yarn
yarn add easy-resizeProps
| Prop | Type | Default | Description |
|---|---|---|---|
allowedDirections | Array<'n'\|'s'\|'w'\|'e'\|'nw'\|'ne'\|'sw'\|'se'> | ['n','s','w','e','nw','ne','sw','se'] | Directions where resize handles should appear |
minWidth | number | 0 | Minimum width the container can be resized to |
minHeight | number | 0 | Minimum height the container can be resized to |
initialWidth | number | 200 | Initial width of the container |
initialHeight | number | 200 | Initial height of the container |
lockAspectRatio | boolean | false | Locks aspect ratio when resizing |
onChangeStarted | (width: number, height: number) => void | () => {} | Callback fired when resizing is started |
onChangeFinished | (width: number, height: number) => void | () => {} | Callback fired when resizing is complete |
resizeHandle | ReactNode | <div style={{width: 10, height: 10, backgroundColor: "gray"}} /> | Custom resize handle for edges |
cornerResizeHandle | ReactNode | Matches resizeHandle | Custom resize handle for corners |
sx | CSSProperties | {} | Additional CSS styles for the container |
Examples
Basic Usage with Custom Initial Size
import ResizableContainer from 'easy-resize'
<ResizableContainer
initialWidth={400}
initialHeight={300}
minWidth={200}
minHeight={200}
>
<div>
Content goes here
</div>
</ResizableContainer>Limiting Resize Directions
import ResizableContainer from 'easy-resize'
<ResizableContainer
allowedDirections={['e', 'se', 's']} // Only allow resizing from right side, bottom, and bottom-right corner
>
<div>
Content goes here
</div>
</ResizableContainer>Using Custom Resize Handles
- You can specify custom resize handles.
- There is a basic resize handle option, and a corner resize handle option, if only the basic resize handle is defined then this will also be used for the corners.
- Corner resize handles will automatically be rotated to be facing towards the corner.
import ResizableContainer from 'easy-resize'
<ResizableContainer
resizeHandle={<div style={{ width: 8, height: 8, backgroundColor: 'blue' }} />}
cornerResizeHandle={<div style={{ width: 10, height: 10, backgroundColor: 'red' }} />}
>
<div>
Content goes here
</div>
</ResizableContainer>1.0.18
10 months ago
1.0.17
11 months ago
1.0.16
11 months ago
1.0.9
11 months ago
1.0.11
11 months ago
1.0.10
11 months ago
1.0.15
11 months ago
1.0.14
11 months ago
1.0.13
11 months ago
1.0.12
11 months ago
1.0.8
11 months ago
1.0.7
11 months ago
1.0.6
11 months ago
1.0.5
11 months ago
1.0.4
11 months ago
1.0.3
11 months ago
1.0.2
11 months ago
1.0.1
11 months ago
1.0.0
11 months ago