Skip to main content
hema.mathivathanan
Employee
Jan 19, 2023 5:12 PM UTC
Solved

Bold in richtextitem

I want to bold a particular word in a text when using a a!richtextitem. when I use the "Style" as "strong", it's making the entire text bold.
In my case, I only want a word to be bold as shown below. Can someone please help


a!richTextDisplayField(
value: {
a!richTextItem(
text: {
"We recommend ABC method.",
},
style: "PLAIN",
)

}

)

    soundarya.g
    Employee
    Jan 19, 2023 5:20 PM UTC

    Hi hema.mathivathanan,

    As richTextDisplayField accepts multiple values in the "value" parameter, we can try the below

    a!richTextDisplayField(
    value: {
    a!richTextItem(text: { "We recommend", }, style: "PLAIN", ),
    a!richTextItem(text: { " ABC ", }, style: "STRONG", ),
    a!richTextItem(text: { "method.", }, style: "PLAIN", )
    }
    )

    Hope it answers your question!!

    6 replies

    soundarya.g
    Employee
    Jan 19, 2023 5:20 PM UTC

    Hi hema.mathivathanan,

    As richTextDisplayField accepts multiple values in the "value" parameter, we can try the below

    a!richTextDisplayField(
    value: {
    a!richTextItem(text: { "We recommend", }, style: "PLAIN", ),
    a!richTextItem(text: { " ABC ", }, style: "STRONG", ),
    a!richTextItem(text: { "method.", }, style: "PLAIN", )
    }
    )

    Hope it answers your question!!

    hema.mathivathanan
    Employee
    Jan 20, 2023 10:36 AM UTC

    Thanks!

    mikes0011
    Brainy
    Jan 19, 2023 9:03 PM UTC

    In addition to the above reply, you should also know that you can nest a!richTextItem() objects within each other to basically any level.  This helps a lot with complicated structures of formatting and also separate links, etc.

    a!richTextDisplayField(
      value: {
        a!richTextItem(
          text: {
            "We recommend",
            
            a!richTextItem(
              text: " ABC ",
              style: "STRONG"
            ),
            
            "method."
          }
        )
      }
    )

    The Expression Guru
    hema.mathivathanan
    Employee
    Jan 20, 2023 10:36 AM UTC

    Thanks Mike, This nesting helps a lot!

    arulk0002
    Inspiring
    Jan 20, 2023 5:07 AM UTC

    hema.mathivathanan
    Employee
    Jan 20, 2023 10:36 AM UTC

    Thank you!