Skip to main content

 

 

 

 
Language:
 
Applies only to Traditional Web Apps
 
 
OutSystems

Toggle Button

Template:OutSystems/Documentation_KB/ContentCollaboration
  • Edit
    Collaborate with us
    Edit this page on GitHub
  • You can use the Toggle Button UI Pattern to provide users with a stand-alone control that allows them to choose between two states, for example, a Yes/No value.

    How to use the Toggle Button UI Pattern

    In this example, we create a toggle button to activate a widget that can is activated only when a condition is met.

    1. In Service Studio, in the Toolbox, search for Toggle Button.

      The Toggle Button 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.

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

    3. Right-click your screen name and select Add Local Variable.

    4. Enter a name and select a data type. In this example, we enter the name IsToggled, set the data type to Boolean and the default value to False.

    5. In this example, we add some text and a button. We enter a name for the button (SubmitButton), and set the Enabled property to the local variable we created earlier (IsToggled).

    6. Select the Checkbox widget, and on the Properties tab, from the Variable drop-down, select the local variable you just created (in this example, IsToggled).

    7. From the OnChange Destination drop-down, select New Screen Action.

    8. From the Toolbox, add the Ajax Refresh to the screen action, and in the Select Widget pop-up, navigate to and select the Submit button name (in this example, SubmitButton), and click OK.

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

    Properties

    Property Description
    ExtendedClass (Text): Optional Adds custom style classes to the 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 UI styles being applied.
    • "myclass1 myclass2" - Adds the myclass1 and myclass2 styles to the UI styles being applied.
    You can also use the classes available on the OutSystems UI. For more information, see the OutSystems UI Live Style Guide.
    • Was this article helpful?