Lessons · Getting started · 3 of 36
Your first app
A complete counter app, line by line.
Here is a complete app: a counter with a header and a round + button. Press Try it, or copy it into src/main.vi, and watch the phone update. Notice the three parts: data at the top, a function that changes the data, and containers that draw the screen. (Real projects split these parts into files; the lesson Files and projects shows how.)
# Data
count = 0
# Functions
increment():
count = count + 1
# The screen
main main_screen:
color: white
children:
header:
size: max, 12
color: purple[300]
arrange: center
children:
header_text:
text: "Simple Counter App"
text_style: 16, bold
body:
size: max, max
arrange: center
children:
counter:
size: 30
shape: rounded
color: purple[600]
arrange: center
text: "{count}"
text_style: 32, white
fab:
place: bottom right
size: 15
space_around: 16
shape: circle
color: blue
arrange: center
on_tap: increment()
children:
plus:
icon: plus
text_style: 28, white
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
- Welcome to ViWhat Vi is and how Vi Studio works.
- Vi in five minutesContainers, data, functions and layout in four small apps.
- Projects and templatesNew Project, Create blank project, and how a project is laid out.
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.