Select the first option by default
See original GitHub issueReproduction link
Steps to reproduce
This is a question
What is expected?
This is a question
What is actually happening?
This is a question
Environment | Info |
---|---|
antd | 4.22.6 |
React | latest |
System | any |
Browser | any |
Is there a way to set the first options in a select by default. For example,
<Form.Item >
<Select
options={options}
selectDefaultFirstOption={true} />
</Form.Item>
As options changes dynamically, the default value is always the first option element by default. I tried
initialValues
in ForminitialValue
in Form.ItemdefaultValue
inSelect
None of the above is working. Would any one kind enough in the ant design community enlighten me with the solution? Thanks a lot.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
How can I set the default value for an HTML <select> element?
In the following example, when run, the first <select> should show option with the value user as selected, and the second <select> should...
Read more >How to set the default value for an HTML <select> element
The option tag contains the value that would be used when selected. The default value of the select element can be set by...
Read more >First option in select dropdown appears selected when no ...
No option should be selected when none of the options match the bound value. For my app it is important that select dropdowns...
Read more >How to set the default value for an HTML ... - Educative.io
The challenge here is that, by default, the tag is displayed on the webpage with the first option. You will get this by...
Read more ><select>: The HTML Select element - HTML - MDN Web Docs
If no value attribute is included, the value defaults to the text contained inside the element. You can include a selected attribute on...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Lantianyou Consider wrapping the Select For FormItem
Thank you !