dioxus icon indicating copy to clipboard operation
dioxus copied to clipboard

It's impossible to set `value=` on `<input>` elements?

Open TheLostLambda opened this issue 5 months ago • 1 comments

Problem

I'm talking about this value: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#value.

It's used as a default value that, for example, form resets return to. After calling reset (https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/reset), I expected my values to return to those I specified in rsx! like this:

input {
    value: "5",
    min: "0",
    r#type: "number",
    required: "true",
}

But instead of returning the input to the value 5, it clears it!

Looking at the HTML, this seems to be because value is treated specially in RSX, so it's not actually even setting the value=... on the ` element!

Steps To Reproduce

Steps to reproduce the behavior:

  • Create an input in RSX and specify value: "foo"
  • Examine the generated HTML and see that the value="foo" is absent!

Expected behavior

Should have <input value="foo" ... />

Environment:

  • Dioxus version: 0.6.3

I think it would be fine to just add the value=... when the <input> element is created?

TheLostLambda avatar Jun 18 '25 14:06 TheLostLambda