vi studio

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]

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

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.