|
| 1 | +# UI Module |
| 2 | + |
| 3 | +A UI Module is a reusable container that groups widgets, queries, and JavaScript logic into a single unit. It is created inside a UI Package and is designed for reuse across multiple applications. |
| 4 | + |
| 5 | +- You can add different types of widgets inside the module container. The entire container is rendered together when the module is used in an application. |
| 6 | + |
| 7 | +- Widgets inside the module cannot be edited directly from the application. All configurations must be done through defined Inputs. |
| 8 | + |
| 9 | +- UI Modules allow dynamic values to be passed from the application into the module using Inputs. Each module instance can receive different values based on application requirements. |
| 10 | + |
| 11 | +This page provides information about the properties, content settings, and style configurations available for UI Modules. |
| 12 | + |
| 13 | +### Content properties |
| 14 | + |
| 15 | +Content properties control the functional behavior of the UI Module container and its dynamic behavior when rendered inside an application. |
| 16 | + |
| 17 | +#### Inputs |
| 18 | + |
| 19 | +<dd> |
| 20 | + |
| 21 | +Inputs allow you to pass dynamic values from the application into the UI Module. |
| 22 | +They act as a bridge between the app and the widgets, queries, or JavaScript logic inside the module. |
| 23 | + |
| 24 | +You can create multiple Inputs when designing the module. Each Input has: |
| 25 | + |
| 26 | +- **Name:** Used to reference the value inside the module. |
| 27 | + |
| 28 | +- **Default value (optional):** Used if no value is passed from the application at runtime. |
| 29 | + |
| 30 | +Inputs help you dynamically configure the behavior of widgets inside the UI Module without modifying the module itself. |
| 31 | + |
| 32 | +**Accessing Inputs** |
| 33 | + |
| 34 | +Inputs are accessed using the same syntax across widgets, queries, and JavaScript functions inside the module: |
| 35 | + |
| 36 | +```javascript |
| 37 | +{{inputs.inputName}} |
| 38 | +``` |
| 39 | + |
| 40 | + |
| 41 | +- **Widget**: Use `{{inputs.inputName}}` inside widget properties such as Default Text, Label, Data, or Options. |
| 42 | + |
| 43 | + *Example:* If you want to prefill a customer profile form with the user's email, create an input named `inputemail` and set the Input widget’s Default Text property to `{{inputs.inputemail}}`, passing `{{appsmith.user.email}}` from the application. |
| 44 | + |
| 45 | +- **Query**: Use `{{inputs.inputName}}` inside the query body to dynamically inject input values at runtime. |
| 46 | + |
| 47 | + *Example:* If you want to fetch customer addresses based on the selected country, create a query that uses: |
| 48 | + |
| 49 | + ```js |
| 50 | + SELECT * FROM addresses WHERE country = {{inputs.inputCountry}} |
| 51 | + ``` |
| 52 | + |
| 53 | +- **JavaScript**: Use `inputs.inputName` directly inside JavaScript Object functions to dynamically operate based on input values. |
| 54 | + |
| 55 | + *Example:* If you want to adjust available shipping options based on country, create a function that checks `inputs.inputCountry` and returns different options accordingly. |
| 56 | + |
| 57 | + |
| 58 | +</dd> |
| 59 | + |
| 60 | + |
| 61 | +#### Visible `boolean` |
| 62 | + |
| 63 | +<dd> |
| 64 | + |
| 65 | +Controls whether the entire UI Module container is visible when the application loads. This property applies to the entire module container, not to individual widgets. |
| 66 | + |
| 67 | +To control the visibility of individual widgets, configure the widget’s visibility property individually inside the module. |
| 68 | + |
| 69 | + |
| 70 | +</dd> |
| 71 | + |
| 72 | +#### Scroll Contents `boolean` |
| 73 | + |
| 74 | +<dd> |
| 75 | + |
| 76 | +Controls whether the UI Module container allows scrolling when the internal content exceeds the container size. This property applies to the entire module container, not to individual widgets. |
| 77 | + |
| 78 | +</dd> |
| 79 | + |
| 80 | +#### Animate Loading `boolean` |
| 81 | + |
| 82 | +<dd> |
| 83 | + |
| 84 | +Controls whether a loading animation appears while the UI Module's widgets, queries, or JavaScript logic are initializing. This property applies to the entire module container, not to individual widgets. |
| 85 | + |
| 86 | + |
| 87 | +</dd> |
| 88 | + |
| 89 | + |
| 90 | +### Style Properties |
| 91 | + |
| 92 | +Style properties control the appearance of the UI Module container, including background, border, and shadow settings. |
| 93 | +Some style properties are also JavaScript configurable and can accept dynamic values through Inputs. |
| 94 | + |
| 95 | +#### Background Color `string` |
| 96 | + |
| 97 | +<dd> |
| 98 | + |
| 99 | +Sets the background color of the UI Module container. You can define a static color value or bind a dynamic color using JavaScript expressions. |
| 100 | + |
| 101 | +Background Color is JavaScript configurable and can also be dynamically controlled by passing a color value through an **Input**. |
| 102 | + |
| 103 | + |
| 104 | +</dd> |
| 105 | + |
| 106 | + |
| 107 | +#### Border Color `string` |
| 108 | + |
| 109 | +<dd> |
| 110 | + |
| 111 | +Sets the color of the border around the UI Module container. Accepts a hex code, RGB value, or color name. |
| 112 | + |
| 113 | +*Example:* If you want the container to have a grey border, set the Border Color to `#E0E0E0`. |
| 114 | + |
| 115 | +</dd> |
| 116 | + |
| 117 | + |
| 118 | +#### Border Width `number` |
| 119 | + |
| 120 | +<dd> |
| 121 | + |
| 122 | +Sets the thickness of the border around the UI Module container. |
| 123 | +Default value is `1`. |
| 124 | + |
| 125 | +*Example:* If you want a thicker border for emphasis, set the Border Width to `2`. |
| 126 | + |
| 127 | +</dd> |
| 128 | + |
| 129 | + |
| 130 | +#### Border Radius `string` |
| 131 | + |
| 132 | +<dd> |
| 133 | + |
| 134 | +Controls the roundness of the corners of the UI Module container. Offers three standard options: **Sharp** (square edge), **Rounded** (slightly curved), and **Pill** (fully curved edges). |
| 135 | + |
| 136 | +</dd> |
| 137 | + |
| 138 | + |
| 139 | +#### Border Shadow `string` |
| 140 | + |
| 141 | +<dd> |
| 142 | + |
| 143 | +Adds a shadow around the UI Module container to create visual elevation. You can select from three standard shadow options: Small, Medium, and Large. |
| 144 | + |
| 145 | + |
| 146 | +</dd> |
0 commit comments