New Compose Multiplatform components arrived on Composables UICheck it out →

Modifier in Compose Foundation



Configures the current node and any children nodes as a Content Receiver.

Content in this context refers to a [TransferableContent] that could be received from another app through Drag-and-Drop, Copy/Paste, or from the Software Keyboard.

There is no pre-filtering for the received content by media type, e.g. software Keyboard would assume that the app can handle any content that's sent to it. Therefore, it's crucial to check the received content's type and other related information before reading and processing it. Please refer to [TransferableContent.hasMediaType] and [TransferableContent.clipMetadata] to learn more about how to do proper checks on the received item.

Last updated:


dependencies {


fun Modifier.contentReceiver(
    receiveContentListener: ReceiveContentListener


receiveContentListenerListener to respond to the receive event. This interface also includes a set of callbacks for certain Drag-and-Drop state changes. Please checkout [ReceiveContentListener] docs for an explanation of each callback.

Code Example


fun ReceiveContentFullSample() {
    val state = rememberTextFieldState()
    var images by remember { mutableStateOf<List<ImageBitmap>>(emptyList()) }
    var dragging by remember { mutableStateOf(false) }
    var hovering by remember { mutableStateOf(false) }
    Column {
        Row {
            images.forEach {
                Image(bitmap = it, contentDescription = null)
            state = state,
            modifier = Modifier
                    when {
                        dragging -> Color.Red
                        hovering -> Color.Green
                        else -> MaterialTheme.colors.background
                    receiveContentListener = object : ReceiveContentListener {
                        override fun onDragStart() {
                            dragging = true

                        override fun onDragEnd() {
                            hovering = false
                            dragging = false

                        override fun onDragEnter() {
                            hovering = true

                        override fun onDragExit() {
                            hovering = false

                        override fun onReceive(
                            transferableContent: TransferableContent
                        ): TransferableContent? {
                            if (!transferableContent.hasMediaType(MediaType.Image)) {
                                return transferableContent
                            val newImages = mutableListOf<ImageBitmap>()
                            return transferableContent
                                .consume { item ->
                                    // only consume this item if we can read an imageBitmap
                                        ?.let { newImages += it; true } ?: false
                                .also {
                                    images = newImages