OneScript

popover

Show a bubble next to a view.

popover(options) shows a bubble next to the modified view, and tapping outside closes it. It stays a bubble on iPhone instead of becoming a sheet.

import { Button, Modifier, Text, useState } from "onescript/views"

function Hint() {
  const [shown, setShown] = useState(false)

  return (
    <Button
      action={() => setShown(true)}
      modifier={Modifier.popover({
        isPresented: shown,
        onDismiss: () => setShown(false),
        arrowEdge: "top",
        content: (
          <Text modifier={Modifier.padding(16)}>
            Long-press a row to reorder it
          </Text>
        ),
      })}
    >
      Tip
    </Button>
  )
}
OptionTypeDescription
isPresentedbooleanWhether the popover is shown.
onDismiss() => voidCalled when the user dismisses the popover; set isPresented to false here.
contentViewChildThe bubble content.
arrowEdge"top" | "bottom" | "leading" | "trailing"Optional. The edge the arrow points from. The system decides when omitted.

The bubble uses the content's ideal size, so long text doesn't wrap on its own. Give the content a width with frame.

How is this guide?

Last updated on