Skip to main content
Looking for design and usage docs?The Design Spec and Usage Guidelines documentation for the component will be available soon. Reach out to our team in the #ask-designsystem channel if you have questions or need assistance!

Common Examples

Bucketing

DndSort is a great way to create a drag-and-drop interface for moving items between different buckets.

Sorting a list

DndSort is also a great way to create a drag-and-drop interface for sorting a list of items.

Bucket and sort

DndSort can also be used to create a drag-and-drop interface for moving items between different buckets and sorting them within those buckets.Note this example also demonstrates cards initially beginning outside of the buckets.

Validation

DndSort provides ways to validate the drag-and-drop interaction. This is useful for preventing invalid interactions, such as moving an item to a bucket that does not accept it.

Basic Validation

The simplest way to validate is to use the type prop on the DndSort.Card component in conjunction with acceptedTypes prop on the DndSort.Zone component.
<DndSort.Zone acceptedTypes={["fruit"]}>
  <DndSort.Card type="fruit">🍎 Apple</DndSort.Card>
</DndSort.Zone>

Advanced Validation

A more advanced way to validate is to use the validator prop on the DndSort.Zone component. This prop takes a function which receives the item id. The function should return a boolean indicating whether the drop is valid. Here are some examples of how to use the validator prop:
// Limit the zone to only accept items with ids in an allowed list
const validator = (id) => validIds.includes(id);
<DndSort.Zone validator={validator}></DndSort.Zone>;

// Limit the based on a property of the item
const validator = (id) => people[id].isFriendly;
<DndSort.Zone validator={validator}></DndSort.Zone>;

// Limit the number of items in a zone to 5
const validator = () => zoneItems.length <= 5;
<DndSort.Zone validator={validator}></DndSort.Zone>;

Customization

DndSort provides a number of ways to customize the drag-and-drop interaction. This includes customizing the appearance of the items and zones.

Advanced zone rendering

The advancedRenderer prop of DndSort.Zone is an alternative to children, allowing you to customize the appearance of the drop zone based upon its internal state.This allows you to show different content when a drag is happening, when an item is over the drop zone, or if the dragged item is valid/invalid for the drop zone.

Custom card preview rendering

The previewRenderer prop of DndSort.Card offers a means to customize the appearance of the card when it is being dragged. This is useful for showing a different appearance for the card, such as a simpler version of a complex card.

Interactive Children

By default, the DndSort.Card places a button around the entire card. This is optimal for accessibility. But if you want to place interactive elements inside your card, it harms accessibility. To resolve this issue, set dragOnlyWithHandle on the DndSort.Card if your card has interactive elements.

Anti-Patterns

Nesting

DndSort does not support nesting. i.e. you may not use a zone as an item.This is an intentional design decision to guarantee these components meet our accessibility and usability standards.If you have a use case that requires nesting, please reach out to us. We would love to hear about your use case and help you find a solution.

Best Practices

dragOnlyWithHandle

<DndSort.Card dragOnlyWithHandle>
  <Button />
</DndSort.Card>
Do
Use the dragOnlyWithHandle prop if your card contains interactive elements.
<DndSort.Card>
  <Button />
</DndSort.Card>
Don’t
Don’t use interactive elements in cards without dragOnlyWithHandle.
Last modified on January 23, 2026