Hyperview

Hyperview

  • Guides
  • Examples
  • Reference
  • Blog

›Input Elements

Reference

  • Index

Behaviors

  • Behavior Attributes
  • <behavior>
  • Alert
  • Share

Display Elements

  • <doc>
  • <screen>
  • <header>
  • <body>
  • <view>
  • <text>
  • <image>
  • <list>
  • <section-list>
  • <section>
  • <section-title>
  • <items>
  • <item>
  • <spinner>
  • <web-view>

Input Elements

  • <form>
  • <text-field>
  • <select-single>
  • <select-multiple>
  • <option>
  • <picker-field>
  • <picker-item>
  • <switch>
  • <date-field>

Style Elements

  • <styles>
  • <style>
  • <modifier>

Hyperview Client

  • Hyperview component
  • Custom elements
  • Custom behaviors
  • Loading Screen

Hyperview Navigation

  • <navigator>
  • <nav-route>

<switch>

The <switch> element represents a boolean input field. When pressed, the switch toggles values between "on" and "off". The value of the <switch> get serialized as form data when a <form> gets submitted.

selected

<form>
  <switch name="notifications" value="on" />
</form>

Structure

A <switch> element can appear anywhere within a <form> element.

Attributes

  • Structure
  • Attributes
    • Behavior attributes
    • name
    • value
    • style
    • id
    • hide

Behavior attributes

A <switch> element accepts the standard behavior attributes, with change trigger.

name

TypeRequired
stringYes

The name of the field within a <form> element. This name will be used when serializing a form to form data that gets sent in a server request.

value

TypeRequired
"on", "off"No (defaults to "off")

The value of the field. A value of "on" corresponds to a switch that is on.

style

TypeRequired
stringNo

A space-separated list of styles to apply to the element. See Styles. Note that the only style that will be applied to the switch is color and backgroundColor. The color will be applied to the thumb of the switch (the part that moves between on/off). The background color will be applied to the track of the switch.

<switch> supports the selected style modifier. See Modifiers for more details. The backgroundColor and color in the selected modifier will be applied when the switch is on.

id

TypeRequired
stringNo

A global attribute uniquely identifying the element in the whole document.

hide

TypeRequired
false (default), trueNo

If hide="true", the element will not be rendered on screen. If the element or any of the element's children have a behavior that triggers on "load" or "visible", those behaviors will not trigger while the element is hidden.

← <picker-item><date-field> →
  • Structure
  • Attributes
Hyperview
Docs
ExamplesHyperview Reference
More
BlogGitHubStar
Copyright © 2025 Instawork