githubEdit

<interaction> Directive

The <interaction> directive defines how UI elements respond to user events and system triggers. It supports both simple UI interactions and complex business logic through a flexible, AI-friendly format.


🛠 Attributes

Attribute
Type
Required
Description

name

string

Yes

Unique identifier for the interaction

event

string

Yes

Type of event (click, hover, focus, etc.)

target

string

No

ID or name of element to affect

type

string

No

'simple' or 'complex' (default: simple)

ai-hint

string

No

Additional context for AI interpretation

✅ Allowed Content

  • For simple interactions:

    • <action> elements

    • <condition> elements

    • <effect> elements

  • For complex interactions:

    • <description> element

    • <requirements> elements

    • <constraints> elements

    • <examples> elements

💡 Examples

Simple Interactions

Modal Dialog

Form Field Validation

Complex Interaction

Order Submission

🧩 AI Interpretation Guidelines

For Simple Interactions

  • Map events to appropriate framework event handlers

  • Implement conditions as if/else statements

  • Chain actions in sequence

  • Handle animations using framework animation systems

  • Maintain state consistency

  • Ensure accessibility

For Complex Interactions

  • Parse natural language description into logical steps

  • Identify required data transformations

  • Map business rules to appropriate services

  • Handle error cases and edge conditions

  • Implement proper state management

  • Ensure data consistency

  • Follow security best practices

Action Types

setProperty

Updates a property of a target element.

Attribute
Type
Required
Description

target

string

Yes

Element to modify

property

string

Yes

Property to update

value

any

Yes

New value to set

animate

Animates a property change over time.

Attribute
Type
Required
Description

target

string

Yes

Element to animate

property

string

Yes

Property to animate

from

any

Yes

Starting value

to

any

Yes

Ending value

duration

string

No

Animation duration (default: 200ms)

easing

string

No

Easing function (default: ease-in-out)

validate

Validates form input or data.

Attribute
Type
Required
Description

target

string

Yes

Form or input to validate

rules

string

No

Validation rules to apply

submit

Submits data to a server or handler.

Attribute
Type
Required
Description

target

string

Yes

Form or data to submit

endpoint

string

No

API endpoint to submit to

toggle

Toggles a boolean property between true and false.

Attribute
Type
Required
Description

target

string

Yes

Element to modify

property

string

Yes

Boolean property to toggle

show

Shows or hides an element.

Attribute
Type
Required
Description

target

string

Yes

Element to show/hide

visible

boolean

Yes

Whether to show or hide

focus

Sets focus to an element.

Attribute
Type
Required
Description

target

string

Yes

Element to focus

select

boolean

No

Whether to select text (default: false)


1. Event Binding via Directives

Interactive elements can declare event-based triggers using attributes such as onClick, onHover, onFocus, etc., and bind them to named actions:

These directives reference actions defined in the current component, screen, or globally.


2. Action Definition

An <Action> defines one or more effects to perform when triggered. Each action has a required name and contains one or more effect nodes such as <SetProperty>, <CallAction>, or <AnimateProperty>.


3. Available Directives

  • onClick

  • onHover

  • onFocus

  • onBlur

  • onChange

  • onMount

  • onEnter, onLeave

Each directive triggers an action by name.


4. Action Elements

<SetProperty>

Sets a property of a given target component.

Attribute
Description

target

ID or name of the element to affect

property

The property to update

value

The new value to assign

<CallAction>

Calls another action by name. Enables chaining.

<AnimateProperty> (optional / future spec)

Defines a visual transition of a property over time.


5. Conditional Logic

Actions can include conditions using the <If> directive. The action will only execute the child effects if the condition evaluates to true.

<If> Attributes

Attribute
Description

property

Path to a property or state variable

equals

Value to compare against


6. Chained Actions

You can call other actions as part of a flow using <CallAction>. Actions will be executed in order of appearance.


7. Action Scope

Actions can be declared:

  • Locally inside a <Component> or <Screen>

  • Globally in shared documents or libraries


8. Complete Example: Hover to Show Arrows (with conditions and chaining)


Last updated