OneScript

Form

Group settings and controls in a scrollable form.

Form lays out controls such as Toggle, Picker, Slider, and Stepper in the platform's settings style. A Section child becomes a group.

import { Form, Section, Toggle, useState } from "onescript/views"

function Settings() {
  const [notifications, setNotifications] = useState(true)
  return (
    <Form>
      <Section
        header="General"
        footer="Applies to all devices."
      >
        <Toggle
          isOn={notifications}
          onChange={setNotifications}
        >
          Notifications
        </Toggle>
      </Section>
    </Form>
  )
}

Form scrolls by itself, so do not put it inside a ScrollView. Use formStyle to change its appearance. Also accepts Modifiers. It is only available in App and Action view sessions; widgets reject it with an unsupported view type error.

How is this guide?

Last updated on