Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

TikTina's avatar

How to add a fixed text on a dropdown, tailwind

How can I put visible text on these dropdowns: https://imgur.com/a/j7VfwQ0

This is my code, I thought that this 'selected' feature would complete the work, but apparently not.

 <select v-model="form.symptoms_1"
                            class="form-select appearance-none block w-full mb-4 px-3 py-1.5 text-base font-normal text-gray-700 bg-white
                     bg-clip-padding bg-no-repeat border border-solid border-gray-300 rounded transition ease-in-out m-0
                     focus:text-gray-700 focus:bg-white focus:border-blue-600 focus:outline-none" aria-label="Default select example">
                        <option selected>Choose your symptom</option>
                        <option v-for="(symptom, id) in options" :key="id" :value="id">{{ symptom }}</option>
                    </select>

0 likes
16 replies
Nakov's avatar
Nakov
Best Answer
Level 73

And if you remove this line

<option v-for="(symptom, id) in options" :key="id" :value="id">{{ symptom }}</option>

Do you then see the text?

I believe the reason is because on the default option which you've put selected to you don't have a value, and then there is a default value in your form.symptoms_1 property which does not match a no value option, will show as an empty dropdown.

So you make sure that you have value="" on your first option or -1 as a value, and then initialize the form.symptoms_1 to be either empty string or -1 whichever you chose.

TikTina's avatar

@Nakov I set the value on the first option feature, but I didn't understand what to do with form.symptoms_1

Nakov's avatar

@TikTina in your data() how do you initialize the form object? Set the default to the symptoms_1 to match the value="" you set for the default option.

let form = {
	symptoms_1: "",
};

Do you initialize it at all or?

TikTina's avatar

@Nakov

data(){
            return{
                form:{
                    mrid:this.medicalRecordId,
                    symptoms:'',
                    when_problem_started:'',
                    pain_area:'',
                    symptoms_1:[],
                    symptoms_2:[],
                    symptoms_3:[],
                }
Nakov's avatar

@TikTina why do you use an array [] when there is only one selected? change the [] to the value you'll use in the default option.

1 like
mihcael's avatar

change the text-grey to text-dark or something and check it.

Tray2's avatar

Is it something like this you are looking for?

<option value="" disabled selected>Select your symptom</option>
TikTina's avatar

@Sinnbeck I can't because, as @nakov said, I can see the text if I remove <option v-for="(symptom, id) in options" :key="id" :value="id">{{ symptom }}</option> since this part is connected to the database. So If I copy-paste the code from the view it would have the text"Choose your symptom", because the data from the database are not listed. Only If I now write every part here including the database.

Sinnbeck's avatar

@TikTina you just check it in the rendered html and copy it from there

F12 -> Elements

Sinnbeck's avatar

@TikTina step by step

  1. open page in Chrome
  2. F12
  3. Elements
  4. find and click container of the selects in the html source
  5. copy
  6. open tailwind play page
  7. paste
  8. share the example here
Sinnbeck's avatar

@TikTina so it works in the play example but not on the real page? Sorry, I might be confused by the topic saying you need help with tailwind, but you actually need help with vue?

Please or to participate in this conversation.