-
-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow standard html attributes to be passed to input
#59
Comments
After some proper look at the Svelte documentation, I found https://svelte.dev/docs#template-syntax-attributes-and-props
I think this could work. |
I'm not too sure about this, what's your use case? I wouldn't want people to for example add a |
@probablykasper the most straightforward use case I can think of is adding an id to be able to semantically use a <label for="some input>
<input id="some input" />
</label> |
We could add an id prop |
It is better to allow extra class attributes to be in |
|
I am not sure if this is the case, but the source doesn't show the class for the <input
class:invalid={!valid}
type="text"
value={text} |
Ah yeah you're right, it styles the |
Could you elaborate on this please? To make it work with forms, this is needed. Some reasons to allow control on attributes of input:
Overall, I think allowing all standard input attributes, except where it would interfere with the custom logic of the component would be good idea i think. This way, it would be an enhanced version of |
The input is a customizable user-facing value, not a data value. Parsing on the server would get complicated, especially for user-dependent formats. It also wouldn't work for the I'd be happy to have other attributes that make sense, like Would be good to have built-in |
So ... how can we use this in forms? |
By binding to the date value and putting it in an input element |
That's exactly what I need because of Accessibility reasons to make possible. |
It seems we have some alignment that at least I think the remaining big item is about the implementation strategy. The way I see it we have at least two potential solutions 1- Expose specific, hardcoded attributes for Any pros/cons you all see here? cc @probablykasper |
What's the problem of giving the possibility to pass all props? It would be the most flexible way. |
I don't want to allow all props for the reasons I already mentioned. |
Could we also add a "required" attribute to be passed. |
About |
Hello. I don't have a ton of experience in Svelte yet so maybe this is not an issue, but it would be great to allow any valid html attribute to be applied to the inner
input
this library exposes. Some examples I can think ofid
aria-
attributesdata-
attributesIs there an easy way to do this in Svelte or one would need to create wrapper proprs for all of them? This doesn't scale well with dynamic ones like
data-
which are custom (valid) attributes. Here's an example of how Vue handles thisHappy to put up a PR once we agree on the strategy here
The text was updated successfully, but these errors were encountered: