Skip to main content
New Participant
Mar 15, 2023 2:04 PM UTC
Question

Toggle button

I want to use the toggle button (highlighted below) in my user interface - similar to that used in the Profile Settings --> Email notifications interface.

Is this available anywhere or on the Appmarket?

Thanks!

    11 replies

    mikes0011
    Brainy
    Mar 15, 2023 2:10 PM UTC

    That seems to be one of the components they keep for behind-the-hood use within the Appian UI itself (though in this case i'm not sure why).  However you could definitely build a component that does something similar in functionality (minus any cool animations anyway), using a Rich Text Display Field containing a Rich Text Icon using the "toggle-on" / "toggle-off" icons.

    a!localVariables(
      local!value: "on",
      
      a!richTextDisplayField(
        value: {
          a!richTextItem(
            size: "MEDIUM_PLUS",
            text: {
              a!richTextIcon(
                icon: "toggle-on",
                showWhen: local!value = "on",
                link: a!dynamicLink(
                  saveInto: {
                    a!save(local!value, "off")
                  }
                ),
                linkStyle: "STANDALONE"
              ),
              a!richTextIcon(
                icon: "toggle-off",
                showWhen: local!value = "off",
                link: a!dynamicLink(
                  saveInto: {
                    a!save(local!value, "on")
                  }
                ),
                linkStyle: "STANDALONE"
              )
            }
          )
        }
      )
    )

    The Expression Guru
    New Participant
    Mar 15, 2023 2:28 PM UTC

    ahh perfect - will give it a go - thanks Mike!

    adityag9712
    Inspiring
    Mar 15, 2023 2:13 PM UTC

    a!localVariables(
      local!value: true,
      a!richTextDisplayField(
        value: {
          a!richTextItem(
            size: "MEDIUM_PLUS",
            text: {
              a!richTextIcon(
                icon: "toggle-on",
                showWhen: local!value = true,
                link: a!dynamicLink(
                  saveInto: {
                    a!save(local!value, false)
                  }
                ),
                linkStyle: "STANDALONE"
              ),
              a!richTextIcon(
                icon: "toggle-off",
                showWhen: local!value =false,
                link: a!dynamicLink(
                  saveInto: {
                    a!save(local!value,true)
                  }
                ),
                linkStyle: "STANDALONE"
              )
            }
          )
        }
      )
    )

    Hi, you can use Rich Text Display Field containing a Rich Text Icon using the "toggle-on" / "toggle-off" icons. And on links use dynamic link to update the variable value.

    - Aditya
    New Participant
    Mar 15, 2023 2:32 PM UTC

    thanks Aditya - will give it a go!

    adityag9712
    Inspiring
    Mar 15, 2023 2:36 PM UTC

    Hi, Please up vote as well :) 

    - Aditya
    abhayd3663
    Brainy
    Mar 15, 2023 2:41 PM UTC

    Agree with all the comments. It will be lot more easier if Appian comes up with these kind of basic component library.

    mikes0011
    Brainy
    Mar 15, 2023 2:56 PM UTC

    I do enjoy the fact that now in 23.1 we can start assembling our own component libraries.  I already had a half dozen or so, and it's nice to have a central place to organize them now.  However (and not to gripe about a nice new feature) i do find it a bit annoying that the Design Library tab lists every single app package any of the added elements are in... that makes it quite a bit... busy.... on my dev environment.

    The Expression Guru
    Participating Frequently
    Sep 14, 2023 8:18 AM UTC

    a!localVariables(
    local!a:true,
    a!cardLayout(
    contents:{
    a!richTextDisplayField(
    value:a!richTextIcon(
    icon: "toggle-off",
    color:"ACCENT",
    size:"MEDIUM_PLUS",
    link: a!dynamicLink(
    saveInto: a!save(local!a,false)
    ),
    linkStyle: "STANDALONE"
    ),
    showWhen:toboolean(local!a)
    ),
    a!richTextDisplayField(
    value:a!richTextIcon(
    icon: "toggle-on",
    color:"ACCENT",
    size:"MEDIUM_PLUS",
    link: a!dynamicLink(
    saveInto: a!save(local!a,true)
    ),
    linkStyle: "STANDALONE"
    ),
    showWhen:toboolean( local!a)= false
    ),
    }
    )

    )

    use this code for toggle button

    stefanhelzle0001
    Brainy
    Sep 14, 2023 1:48 PM UTC