For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /guide/native-plugins/hosted-children.md.
A plugin's native element can show the Angular elements inside it in a view of the platform's own, outside the page. For example, a system sheet, a popover or a dialog. This page shows how to keep those children interactive there.
Lynx sends a touch to the elements it finds from the page's root view. So children whose views you move out draw, but never get a tap.
showChildren(in:) moves the element's view into your container, with its children and its own background, border and shadow. It dispatches their touches from there.
returnChildren() puts it back.
In between, bindtap, bindtouchmove and gestures on the children work as they do on the page.
package com.example.greeterimport android.widget.FrameLayoutimport com.google.android.material.bottomsheet.BottomSheetDialogimport com.lynx.tasm.behavior.LynxContextimport com.lynx.tasm.behavior.LynxPropimport com.lynx.tasm.event.LynxDetailEventimport dev.angularlynx.shell.HostElementUIclass NativeSheet(context: LynxContext) : HostElementUI(context) { private var dialog: BottomSheetDialog? = null // The app's `open`, which may turn true again before the dismiss listener runs. private var open = false // The app closed it: Dialog posts the dismiss listener, so this lasts until it runs. private var closing = false @LynxProp(name = "open") fun setOpen(open: Boolean) { this.open = open val dialog = dialog if (open && dialog == null) { // An `open` that starts true: wait until Lynx has put the view on the page. if (mView.isAttachedToWindow) { show() } else { mView.post { if (this.open && this.dialog == null) show() } } } else if (!open && dialog != null && !closing) { closing = true dialog.dismiss() } } // The app removed the element: the sheet goes with it, without a `close`. override fun destroy() { open = false val sheet = dialog if (sheet != null && !closing) { closing = true sheet.dismiss() } super.destroy() } private fun show() { val sheet = BottomSheetDialog(mView.context) val content = FrameLayout(sheet.context) showChildren(content) sheet.setContentView(content) sheet.setOnDismissListener { dialog = null returnChildren() if (closing) { closing = false if (open) show() } else { // A swipe down, a tap outside or back closed it: tell the app. open = false lynxContext.eventEmitter.sendCustomEvent(LynxDetailEvent(sign, "close", hashMapOf<String, Any>())) } } sheet.show() dialog = sheet }}
The element is laid out on the page like any other, and keeps the width and height it has there. So give it the container's width, and keep it out of the way: below the page, or position: absolute off screen.
On iOS and Android, its background, border, box shadow and outline go into the container with it. On iOS, they follow a change of style while it's there.
Give it its shadow or outline before you open the container. On Android, a first one added while it's open puts the element back on the page until the container closes.
A shadow or outline that reaches outside the element can be cut off at the container's edges.