cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
StellaTs
Frequent Visitor

different color in part of a text

Hello,

I use a TextInput and I would like to highlight certain part of that text.
For example if the user's name is inside that text input I want it blue,but all the other words I want it to be black.
I tried different options but all operate to the whole text of a text input.

Thank you in advance,
Stella

6 REPLIES 6
CarlosFigueira
Power Apps
Power Apps

This is not supported on the Text Input control. If you feel that this feature is important for your scenario, please create a new item in the PowerApps Ideas board, with details about your scenario.

 

If you want to format a control that displays text (not letting the user input it), you can use the HTML Text control, where you can control, via HTML tags, the color of parts of the text.

NEPatton
Kudo Kingpin
Kudo Kingpin

Hey StellaTs!

 

You might be able to get creative using a TextInput AND the HTML text, actually...

 

I did this as a quick test --

 

TextInput1 - I typed in "Hey Nick!"

TextInput1.OnChange = Set(stuff,TextInput1.Text)

 

HTMLtext1.HTMLtext = Substitute(stuff,"Nick","<b>Nick</b>")

 

So then HTMLtext1 reads Hey Nick!

 

I don't know if that's helpful or not.

Thank you both for your responses.

It's not exactly what I have in mind but I'll make a workaround probably.

hi @StellaTs  - Just curious to know if you were you able to figure out a workaround to this requirement as I have the similar requirement?

 

Thank you!

 

I know this is an old post, but I found this was a great solution - I modified slightly with some HTML encoding and worked really well for me.
Substitute(ThisItem.GuidanceHTML,TextInput1.Text,
Concat(
["<span style='background-color: #000000; color: #ffffff;'>",TextInput1.Text,"</span>"]
,Value,"")
)

doshort
Frequent Visitor

I wanted to highlight text in fields as the text was typed into a search box. It took awhile, but I settled on using an HTMLTextBox and setting the HTMLText property to a value that substituted the search text with a highlighted version of the text. I also set the gallery Items property to filter the gallery by search text as it was typed using

Search(colYourCollectionName, SearchBox1_2.Text, "YourField1", "YourField2", "YourField3", "YourField4").

 

The code is:

/*

The search function does a case insensitive search for the entered text in the specified fields.

This code highlights the search text in this field using the HTML5 <mark> tag.

It is nested so it first substitutes the exact search box text in the field Text.

Then it takes that text and substitutes all lower case occurrences of the search text.

Then it takes that text and substitutes all upper case occurrences of the search text.

Then it takes that text and substitutes all title (Proper) case occurrences of the search text.

The result is that all occurrences of the search text are highlighted except for miXEd text.

*/

Substitute(

    Substitute(

        Substitute(

            Substitute(

                ThisItem.YourFieldName,

                SearchBox1_2.Text,

                "<mark>" & SearchBox1_2.Text & "</mark>"

            ),

            Lower(SearchBox1_2.Text),

            "<mark>" & Lower(SearchBox1_2.Text) & "</mark>"

        ),

        Upper(SearchBox1_2.Text),

        "<mark>" & Upper(SearchBox1_2.Text) & "</mark>"

    ),

    Proper(SearchBox1_2.Text),

    "<mark>" & Proper(SearchBox1_2.Text) & "</mark>"

)

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (4,327)