githubEdit

Custom UI Components

Learn how to create custom UI components for Elsa Studio, including custom property editors for activity inputs and integration of React/Angular components via web components.

Elsa Studio provides a rich, extensible UI for designing workflows, but sometimes you need custom editors for specific activity properties. This guide explains how Studio renders activity editors, how to create custom property editors, and how to integrate them with your activities.

Overview

Elsa Studio's workflow designer allows you to create and configure activities visually. Each activity has properties (inputs and outputs) that are edited through property editors in the property panel. While Studio provides default editors for common types (text, numbers, booleans, etc.), you can create custom property editors for specialized data types or enhanced user experiences.

What You Can Customize

  • Property Editors: Custom input controls for activity properties

  • Content Visualizers: Custom display components for activity output values

  • Field Extensions: Additional UI functionality for specific fields

  • Activity Pickers: Custom selection interfaces for choosing activities

How Studio Renders Activity Editors

When you select an activity in the workflow designer, Studio:

  1. Loads Activity Descriptor: Retrieves metadata about the activity's inputs and outputs

  2. Determines Property Types: Identifies the data type of each property

  3. Selects Editor Components: Chooses appropriate UI components based on:

    • Property data type (string, number, boolean, etc.)

    • UI Hints (custom editor identifiers)

    • Expression type (Literal, JavaScript, C#, etc.)

  4. Renders Property Panel: Displays editors in the inspector panel

  5. Binds Data: Connects editors to the workflow definition's property values

Default Property Editors

Studio includes built-in editors for common types:

Data Type
Default Editor
Description

string

Single-line text

Basic text input

string (multi-line)

Multi-line text

Textarea for longer text

number

Number input

Numeric input with validation

boolean

Checkbox/Toggle

True/false selection

object

JSON editor

Monaco editor for JSON

array

List editor

Add/remove items interface

UI Hints: Requesting Custom Editors

The UIHint attribute tells Studio which custom editor to use for a property:

The UIHint value (e.g., "email-input") identifies which custom editor component Studio should use for that property.

Creating Custom Property Editors

Custom property editors are web components that conform to Studio's component interface. Studio is built with modern web standards, allowing you to create editors using any framework that can compile to web components.

Architecture: Backend + Frontend

Custom property editors involve both backend and frontend:

  1. Backend (Elsa Core):

    • Activity definition with UIHint attributes

    • Optional: UI hint handler for metadata/validation

    • Optional: Custom serialization for complex types

  2. Frontend (Elsa Studio):

    • Custom web component implementing the editor

    • Registration of the component with Studio

    • Styling and user interaction logic

Example: Custom Email Input Editor

Let's create a custom email input with validation and suggestions.

Backend: Activity with UI Hint

Backend: UI Hint Handler (Optional)

UI hint handlers provide metadata and validation for custom editors:

Register the handler in your feature:

Frontend: Custom Web Component

Create a web component for the email editor:

Frontend: Register the Component

Register your component with Elsa Studio:

Frontend: Include in Studio Build

Add your custom component to Studio's build configuration:

Include the built extension in your Studio deployment:

Integrating React Components

React components can be integrated via web components. Here's how:

Step 1: Create React Component

Step 2: Wrap in Web Component

Step 3: Register with Studio

Integrating Angular Components

Angular components can also be wrapped as web components:

Step 1: Create Angular Component

Step 2: Convert to Web Component

Property Editor Interface

All custom property editors must implement this interface:

Best Practices

1. Handle Expression Mode

When isExpression is true, the property contains an expression (JavaScript, C#, etc.) rather than a literal value. Disable or hide your custom UI in this mode:

2. Emit Value Changes

Always dispatch a valueChanged event when the value changes:

3. Validate Input

Provide immediate validation feedback to users:

4. Responsive Design

Ensure your editor works in Studio's property panel (usually 300-400px wide):

5. Accessibility

Make your editors keyboard-accessible and screen-reader friendly:

Debugging Custom Editors

Browser DevTools

  • Use browser DevTools to inspect your web component

  • Check the component's properties and attributes

  • Monitor event dispatching with event listeners

Studio Debug Mode

Enable Studio's debug mode to see editor registration and loading:

Placeholder for Screenshots

[Screenshot: Custom email editor in Studio property panel]

[Screenshot: Custom editor validation in action]

[Screenshot: React-based custom editor example]

Further Reading

Summary

Creating custom UI components for Elsa Studio involves:

  1. Backend: Define activities with UIHint attributes

  2. Frontend: Create web components implementing the property editor interface

  3. Registration: Register components with Studio's property editor registry

  4. Integration: React/Angular components can be wrapped as web components

Custom property editors enable rich, domain-specific editing experiences while maintaining compatibility with Studio's workflow designer.

Last updated