
Block Fundamentals
- What are Blocks?
- Block Types
- Block Communication
Blocks are modular UI components with specific purposes:
- Self-contained: Each block encapsulates specific functionality
- Reusable: Can be used across multiple pages and workspaces
- Configurable: Customizable through properties and settings
- Interactive: Respond to user actions and system events
- Event-driven: Communicate with other components through events
Common Block Properties
All blocks share a set of common properties that can be configured in YAML:Common Properties
Common Properties
Required. Unique identifier for the block in your workspace.
Event fired when the block is initialized. Example:
myInitBlockEventEvent that triggers an update of the block. Example:
myUpdateBlockEventName of the automation to associate with this block.
Identifier for the section containing this block. Example:
myBlockCSS class name to apply to the block. Example:
block-classnameCustom CSS for styling the block. Uses
:block selector for the block root element.Conditional display expression. Block will only be shown if the expression evaluates to true.
Allows repeating the block for each item in an array. Example:
repeat on myArrayVariable name for the current item when using repeat. Example:
myItemBuilt-in Blocks Library
AI Builder includes a comprehensive library of built-in blocks. Here’s a detailed reference for each block with its specific YAML configuration.Marketplace Blocks
The following blocks are available after installing specific apps from the marketplace.Block Event System
The event system is the core communication mechanism between blocks:Event Types
Event Types
Event Types
Event Communication Pattern
1
Event Definition
Blocks define the events they will emit:This creates an event on the system when the end user interacts with blocks
2
Event Subscription
Other automations register to receive specific events:This tells the automation to listen for the specified event and call the appropriate handler when it occurs.
Advanced Block Features
Block Composition
Block Composition
Blocks can be composed from other blocks to create higher-level components:
- Container Blocks: Wrap and organize other blocks
- Composite Blocks: Combine multiple blocks into a cohesive component
- Layout Blocks: Control the arrangement of nested blocks
- Wrapper Blocks: Add functionality to existing blocks
Block Styling
Block Styling
Blocks can be styled through multiple approaches:
- CSS Editor: Direct CSS customization
- Built-in CSS: Keeping the default CSS
- CSS Classes: Predefined style sets
Block Conditions
Block Conditions
Blocks can have conditional behavior based on various logical factors:
- Block Display Condition (if): Example: if MyCondition
- Repeat Block on Array: Example: repeat on MyTable
- Variable Name for Each Item: Example: MyVariable
Block Best Practices
Single Responsibility
Design blocks to do one thing well:
- Focus on a specific UI functionAvoid creating overly complex blocksSplit complex functionality into multiple blocksCreate specialized blocks for specific use cases
Clear Naming
Use consistent, descriptive naming:
- Choose clear, descriptive block namesUse consistent terminology across blocksEstablish naming conventions for properties and eventsDocument the purpose of each block
Robust Error Handling
Design blocks to handle failures gracefully:
- Validate inputs and handle edge casesProvide clear error states and messagesImplement fallback behavior for missing dataLog issues for troubleshooting
Accessibility
Ensure blocks work for all users:
- Follow WCAG guidelines for accessibilitySupport keyboard navigationInclude screen reader compatible markupMaintain sufficient color contrast
Responsive Design
Optimize blocks for all device sizes:
- Test across different screen sizesImplement responsive layoutsAdjust content for mobile displaysUse relative units for sizing
Performance Optimization
Keep blocks efficient and responsive:
- Minimize unnecessary rendersOptimize heavy operationsImplement loading states for async operationsUse lazy loading where appropriate