Skip to content

Add Icons to Placeholder text in Input Fields (Need Search Icon in Search Input) #6020

Answered by Hiws
ricktate asked this question in Q&A
Discussion options

You must be logged in to vote

You can't do this directly using the standard placeholder attribute as it does not support HTML.
You will instead need to position the icon on top of the input with position: absolute.

You can do this fairly easily using just utility classes. You could also implement the Floating Label example, which uses the same logic of placing the label on top of the input and in turn allowing HTML.

Here's a codepen with examples of both:
https://codepen.io/Hiws/pen/OJXoyaO

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by Hiws
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #6020 on December 14, 2020 15:42.