Skip to main content

 

 

 

 

Template:OutSystems/Documentation_KB/Breadcrumb_New_Layout

 

 

Template:OutSystems/OSLanguageSwitcher

 

Applies only to Mobile Apps and Reactive Web Apps

 

 

OutSystems

Badge

Template:OutSystems/Documentation_KB/ContentCollaboration
  • Edit
    Collaborate with us
    Edit this page on GitHub
  • 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 following example demonstrates how you can display the number of registered users on your platform.

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

      The Badge widget is displayed.

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

    3. To create an aggregate that retrieves all of the users on your platform, right-click your screen name and select Fetch Data from Database.

    4. Click the Aggregate screen, and from the Select Source popup, select the relevant database entity (in this example, Users), and click Ok.

    5. To reopen your screen, double-click on your screen name.

    6. Select the 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.

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

      The Number property is now set to display the Count property of the aggregate you created, which retrieves the number of users on your platform and displays it in your Badge.

    8. 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, medium-sized, soft-rounded badge.

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

    Properties

    Property Description
    Number (LongInteger): 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).

    Examples

    • Blank - displays the number 8 (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 badge.

    Examples

    • Blank - displays the badge in the color you chose when creating the app (default value)
    • Entities.Color.Red - displays a red badge
    Size (Size Identifier): Optional Set the badge size. Small and medium are the predefined sizes available for the badge.

    Examples

    • Blank - displays a medium sized badge (default value)
    • Entities.Size.Small - displays a small sized badge
    Shape (Shape Identifier): Optional Set the badge shape. Rounded, soft rounded, and sharp are the predefined shapes available for the badge.

    Examples

    • Blank - displays a rounded badge (default value)
    • Entities.Shape.Sharp - displays a square badge
    IsLight (Boolean): Optional Specify the badge's background color.

    Examples

    • Blank - A darker hue of the color is applied to the badge and a lighter color to the text (default value)
    • True - A brighter hue of the color is applied to the badge and a darker color to the text.
    • False - A darker hue of the color is applied to the badge and a lighter color to the text
    ExtendedClass (Text): Optional Add custom style classes to the 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 Badge UI styles being applied.
    • ''myclass1'' ''myclass2'' - Adds the myclass1 and myclass2 styles to the Badge UI styles being applied.
    • Was this article helpful?