A react hook for making elements user resizable
npm install useresizehandle
# or with yarn
yarn add useresizehandle
import { useResizeHandle } from "useresize";
function Component() {
const {handleProps, containerProps } = useResizeHandle();
return (
<div>
<div {...containerProps}>
<div>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
</div>
<div {...handleProps}
style={{
...handleProps.style,
width: 30,
height: 30,
background: "black"
}}
></div>
</div>
)
}
The useResizeHandle
hook accepts an optional configuration object that can be used to alter the behaviour.
interface UseResizeConfig {
axis: "horizontal" | "vertical" | "both";
}
const config = {
axis: "horizontal",
}
const {handleProps, containerProps} = useResizeHandle(config)