Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

AnsweredbyHiws
ricktate asked this question inQ&A
Discussion options

Is your feature request related to a problem? Please describe...

I would like to display a search icon within the placeholder text of my search input field. This creates a visual representation for users to quickly interpret what the field does.

Describe alternatives you've considered

We've added a disabled button with a search icon. Takes up space and has a negative impact of users sometimes trying to click the button.

Additional context

Is there already a way to do this? Apologies if I'm missing something but struggling to find a way to add it.

You must be logged in to vote
Answered by HiwsNov 6, 2020

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

You can do this fairly easily using just utility classes. You could also implement theFloating 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

Hiws
Nov 6, 2020
Maintainer

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

You can do this fairly easily using just utility classes. You could also implement theFloating 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

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

Hiws
Nov 6, 2020
Maintainer

You could also useInput Groups and prepend/append the icon.

You must be logged in to vote
0 replies
Comment options

Thanks for the suggestion@Hiws. I'll give these a shot.

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

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


[8]ページ先頭

©2009-2025 Movatter.jp