Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Drag/Drop Material-UI Cards

Is it possible to drag/drop and change the sorting of the Material UI Cards? If so, how? https://material-ui.com/components/cards/

like image 703
Reis Avatar asked Feb 03 '20 17:02

Reis


People also ask

Why is material UI so hard?

> Material UI uses a very similar theming system. The interface of the theme itself is different, but that seems to be about it there. Material UI implements Material UI by default and this is the main reason why it's hard to customize.

How do I fix the card height in material UI?

To set the card height with React Material UI, we can set the style prop of the Card . to set the style prop of the Card to an object that has the height of the card. As a result, the card height should be set to 45vw.


1 Answers

Is it possible to drag/drop and change the sorting of the Material UI Cards/

Yes.

how?

You can use react-dnd or react-beautiful-dnd.

They have alot of examples on how to do it and you can check it here for react-dnd.

Here is a working example of how to do it and, which is based on react-dnd examples.

And this is what react-beautiful-dnd has to say about both options:

There are a lot of libraries out there that allow for drag and drop interactions within React. Most notable of these is the amazing react-dnd. It does an incredible job at providing a great set of drag and drop primitives which work especially well with the wildly inconsistent html5 drag and drop feature. react-beautiful-dnd is a higher level abstraction specifically built for lists (vertical, horizontal, movement between lists, nested lists and so on). Within that subset of functionality react-beautiful-dnd offers a powerful, natural and beautiful drag and drop experience. However, it does not provide the breadth of functionality offered by react-dnd. So react-beautiful-dnd might not be for you depending on what your use case is.

like image 186
Vencovsky Avatar answered Oct 01 '22 02:10

Vencovsky