# How Options work

This chapter explains how options work in ReDrop. Options are a critical part of the library, and understanding them thoroughly is essential for effective usage.

For detailed information on type definitions, default values, and explanations for each option in the draggable and droppable options objects, please refer to the [Options Documentation](../../api-docs/options).

### Understanding Options

```javascript
import { Redrop } from "redrop-dnd";

const dndManager = new Redrop();

const draggableItem = dndManager.makeDraggable("#draggableElm", draggableOptions);
const droppableItem = dndManager.makeDroppable("#dropzone", droppableOptions);
```

As shown, the second argument in the [`makeDraggable()`](../../api-docs/redrop/makedraggable) and [`makeDroppable()`](../../api-docs/redrop/makedroppable) methods is used to pass options. Options are optional, and in the above example, we haven't defined any. Let’s define some options to understand this further:

```javascript
import { Redrop } from "redrop-dnd";

const draggableOptions = {
  modifier: {
    cursor: {
      offset: {
        preset: "center",
      },
    },
  },
};

const dndManager = new Redrop({
  draggableOptions: {
    identifier: {
      type: "draggableItem",
    },
  },
  droppableOptions: {
    identifier: {
      type: {
        accept: ["draggableItem", "draggables"],
      },
    },
  },
});

const draggableItem = dndManager.makeDraggable("#draggableElm", draggableOptions);
```

### Key Points About Options

1. **Global vs. Local Options**:\
   ReDrop allows you to set global options when initializing the `Redrop` instance. These global options apply to all draggable and droppable elements unless overridden by local options provided in the [`makeDraggable()`](../../api-docs/redrop/makedraggable) or [`makeDroppable()`](../../api-docs/redrop/makedroppable) methods.
2. **Default Options**:\
   If no options are set, ReDrop uses default options. You can refer to the [_Options Documentation_](../../api-docs/options) for details on these defaults.
3. **Selective Configuration**:\
   You don’t need to define all options explicitly. Only set the ones you need to customise, and ReDrop will use default values for the rest.
4. **Option Hierarchy**:
   * Global options apply to all elements for all the elements created with same instance.
   * Local options override global options for specific elements.
5. **Identifiers**: both draggable and droppable options have identifier options which you need to understand properly. It contains the following two properties
   * **`id`**: Each draggable or droppable element requires a unique `id`. If not provided, a default unique ID will be generated.
   * **`type`**: The `type` property links draggable and droppable elements. For example, if a draggable item has a type `"draggableItem"`, the droppable options must include `{ accept: ["draggableItem", "draggables"] }` to accept that draggable item. Multiple types can be included if required.

By leveraging these options effectively, you can customise the drag-and-drop behaviour of your application without the need to set every option manually.



I highly recommend you to please visit [options](../../api-docs/options "mention") documentation to understand each options available with their explanation and default options.

