Skip to main content

UI Components

These are the visual elements you drag onto the canvas in CCraft Studio. On export, each one becomes an instance of a Lua class in components/ (see Generated File Reference). This page lists every component and the properties it carries into the generated code.

All components share a common set of base properties; each type then adds its own. The tables below list the property name and type that appear in the exported Lua — not editor defaults, since every element is written with its current values.

Shared properties

Every element is created from screens/<ScreenName>.lua with these base fields:

PropertyTypeDescription
namestringUnique element name (used by getChild)
typestringElement type: label, button, container, …
x, ynumberResolved top‑left position (1‑based)
width, heightnumberResolved size in characters
widthUnit, heightUnitpx | % | fillHow the size was specified
rawWidth, rawHeightnumberOriginal %/fill value (only when not px)
bgColorcolorBackground color
visiblebooleanWhether the element is drawn / hit‑tested
zIndexnumberDraw + hit‑test order (higher is on top)
parentNamestringName of the containing container/panel (if nested)
screenNamestringName of the owning screen

Size units

UnitMeaning
pxFixed number of characters
%Percentage of the parent's inner size (stored in rawWidth/rawHeight)
fillGrow to fill the available space

Components

Label

Static, non‑interactive text.

PropertyTypeDescription
textstringThe text to display
textAlignleft | center | rightHorizontal alignment
textColorcolorText color

Button

A clickable button with separate colors for its focused (pressed) state.

PropertyTypeDescription
textstringButton label
textAlignleft | center | rightHorizontal alignment
textColorcolorText color
focusBgColorcolorBackground while pressed
focusTextColorcolorText color while pressed

Events: clicked, focused, released, text_changed.

Container

An invisible layout group. Lays out its children with flex or grid rules (see Layout).

PropertyTypeDescription
displayflex | gridLayout algorithm
flexDirectionrow | columnMain axis (flex only)
gap, gapUnitnumber, px | %Space between children
alignItemsstart | center | endCross‑axis alignment
justifyContentstart | center | end | space-betweenMain‑axis distribution
gridTemplateCols, gridTemplateRowsnumberGrid size (grid only)
padding, paddingUnitnumber, px | %Inner spacing

Panel

A titled, bordered container. Same layout options as Container, plus a title bar and border. The border insets its content by one character on every side.

PropertyTypeDescription
textstringTitle shown in the bar
textAlignleft | center | rightTitle alignment
textColorcolorTitle text color
borderColorcolorBorder color
titleBgColorcolorTitle bar background
…all Container layout propsSame flex/grid options as Container

ProgressBar

A fillable bar that can fill in any direction.

PropertyTypeDescription
textstringLabel drawn over the bar
textAlignleft | center | rightLabel alignment
progressnumber (0–100)Fill amount
progressColorcolorFilled portion color
textColorcolorLabel color
orientationsee OrientationFill direction

Events: progress_changed, text_changed.

Slider

A draggable control that maps a handle position to a value range.

PropertyTypeDescription
from, tonumberValue range bounds
valuenumberCurrent value
handleColorcolorHandle color
filledColorcolorFilled track color
orientationsee OrientationTravel direction

Events: value_changed.

CheckBox

A labelled toggle.

PropertyTypeDescription
textstringLabel text
checkedbooleanWhether it's ticked
checkIconstringCharacter shown when checked
textColorcolorLabel color
boxColorcolorBox color when unchecked
checkedColorcolorBox color when checked
textAlignleft | center | rightLabel alignment

Events: toggled, checked, unchecked, text_changed.

Input

An editable single‑line text field with a placeholder.

PropertyTypeDescription
textstringCurrent text value
placeholderstringHint shown when empty
textColorcolorText color
placeholderColorcolorPlaceholder color
textAlignleft | center | rightText alignment

Events: key_pressed, focused, text_changed.

Layout: containers & panels

Containers and panels position their children automatically; the exporter pre‑computes the resulting coordinates, and the runtime re‑resolves them for the actual display size.

  • Flex (display = "flex") lays children along a main axis set by flexDirection (row or column). justifyContent distributes space along that axis; alignItems aligns on the cross axis; gap spaces children apart.
  • Grid (display = "grid") arranges children into gridTemplateCols × gridTemplateRows cells.
  • padding insets the children; a Panel additionally reserves one character of border on every side.
  • % and fill sized children share the leftover space; mixing them with px children works as you'd expect.

Orientation

ProgressBar and Slider fill/travel in one of four directions:

ValueDirection
hltrHorizontal, left → right
hrtlHorizontal, right → left
vttbVertical, top → bottom
vbttVertical, bottom → top

Colors

Colors map directly to the 16 CC: Tweaked colors and are emitted as colors.<name> in the generated Lua.

NameLuaHex
whitecolors.white#F0F0F0
orangecolors.orange#F2B233
magentacolors.magenta#E57FD8
lightBluecolors.lightBlue#99B2F2
yellowcolors.yellow#DEDE6C
limecolors.lime#7FCC19
pinkcolors.pink#F2B2CC
graycolors.gray#4C4C4C
lightGraycolors.lightGray#999999
cyancolors.cyan#4C99B2
purplecolors.purple#B266E5
bluecolors.blue#3366CC
browncolors.brown#7F664C
greencolors.green#57A64E
redcolors.red#CC4C4C
blackcolors.black#111111

Special characters in text

Any text property can embed a CC: Tweaked character code using a \NN token, where NN is the character's number. At render time the runtime converts it with string.char. For example "Button \17" renders the ▶ arrow glyph (character 17).

See also