Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
The react-rnd package is a React component that allows you to create resizable and draggable elements. It is highly customizable and can be used to build complex user interfaces with ease.
Draggable
This feature allows you to make any element draggable. The code sample demonstrates how to create a draggable component with default position and size.
import Rnd from 'react-rnd';
function DraggableComponent() {
return (
<Rnd
default={{ x: 0, y: 0, width: 320, height: 200 }}
>
<div style={{ border: '1px solid black', padding: '10px' }}>
Draggable Content
</div>
</Rnd>
);
}
Resizable
This feature allows you to make any element resizable. The code sample demonstrates how to create a resizable component with resizing enabled on all sides and corners.
import Rnd from 'react-rnd';
function ResizableComponent() {
return (
<Rnd
default={{ x: 0, y: 0, width: 320, height: 200 }}
enableResizing={{ top: true, right: true, bottom: true, left: true, topRight: true, bottomRight: true, bottomLeft: true, topLeft: true }}
>
<div style={{ border: '1px solid black', padding: '10px' }}>
Resizable Content
</div>
</Rnd>
);
}
Draggable and Resizable
This feature allows you to make any element both draggable and resizable. The code sample demonstrates how to create a component that can be dragged and resized.
import Rnd from 'react-rnd';
function DraggableResizableComponent() {
return (
<Rnd
default={{ x: 0, y: 0, width: 320, height: 200 }}
enableResizing={{ top: true, right: true, bottom: true, left: true, topRight: true, bottomRight: true, bottomLeft: true, topLeft: true }}
>
<div style={{ border: '1px solid black', padding: '10px' }}>
Draggable and Resizable Content
</div>
</Rnd>
);
}
react-draggable is a package that provides draggable functionality for React components. It is simpler and more focused on dragging compared to react-rnd, which also includes resizing capabilities.
react-resizable is a package that provides resizable functionality for React components. It is more focused on resizing compared to react-rnd, which also includes dragging capabilities.
react-grid-layout is a package that provides a grid layout system with draggable and resizable widgets. It is more complex and feature-rich compared to react-rnd, offering a complete layout system.
FAQs
A draggable and resizable React Component
The npm package react-rnd receives a total of 185,648 weekly downloads. As such, react-rnd popularity was classified as popular.
We found that react-rnd demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.