Replies: 3 comments 1 reply
-
Do you mean focus on pageload? You can use https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/autofocus But it's not very accessible. |
Beta Was this translation helpful? Give feedback.
-
You can also bind a variable (e.g. |
Beta Was this translation helpful? Give feedback.
-
I see now how vague my questions is! I understand how I can focus a normal input element, and it would be trivial to modify the shadcn-Input source to allow focusing the input. But is there a way to do this without modifying the code. I was kind of expecting a focus() method to be available on the shadcn- component, but perhaps there is another way? |
Beta Was this translation helpful? Give feedback.
-
Change Type
Addition
Proposed Changes
Perhaps this question is so basic that it's obvious how to solve it, but I still got stuck.
How can I focus an element from code?
I converted my code from using a normal to the shadcn and I now need a way to focus my input field in the same way as I did before (inputField.focus() // InputField being bound to the actual ).
Can the concepts for this be found in the documentation? How can it be done? :)
Beta Was this translation helpful? Give feedback.
All reactions