← Interface components

UI.FlipCard

luastra/ui
UI.FlipCard(input: Input): Node

Creates a fixed two-sided 3D surface whose first child is the front and second child is the back. A rotationY motion from Motion.flip controls which face is visible while both sides share the same bounds.

Mental model

This is a declarative node: app.render describes it again from current state, while the host matches its stable id to the existing view.

Before you use it

Add luastra/ui to this module's dependencies in luastra.json, then import it with require("luastra/ui"). The project must declare the ui.render capability. app.render must return one UI.Screen root; place this node inside that tree rather than invoking it for a hidden side effect.

How it fits

The constructor validates its fields immediately and returns a UI.Node. After app.render returns, the host reconciles that node by stable id with the current semantic DOM-based interface. Current desktop and mobile hosts package the same web artifact; native adapters are used at capability boundaries.

When to use it

Use UI.FlipCard for reveal interactions where two complete visual trees occupy one card-sized area. Use Layer inside either face when that face needs an image, shape, and overlaid text.

Shared parameter groups

visualmotion

Parameters

ParameterType / valuesDescription
idlowercase path, requiredUnique ID.
childrenexactly 2 UI.NodeFirst child is the front and second is the back; FlipCard owns the size.
marginnone | xs | sm | md | lg | xlAll-side outer spacing. Group: Layout and surfaces.
marginX / marginYnone | xs | sm | md | lg | xlAxis-specific outer spacing. Group: Layout and surfaces.
marginTop / marginBottom / marginStart / marginEndnone | xs | sm | md | lg | xlLogical side-specific outer spacing. Group: Layout and surfaces.
classNamesafe string ≤ 256 bytesAdditional admitted class tokens. Group: Layout and surfaces.
rolealert | group | statusSupported ARIA role. Group: State and semantics.
labelstringAccessible name. Group: State and semantics.
hiddenbooleanVisibility state. Group: State and semantics.
motion{ [property]: Tween | Sequence }Opacity, rotation, scale, and translation channels. Group: Events and motion.
width / height1…4096CSS-pixel size. Group: Image, Shape, and FlipCard.
aspectRatio0.05…20Aspect ratio. Group: Image, Shape, and FlipCard.

Children and layout

First child is the front and second is the back; FlipCard owns the size.

Accessibility and keyboard

A stable id, logical render-tree order, and visible labels preserve predictable keyboard and screen-reader navigation.

Common mistakes

  • Passing anything other than exactly two sides.
  • Sizing only a child Shape instead of the FlipCard itself.

Returns

Node — a validated declarative UI node that becomes part of the next host-neutral render tree.

What happens next

A validated declarative node appears after it is returned as part of the current render tree.

Failures and fixes

Invalid fields, duplicate IDs, unsupported child combinations, or a missing ui.render capability fail during check, render-tree validation, or host startup.

Availability

Source API in 0.5.0-alpha; the public installer targets 0.5.0-alpha. Verify host-specific behavior against the selected SDK.

Focused example

UI.FlipCard {
    id = "game/card",
    width = 274,
    height = 382,
    motion = Motion.flip { fromDeg = revealed and 0 or 180, toDeg = revealed and 180 or 0, durationMs = 500 },
    UI.Image { id = "game/card/back", source = cardBack, label = "Hidden card" },
    UI.Shape { id = "game/card/color", shape = "roundedRectangle", width = 274, height = 382, fill = hiddenColor },
}

Continue learning

Prerequisites

UI.LayerUI.CardUI.Shape

Complete inventory

View all pages in Interface components
← Previous: UI.TableCellNext: UI.Image →