vi studio

Lessons · Getting started · 2 of 36

Vi in five minutes

Containers, data, functions and layout in four small apps.

main home:
  color: blue[50]
  arrange: center
  children:
    greeting:
      text: "Hello!"
      text_style: 32, bold, blue[700]

Data makes the screen change

count = 0

main counter:
  arrange: center
  space_between: 16
  children:
    display:
      text: "Count: {count}"
      text_style: 32
    plus:
      button: "+ 1"
      on_tap: count = count + 1

Functions do the work

tasks = ["Buy milk", "Call Sam"]

add_task(name):
  tasks.add(name)

main home:
  space_inside: 20
  space_between: 10
  children:
    title:
      text: "{tasks.count} tasks"
      text_style: 24, bold
    task_row
    add:
      button: "Add one"
      on_tap: add_task("Task {tasks.count + 1}")

task_row:
  repeat: task in tasks
  size: max, auto
  space_inside: 12
  color: gray[100]
  shape: rounded
  text: task
  on_hold: tasks.remove(task)

Sizes, space and layout

main home:
  arrange: column, spread
  space_inside: 24
  children:
    banner:
      size: max, 30
      color: purple[400]
      shape: rounded
    tiles:
      size: max, auto
      arrange: row, spread
      children:
        tile_a:
          size: 30
          color: orange[300]
        tile_b:
          size: 30
          color: green[300]
        tile_c:
          size: 30
          color: blue[300]

Every example here runs in Vi Studio: open it in your browser (phones too) and press Start learning on the welcome page. Each code block there has a Try it button that runs it in the phone preview.

More in Getting started

About Vi. Vi is a free, open-source programming language for building real mobile apps. You describe each screen in plain words, and Vi compiles it to React Native (Expo) for Android, iOS and the web. Its editor, Vi Studio, runs on Windows, in any browser and on your phone, with the app running live as you type. Read more about Vi.