{/* Copyright 2026 Adobe. All rights reserved. This file is licensed to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */} import {Layout} from '../../src/Layout'; export default Layout; import {FunctionAPIGroup} from '../../src/FunctionAPI'; import {InterfaceType} from '../../src/types'; import docs from 'docs:@react-aria/dnd'; import statelyDocs from 'docs:@react-stately/dnd'; export const section = 'Interactions'; export const description = 'Provides the behavior and accessibility implementation for dropping items onto a collection.'; # useDroppableCollection {docs.exports.useDroppableCollection.description} ```tsx render "use client"; import React from 'react'; import {useListBox, useOption} from 'react-aria/useListBox'; import {useListState} from 'react-stately/useListState'; import {Item} from 'react-stately/Item'; import type {Node} from '@react-types/shared'; import {useFocusRing} from 'react-aria/useFocusRing'; import {mergeProps} from 'react-aria/mergeProps'; import {useDroppableCollectionState} from 'react-stately/useDroppableCollectionState'; import {useDroppableCollection, useDroppableItem, useDropIndicator} from 'react-aria/useDroppableCollection'; import {useDrag} from 'react-aria/useDrag'; import {ListKeyboardDelegate} from 'react-aria/ListKeyboardDelegate'; import {ListDropTargetDelegate} from 'react-aria/ListDropTargetDelegate'; import 'vanilla-starter/theme.css'; function ListBox(props: Parameters[0] & Parameters[0] & {label?: React.ReactNode, onItemDrop?: Parameters[0]['onItemDrop']}) { // Set up the list box as normal. See the useListBox docs for details. let state = useListState(props); let ref = React.useRef(null); let {listBoxProps} = useListBox(props, state, ref); // Set up the drop state and keyboard/drop target delegates. let dropState = useDroppableCollectionState({ ...props, collection: state.collection, selectionManager: state.selectionManager }); let {collectionProps} = useDroppableCollection({ ...props, keyboardDelegate: new ListKeyboardDelegate(state.collection, state.disabledKeys, ref), dropTargetDelegate: new ListDropTargetDelegate(state.collection, ref) }, dropState, ref); let isDropTarget = dropState.isDropTarget({type: 'root'}); return (
    {[...state.collection].map(item => (
); } function Option({item, state, dropState}: {item: Node, state: ReturnType, dropState: ReturnType}) { let ref = React.useRef(null); let {optionProps} = useOption({key: item.key}, state, ref); let {isFocusVisible, focusProps} = useFocusRing(); // Register the item as a drop target. let {dropProps, isDropTarget} = useDroppableItem( {target: {type: 'item', key: item.key, dropPosition: 'on'}}, dropState, ref ); return ( <>
  • {item.rendered}
  • {state.collection.getKeyAfter(item.key) == null && } ); } function DropIndicator(props: Parameters[0] & {dropState: ReturnType}) { // Drop indicators must use role="option" inside a listbox to keep the ARIA tree valid. let ref = React.useRef(null); let {dropIndicatorProps, isHidden, isDropTarget} = useDropIndicator(props, props.dropState, ref); if (isHidden) { return null; } return (
  • ); } function Draggable() { let {dragProps, isDragging} = useDrag({ getItems: () => [{'text/plain': 'budget.xls'}] }); return (
    budget.xls
    ); }
    alert(`Dropped on ${e.target.key}`)}> Documents proposal.doc presentation.ppt
    ``` ## API