Insert a pair of icons directly into an input field

Is there a way to place two icons within an input element, with both icons being clickable? I currently have react-semantic-UI and uikit installed. Any advice or suggestions would be greatly appreciated. Thank you!

https://i.sstatic.net/xzoI9.png

Answer №1

To simplify the process, one can avoid placing icons directly in the input field but instead style a container with a prefix, the input itself, and a suffix. By removing all styles from the input and styling the container as if it were an input, a cleaner design can be achieved.

<div class="input">
  <span class="prefix"><i>YOUR ICON</i></span>
  <input />
  <span class="suffix"><i>YOUR ICON</i></span>
</div>

<style>
.input {
  display: flex;
  gap: 1rem;
  border: 1px solid #aaa;
  border-radius: 4px;
  padding: 0.5rem 0;
}

input {
  all: unset;
}
</style>

For demo purposes, you can view the codepen I have set up: https://codepen.io/webfussel/pen/rNYPzyX

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Troubleshooting the issue with the htmlFor attribute

I have encountered an issue with creating radio buttons and labels using JavaScript. Despite adding the 'for' attribute in the label using 'htmlFor', it does not apply to the actual DOM Element. This results in the label not selecting t ...

Activate a switch in a single table after its information has been transferred to a different table

I have a dilemma involving two tables - one displaying a list of items and the other serving as an empty favorites table. Users can select items from the first table and click 'Add' to move them to the favorites table. Once added, the 'Add& ...

Utilizing nested arrays in jQuery templates

I have a JSON object that looks like the following: [Object] 0: Object domains: Array[1] 0: "domain1.com" length: 1 __proto__: Array[0] name: "name1" 1: Object domains: Array[2] 0: "domain2.com" length: 2 __proto__: Arr ...

Having trouble getting Chrome to execute my jQuery code

It seems that my jQuery code is not running in Chrome as expected. The purpose of my jQuery code is to determine if an element is within the viewport or not. function isElementInViewport(elem) { var $elem = $(elem); // Get the scroll position ...

Tips for maintaining the full width/height ratio of a child image when covering a fixed size container

I have a square container with dimensions of 300x300 and an <img src="" /> image inside. My goal is for the image to cover the entire container while maintaining its width/height ratio. If the image's width is smaller than its height ...

Is it recommended to reset heading tag numbering while nesting them?

Consider an HTML book as an example (steering away from the typical blog post). Take a look at this code: <!DOCTYPE html> <html> <head> <title>The title</title> </head> <body> <h1>The title</h1&g ...

What is the best way to link and store invoice formset with the main form foreign key in Django?

I am new to Django and need help. I am trying to save my invoice in a database, but the issue I'm facing is that I can't retrieve the foreign key from the main form when I try to save the formset. View.py def createInvoice(request):` if requ ...

Quiz Canvas: An interactive HTML game for testing your knowledge

Hello, I am currently working on developing an HTML quiz game using canvas. However, as a beginner in this field, I have struggled to find relevant documentation specifically for this project. Overview of the Game The game consists of 5 scenes, each repr ...

Mastering CSS selectors with jQuery

My desire to delve into the world of jQuery has ignited. From my perspective, jQuery simply selects the desired element and performs actions on it. However, I find the selection process closely resembling CSS selectors, a realm with which I am not well-ver ...

Visual button spacing

There is no CSS styling applied to the page. When two image buttons are placed in separate lines of code like this: <asp:ImageButton ID="btnVoteUp" Height="16px" Width="16px" runat="server" ImageUrl="images/thumbs_up.gif" CausesValidation="false" Co ...

What is the best way to customize my menu so that the currently selected element stands out with a distinct color?

I'm struggling with customizing the background color of the active page due to complex HTML structure. I'm using responsive twitter bootstrap (2) and facing challenges. To view all tabs at the top, you need to stretch the viewing window. Below is ...

If no content is present in a cell of an HTML table, alter the row

I am attempting to create a CSS table that changes the row color if any cell in the row is empty. Here's what I have so far: <style type="text/css"> td:empty { background-color: red; } </style> Is there a way to change th ...

Requesting data from local APIs using ZingGrid CRUD operations

Is there anyone who can assist me with ZingGrid? I am looking for a sample project to understand how to make API calls using ZingGrid. ...

Text is not wrapping onto a new line following the <hx> elements

I've been struggling to get my paragraph text to start on a new line after the subtitles in my code. I've tried using display:block and adding a right margin to take up the full width of the div, but nothing seems to be working! If you want to s ...

Tips on adjusting the color of a link once it has been clicked?

Looking for a link with a specific style? a { color: #999; &:hover { color: #008da0; } &:visited { color: #999; } /* I added this to test if it's gonna fix it, but it didn't */ } Upon clicking the link, it turns blue and remains s ...

I can't figure out why I'm facing a Same-origin policy error when all the files are located in the same local directory

Currently, I am facing an issue with my main html file that loads another html file in the same directory using an iframe. There is a button on the main page that interacts with the html file within the iframe through a function: <script> function m ...

Instructions for redirecting a hyperlink through a different page upon clicking in HTML

Apologies for my confusing title, I've been struggling to find the right terminology in my search results. Let me try to clarify my question. When you visit a news website or blog's homepage (e.g. www.homepage.co.uk/) and then click on an article ...

Ways to conceal li and label elements without relying on a class or ID or utilizing a commonly shared class or ID

Is there a way to hide the li and label elements from a page without specific IDs or classes? <li><a href="https://www.test.com/feature/%d8%ac%d9%85%d8%b9-%d8%a7%d9%84%d8%a7%d9%86%d9%85%d8%a7%d8%b7/"><i class="fa fa-check" ...

Angular click event not functioning properly on elements loaded via http request

Check out my CodePen link: http://codepen.io/gauravcoder/pen/vLWEjJ?editors=101 I'm just getting started with Angular JS. I have some items that trigger an alert when clicked, it works fine for items that are not loaded via an HTTP request. However, ...

What is the best way to retrieve the parent element in jQuery when you already have the child element selected

I am working with jQuery Mobile, which automatically generates a lot of the DOM structure. The challenge I am facing is removing radio buttons without having an id for the parent div due to the HTML construction in jQuery Mobile. While I can easily targe ...