Skip to main content

 

Patterns

 

Applies only to Traditional Web Apps

 

OutSystems

Icon Badge

  • Edit
  • We’ve been working on this article. Please let us know how useful this new version is by voting.

    You can use the Icon Badge UI Pattern to display numerical information as a notification. For example, the Icon 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 Icon Badge UI Pattern

    The Icon 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.

    1. In Service Studio, in the Toolbox, search for Icon Badge.

      The Icon Badge widget is displayed.

    2. From the Toolbox, drag the Icon Badge widget into the Main Content area of your application's screen.

    3. 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.

    4. 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 the users on your platform.

    5. To reopen your screen, select the Interface tab, and double-click on your screen.

    6. Select the Icon Badge widget, and on the Properties tab, from the Number drop-down, select Expression Editor.

    7. In the Expression Editor, enter the following expression and click Done.

      LongIntegerToInteger(GetUsers.Count)

      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 LongIntegerToInteger to the Get.Users.Count expression.

      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 icon badge.

    8. On the Properties tab, you can also customize the Icon Badge's look and feel by setting any of the optional properties, for example, the color. The following example displays a blue icon badge.

    After following these steps and publishing the module, you can test the pattern in your app.

    Properties

    Property Description
    Number (Integer): Optional Number that appears inside the Icon Badge. Set this to a Data source that contains the value that the Icon 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).

    Examples

    • Blank - displays the icon only with no number (default value)
    • 22 - displays the number 22
    • VariableName - displays the value that the variable ''VariableName'' holds at that time
    • ExampleAggregate.Count - displays the number of records returned by the ''ExampleAggregate'' aggregate execution
    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 icon badge.

    Examples

    • Blank - displays the icon badge in the color you chose when creating the app (default value)
    • Entities.Color.Red - displays a red icon badge
    IsLight (Boolean): Optional Specify the icon badge's background color.

    Examples

    • Blank - A darker hue of the color is applied to the icon badge and a lighter color to the text (default value)
    • True - A brighter hue of the color is applied to the icon badge and a darker color to the text.
    • False - A darker hue of the color is applied to the icon badge and a lighter color to the text
    ExtendedClass (Text):Optional Add custom style classes to the Icon Badge UI Pattern.You define your custom style classes in your application using CSS.

    Examples

    • Blank - No custom styles are added (default value).
    • "myclass" - Adds the myclass style to the Icon Badge UI styles being applied.
    • "myclass1" "myclass2" - Adds the myclass1 and myclass2 styles to the Icon Badge UI styles being applied.
    • Was this article helpful?