Data-driven look
Three things let a list look like it was designed for its data. All three are checked by ynch check, and none of them runs code.


A card you can tap
Section titled “A card you can tap”Card, Row and Cover accept an action, the same one a Button takes. The whole block then responds to a tap, with press feedback. Inside a list, the action can pass a field of the row as a route parameter.
{ "id": "question-row", "type": "Card", "props": {}, "preset": "row-card", "children": [], "action": { "type": "navigate", "routeId": "question", "parameters": { "card-id": { "source": "field", "model": "card", "field": "id" } } }}Color and icon from the row
Section titled “Color and icon from the row”bindings.tint names a text field that holds a color as #RRGGBB. Card, Cover, Icon, Badge, ProgressBar and ProgressRing use it as their fill; a Card or Cover turns it into a soft gradient. A value that is not exactly #RRGGBB is ignored, and the block keeps its own style.
An Icon’s bindings.value names a text field that holds an icon name. An unknown name falls back to the icon’s own name.
{ "id": "topic-cover", "type": "Cover", "props": { "height": "sm", "contentAlign": "bottom" }, "children": [ { "id": "topic-icon", "type": "Icon", "props": { "name": "book", "label": "Topic", "size": "lg" }, "bindings": { "value": { "model": "topic", "field": "icon" } }, "style": { "color": "$color.on-accent" } } ], "bindings": { "tint": { "model": "topic", "field": "color" } }, "style": { "backgroundColor": "$color.raised", "align": "end" }}Show only when a value matches
Section titled “Show only when a value matches”when draws a component only while a field of the enclosing list row (or form) equals a value: a literal, or a parameter of the current route. It works on every component except Screen.
{ "id": "tag-hard", "type": "Badge", "props": { "text": "Hard" }, "when": { "model": "card", "field": "difficulty", "is": { "source": "literal", "value": "hard" } }, "style": { "color": "$color.error", "backgroundColor": "$color.error-soft" }}Comparing with a route parameter marks the row the user came from:
{ "id": "right-yours", "type": "Badge", "props": { "text": "Your answer", "icon": "check" }, "when": { "model": "choice", "field": "id", "is": { "source": "route", "parameter": "choice-id" } }, "style": { "color": "$color.ink", "backgroundColor": "$color.success" }}- The field must belong to the model of the enclosing RecordList or Form, and the list’s operation must load it.
- A literal must be a value the field can hold. Text never equals a number, and a number never equals true or false.
- There are no other comparisons and no expressions. To show one of several looks, write one component per value, each with its own
when.
Showing something only when a value is there
Section titled “Showing something only when a value is there”On Ynch 1.1 (build 36 and later), when can ask directly: "is": {"source": "test", "test": "not-empty"}, and it can compare a number or a date in order with "compare": "gt" (also gte, lt, lte, neq). For older builds, or for a rule your database knows best, let the database answer with a yes/no column and test that. In Supabase, a view does it:
create view contact_cards with (security_invoker = true) asselect c.*, (c.phone is not null and btrim(c.phone) <> '') as has_phonefrom contacts c;List the view instead of the table, add has-phone to the model as a boolean, and draw the button only when it is true:
{ "id": "call-contact", "type": "Button", "props": { "label": "Call", "icon": "phone" }, "when": { "model": "contact", "field": "has-phone", "is": { "source": "literal", "value": true } }, "action": { "type": "contact", "method": "call", "value": { "source": "field", "model": "contact", "field": "phone" } }}security_invoker = true makes the view obey the same row level security as the table it reads.