OneScript
UI

Overview

Present temporary content with sheet, alert, and related modifiers.

Presentation modifiers are methods of Modifier from onescript/views and work in App and Action views. Widgets do not support them.

ModifierPurpose
sheetSlide a card up from the bottom that can be swiped away.
fullScreenCoverCover the whole screen; you provide the close button.
popoverShow a bubble next to a view.
alertShow an alert, optionally with text fields.
confirmationDialogShow a set of actions to choose from.
presentationDetentsSet the heights a sheet can rest at.
presentationDragIndicatorShow or hide the sheet's drag indicator.
presentationContentInteractionChoose whether swiping resizes the sheet or scrolls its content.
presentationBackgroundInteractionChoose whether the page behind a sheet can be used.
interactiveDismissDisabledPrevent swipe to dismiss.

Controlled state

The script owns the presentation state: isPresented decides whether it shows, and onDismiss is required.

  • When the user dismisses natively (swiping a sheet down, tapping an alert button, tapping outside a popover), OneScript calls onDismiss, where you set isPresented to false.
  • When the script sets isPresented to false itself, the presentation closes without calling onDismiss.
  • If onDismiss leaves the state true, the content is presented again. To stop the user from dismissing, use interactiveDismissDisabled.
import { app } from "onescript"
import { Button, Modifier, Text, useState } from "onescript/views"

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

  return (
    <Button
      action={() => setShown(true)}
      modifier={Modifier.sheet({
        isPresented: shown,
        onDismiss: () => setShown(false),
        content: <Text>Hello</Text>,
      })}
    >
      Show
    </Button>
  )
}

await app.show(<Screen />)

Behavior

  • Modifiers chained before a presentation modifier apply to the modified view, and modifiers chained after it apply to the whole result, matching SwiftUI's modifier order.
  • Keep presentation modifiers attached and only toggle isPresented. Adding or removing one between renders recreates the modified view and loses the component state inside it.
  • The content of sheet, fullScreenCover, and popover is a new presentation level: it can hold its own NavigationStack, and a NavigationLink inside it never pushes onto the outer stack.
  • Presentation modifiers also work on a root NavigationStack or TabView.

How is this guide?

Last updated on

On this page