1.0.18 • Published 5 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-resize
With yarn
yarn add easy-resize
Props
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
5 months ago
1.0.17
5 months ago
1.0.16
5 months ago
1.0.9
5 months ago
1.0.11
5 months ago
1.0.10
5 months ago
1.0.15
5 months ago
1.0.14
5 months ago
1.0.13
5 months ago
1.0.12
5 months ago
1.0.8
6 months ago
1.0.7
6 months ago
1.0.6
6 months ago
1.0.5
6 months ago
1.0.4
6 months ago
1.0.3
6 months ago
1.0.2
6 months ago
1.0.1
6 months ago
1.0.0
6 months ago