Lessons · The language · 6 of 36
Containers
Everything on screen is a container; children one per line.
Everything on the screen is a container: a box with attributes, one per line. A container can
hold other containers in children:, one per line.
main main_screen:
color: gray[100]
children:
header:
size: max, 15
color: purple[400]
arrange: center
children:
title:
text: "Containers"
text_style: 20, white
body:
size: max, max
arrange: center
children:
note
footer
note:
text: "A container defined on its own, used by name"
footer:
size: max, 10
color: purple[100]
- A child written inside
children:(likeheader:) belongs to its parent. - A child written by name (
note,footer) is a container defined on its own, at the left edge. Use that for pieces you show in several places. - Every container has a name, so you can find it, change it and reach it from code.
Several containers can share one style:
main row_of_cards:
arrange: row, spread
space_inside: 16
children:
card_a
card_b
card_c
card_a, card_b, card_c:
size: 30
color: teal[300]
shape: rounded
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 The language
- Comments and names# comments, <# blocks #> and snake_case names.
- Size and spacesize out of 100, and space_inside / between / around.
- Arrange and placeDirection, spot and spread; floating with place.
- Texttext and text_style.
- Colour, shape and imagesColours and shades, shape, shadow, see_through, outline, @images.
- Buttons, inputs and other kindsbutton, input, search, icon, link and scrolling lists.
- Eventson_tap, on_hold, on_touch, on_swipe, on_change, on_submit, on_hit.
- Data: lists and objectsVariables, lists, objects and the list helpers.
- FunctionsYour own functions and the built-in ones.
- Conditions and loopsif / else, the inline if, and, or, not, for and while.
- Programs without a screenmain functions and print().
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.