We’ve been working on this article. Please let us know how useful this new version is by voting.
You can use the Badge UI Pattern to display numerical information as a notification. For example, the Badge UI pattern is frequently used to notify users about the number of unread emails, unopened messages, or new tasks they may have.
How to use the Badge UI Pattern
The Badge UI Pattern usually displays dynamic information. In most cases, prior to using this pattern, you will need to retrieve or update the Data that contains the information you want to display onscreen. You do this by using an Action.
The following example demonstrates how you can display the number of registered users on your platform.
In Service Studio, in the Toolbox, search for
The Badge widget is displayed.
If the UI widget does not display, it may be because you used a ready-made app, which deletes unused widgets from the module. To make additional widgets available in your app:
a. Go to Module > Manage dependencies.
b. Search for and select the relevant Producer, for example OutSystemsUI. Ensure Show All is selected.
c. On the Public elements for the selected Producer displayed on the right, ensure Show All is selected.
d. Search for and select the element you want to add, and click Apply.
e. In Service Studio, in the Toolbox, search for the widget again.
From the Toolbox, drag the Badge widget into the Main Content area of your application's screen.
From the Element tree, create a Preparation action by right-clicking on your screen, and from the drop-down, select Add Preparation.
This Preparation action executes logic that fetches the data before the screen is displayed.
Select the Data tab, and from the Entities tree, navigate to the User entity and drag it onto the Preparation action.
This creates an aggregate that retrieves all of the users on your platform.
To reopen your screen, select the Interface tab, and double-click on your screen.
Select the Badge widget, and on the Properties tab, from the Number drop-down, select Expression Editor.
In the Expression Editor, enter the following expression and click Done.
Note: You can also add the expression by navigating through the Expression Editor's Scope tree and double-clicking on the Count output parameter. However, because the expected Badge data type (Integer) is different to the Count data type (Long Integer), to ensure the expression is correct, you must add
The Number property is now set to display the Count property of the Aggregate you added to the Preparation action, which gets the number of users on your platform and displays them in your Badge.
On the Properties tab, you can also customize the Badge's look and feel by setting any of the optional properties, for example, the color, shape, and size. The following example displays a blue, small sized, circle badge.
After following these steps and publishing the module, you can test the pattern in your app.
|Number (Integer): Optional||Number that appears inside the badge. Set this to a Data source that contains the value that the Badge will display. Common use cases include displaying a value contained in a Variable or the result of an Aggregate (for instance, querying a 'Messages' table for the current user to return the count of new messages).
|Color (Color Identifier): Optional||Set the badge color. Red, orange, yellow, lime, green, blue, violet, and pink are just some of predefined colors available for the badge.
|Shape (Shape Identifier): Optional||Set the badge shape. Rounded, soft rounded, and sharp are the predefined shapes available for the badge.
|Size (Size Identifier): Optional||Set the badge size. Small and medium are the predefined sizes available for the badge.
|IsLight (Boolean): Optional||Specify the badge's background color.
|ExtendedClass (Text): Optional||Adds custom style classes to the Pattern. You define your custom style classes in your application using CSS.
If the number on Badge Pattern is greater than 99, it is displayed as 99+.