You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Drag and drop is a common UI interaction that allows users to transfer data between two locations by directly moving a visual representation on screen. It is a flexible, efficient, and intuitive way for users to perform a variety of tasks, and is widely supported across both desktop and mobile operating systems.
25
-
26
24
React Aria supports traditional mouse and touch based drag and drop, but also implements keyboard and screen reader friendly interactions. Users can press <Keyboard>Enter</Keyboard> on a draggable element to enter drag and drop mode. Then, they can press <Keyboard>Tab</Keyboard> to navigate between drop targets, and <Keyboard>Enter</Keyboard> to drop or <Keyboard>Escape</Keyboard> to cancel. Touch screen reader users can also drag by double tapping to activate drag and drop mode, swiping between drop targets, and double tapping again to drop.
27
25
28
26
See the [drag and drop introduction](dnd.html) to learn more.
@@ -36,6 +34,7 @@ This example shows how to make a simple draggable element that provides data as
36
34
import {useDrag} from'@react-aria/dnd';
37
35
import {DropTarget} from'./DropTarget.tsx';
38
36
import'./useDragExample.css';
37
+
import'vanilla-starter/theme.css';
39
38
40
39
function Draggable() {
41
40
let {dragProps, isDragging} =useDrag({
@@ -151,9 +150,11 @@ A <TypeLink links={sharedDocs.links} type={sharedDocs.links[sharedDocs.exports.D
151
150
*`copy` – indicates that the dragged data will be copied to the target destination.
152
151
*`link` – indicates that there will be a relationship established between the source and target locations.
153
152
*`cancel` – indicates that the drag and drop operation will be canceled, resulting in no changes made to the source or target.
153
+
154
154
Many operating systems display these in the form of a cursor change, e.g. a plus sign to indicate a copy operation. The user may also be able to use a modifier key to choose which drop operation to perform, such as <Keyboard>Option</Keyboard> or <Keyboard>Alt</Keyboard> to switch from move to copy.
155
155
The `onDragEnd` event allows the drag source to respond when a drag that it initiated ends, either because it was dropped or because it was canceled by the user. The `dropOperation` property of the event object indicates the operation that was performed. For example, when data is moved, the UI could be updated to reflect this change by removing the original dragged element.
156
156
This example removes the draggable element from the UI when a move operation is completed. Try holding the <Keyboard>Option</Keyboard> or <Keyboard>Alt</Keyboard> keys to change the operation to copy, and see how the behavior changes.
Drag and drop is a common UI interaction that allows users to transfer data between two locations by directly moving a visual representation on screen. It is a flexible, efficient, and intuitive way for users to perform a variety of tasks, and is widely supported across both desktop and mobile operating systems.
26
-
27
25
React Aria supports traditional mouse and touch based drag and drop, but also implements keyboard and screen reader friendly interactions. Users can press <Keyboard>Enter</Keyboard> on a draggable element to enter drag and drop mode. Then, they can press <Keyboard>Tab</Keyboard> to navigate between drop targets, and <Keyboard>Enter</Keyboard> to drop or <Keyboard>Escape</Keyboard> to cancel. Touch screen reader users can also drag by double tapping to activate drag and drop mode, swiping between drop targets, and double tapping again to drop.
28
26
29
27
See the [drag and drop introduction](dnd.html) to learn more.
@@ -39,6 +37,7 @@ import type {TextDropItem} from '@react-aria/dnd';
39
37
import {useDrop} from'@react-aria/dnd';
40
38
import {Draggable} from'./Draggable.tsx';
41
39
import'./useDragExample.css';
40
+
import'vanilla-starter/theme.css';
42
41
43
42
function DropTarget() {
44
43
let [dropped, setDropped] =React.useState(null);
@@ -74,6 +73,7 @@ function DropTarget() {
74
73
*`directory` – references the contents of a directory
75
74
### Text
76
75
A <TypeLinklinks={sharedDocs.links}type={sharedDocs.exports.TextDropItem} /> represents textual data in one or more different formats. These may be either standard [mime types](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types) or custom app-specific formats. Representing data in multiple formats allows drop targets both within and outside an application to choose data in a format that they understand. For example, a complex object may be serialized in a custom format for use within an application, with fallbacks in plain text and/or rich HTML that can be used when a user drops data from an external application.
76
+
77
77
The example below finds the first available item that includes a custom app-specific type. The same draggable component as used in the above example is used here, but rather than displaying the plain text representation, the custom format is used instead.
78
78
79
79
```tsx render
@@ -114,8 +114,8 @@ function DropTarget() {
114
114
```
115
115
### Files
116
116
A <TypeLinklinks={sharedDocs.links}type={sharedDocs.exports.FileDropItem} /> references a file on the user's device. It includes the name and mime type of the file, and methods to read the contents as plain text, or retrieve a native [File](https://developer.mozilla.org/en-US/docs/Web/API/File) object which can be attached to form data for uploading.
117
-
This example accepts JPEG and PNG image files, and renders them by creating a local [object URL](https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL).
118
117
118
+
This example accepts JPEG and PNG image files, and renders them by creating a local [object URL](https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL).
@@ -208,6 +208,7 @@ A <TypeLink links={sharedDocs.links} type={sharedDocs.exports.DropOperation} />
208
208
*`copy` – indicates that the dragged data will be copied to the target destination.
209
209
*`link` – indicates that there will be a relationship established between the source and target locations.
210
210
*`cancel` – indicates that the drag and drop operation will be canceled, resulting in no changes made to the source or target.
211
+
211
212
Many operating systems display these in the form of a cursor change, e.g. a plus sign to indicate a copy operation. The user may also be able to use a modifier key to choose which drop operation to perform, such as <Keyboard>Option</Keyboard> or <Keyboard>Alt</Keyboard> to switch from move to copy.
212
213
The drag source can specify which drop operations are allowed for the dragged data (see the [useDrag docs](useDrag.html) for how to customize this). By default, the first allowed operation is allowed by drop targets, meaning that the drop target accepts data of any type and operation.
0 commit comments