1

I am trying to put some HTML (even <b> tags) in Bootstrap-Vue Input fields.

    <template>
      <b-form-input></b-form-input>
      <datalist id="my-list-id">
        <option v-for="size in sizes">{{ size }}</option>
      </datalist>
    </template>

...
new Vue({
    el: '#vue',
    data: {
        sizes: ['Manual Option', '<b>bold</b>first', 'Medium', 'Large', 'Extra Large'],

enter image description here

However, I was unable to find out how to use the HTML members, instead of plain-text members in the selection?

1 Answer 1

2

While not recommended due to possible Cross Site Scripting (XSS) attacks, you can use v-html to place HTML content inside elements (just make sure it is content that you provide and not users)

  <template>
    <div>
      <b-form-input list="my-list-id"></b-form-input>
      <datalist id="my-list-id">
        <option v-for="size in sizes" v-html="size"></option>
      </datalist>
    </div>
  </template>

Note that the HTML will not show in the <b-form-input>, as native <input> elements do not support HTML content.

Sign up to request clarification or add additional context in comments.

2 Comments

Well, so actually it's not possible to have it as other "combo box" extensions offer to have i.e. image + text in the chosen input field.
many thanks for noting that to me. As I've read about Vulnerabilities, and I wouldnt directly render any user-content without sanitization from backend.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.