Skip to main content
hema.mathivathanan
January 19, 2023
Solved

Bold in richtextitem

  • January 19, 2023
  • 6 replies
  • 0 views

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",
)

}

)

    Best answer by soundarya.g

    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
    January 19, 2023

    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
    January 20, 2023

    Thanks!

    mikes0011
    Brainy
    January 19, 2023

    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
    January 20, 2023

    Thanks Mike, This nesting helps a lot!

    arulk0002
    Inspiring
    January 20, 2023

    hema.mathivathanan
    January 20, 2023

    Thank you!