vi studio

Lessons · The language · 10 of 36

Colour, shape and images

Colours and shades, shape, shadow, see_through, outline, @images.

color: is the background. Colours have names (red, teal, gray…), shades from 50 (light) to 900 (dark) like blue[600], or rgb(r, g, b) with an optional fourth number from 0 (see-through) to 1 (solid). A hex colour goes in quotes: "#FF6B6B".

main swatches:
  arrange: row, center
  space_between: 10
  children:
    named:
      size: 20
      color: coral
      shape: circle
    shade:
      size: 20
      color: teal[700]
      shape: rounded
    mixed:
      size: 20
      color: rgb(255, 120, 0, 0.6)
      shadow: true
    faded:
      size: 20
      color: "#6B4EFF"
      see_through: 50
      outline: 2, purple[900]
Attribute Does
shape: square (default), rounded or circle
shadow: true a soft drop shadow
see_through: 50 50 % see-through (0 is solid, 100 invisible)
outline: 2, red a 2-point line round the edge; name sides for some: outline: bottom 1, gray
visible: false hides it (and the space it took)
image: @photo.jpg a picture behind the children; add fill to cover the box, blurred to blur it

@name means a file in the project's assets folder: @cat.png, @backgrounds/sky.jpg. Typing @ lists the files. Web pictures go in quotes: image: "https://…/photo.jpg".

main card:
  size: max, 40
  image: @hero.png, fill
  arrange: bottom left
  space_inside: 16
  children:
    caption:
      text: "Pictures come from the assets folder"
      text_style: 16, bold, 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 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.