Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

148
Views
Delete long text in TagInput

I have TagsInput where the user can enter any data (assumed to be links). Since links can be very long, I need a way to shorten their display so that the window does not stretch too much. I solved it with white-space: nowrap

Since I'm using TagsInput, the user should be able to delete the input. I have this functionality. And as you can see, it works on short links. But if the link is long, this cross is at the end and, accordingly, it is not visible. I would like everything to be displayed as follows (I marked the desired functionality in red):

Thus, I want the user to be able to delete a long link

.tag {
    display:flexbox;
    /* align-items: center; */
    margin: 5px 0;
    margin-right: 5px;
    padding: 0 5px;
    border: 1px solid black;
    border-radius: 5px;
    color: black;
    overflow:hidden;
    text-overflow: ellipsis;
    max-width: fit-content;
    white-space: nowrap;
}

Just in case, the part of the code where I define the button to remove the tag

...
    const deleteTag = (index) => {
    setTags(prevState => prevState.filter((tag, i) => i !== index))
}

return (
    <div className={classes.container}>
        {tags.map((tag, index) => <div className={classes.tag}>
            {tag}
            <ClearIcon className={classes.del} fontSize="small" onClick={() => deleteTag(index)} />
        </div>
        )}
        <input
            className={classes.input}
            value={input}
            placeholder={props.inputPlaceholder}
            onKeyDown={onKeyDown}
            onKeyUp={onKeyUp}
            onChange={onChange}
        />
    </div>);
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If you try to make it simple then you need to restructure your JSX:

<div className="tag">
  <div className="tag-name">www.google.com/dummytext/123</div>
  <ClearIcon className={classes.del} fontSize="small" onClick={() =>deleteTag(index)} />
</div>

CSS:

.tag {
  display: flex;
  border: 1px solid black;
  border-radius: 5px;
  padding: 0 5px;
  max-width: fit-content;
  margin: 5px 0;
}

.tag-name {
  margin-right: 5px;
  color: black;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: -moz-fit-content;
  max-width: fit-content;
  white-space: nowrap;
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!