getProperty()

Category:UI Controls

You will generally want to define properties of UI elements using Design mode in App Lab. But sometimes you will want to change the value of a property in your app based on the user or in response to an event. getProperty() lets you see the current value of any property listed in Design mode for a given UI element.

Possible Properties

Property Value Works on
"width" number All Design mode elements except screens
"height" number All design mode elements except screens
"x" number All design mode elements except screens
"y" number All design mode elements except screens
"text-color" color string Button, text input, label, dropdown, and text area
"background-color" color string Button, text input, label, dropdown, screen, and text area
"border-width" number Button, text input, label, dropdown, image, photo select, and text area
"border-color" color string Button, text input, label, dropdown, image, photo select, and text area
"border-radius" number Button, text input, label, dropdown, image, photo select, and text area
"font-family" string Button, text input, label, dropdown, and text area
"font-size" number Button, text input, label, dropdown, and text area
"text-align" string ("left", "right", "center", or "justify") Button, label, text area
"hidden" boolean All design mode elements except screens
"text" string Button, label, text area
"placeholder" string Text input
"image" string Button, image
"group-id" string Radio button
"checked" boolean Radio button, checkbox
"readonly" boolean Text area
"options" list of values Dropdown
"value" number Slider
"min" number Slider
"max" number Slider
"step" number Slider
"fit" string Image
"index" number Dropdown

Syntax

getProperty(id, property)

Parameters

NameTypeRequired?Description
id String The ID of the UI element to which this function applies. Must begin with a letter, contain no spaces, and may contain letters, digits, - and _.
property String The property to get.

Tips

  • If you select a UI element that was created in Design mode, the dropdown for property will filter to just the possible set of properties that can be set for the UI element.
  • setProperty() can be used to change the value of a given property.

Found a bug in the documentation? Let us know at documentation@code.org