Skip to content
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

[Feature Request] Create a Prop that passes down to the Input component. #400

Open
hellb0rg opened this issue Nov 5, 2024 · 3 comments
Open
Labels
help wanted Extra attention is needed

Comments

@hellb0rg
Copy link

hellb0rg commented Nov 5, 2024

They keyword Mod allows me to pass a dict/string that is then translated into a data- variable on the input.
The problem is that the data- variable gets created on the root element rather than the input which means that the data- prop is unusable for a patternmatching callback.

Would be nice if one could add another keyword, something like inputMod, that functions like the Mod keyword but for the actual Input element.

@AnnMarieW
Copy link
Collaborator

@hellb0rg
Can you make a minimal example so I understand what you are looking for? I'm not familiar with the Mod keyword.

@hellb0rg
Copy link
Author

hellb0rg commented Nov 6, 2024

Lets see, ill try.
Mod allows one to pass something akin to {"validation-key":"123-2243"} which gets translated into data-validation-key="123-2243" on the root element of a input.

I would like a prop that does the same thing, but on the actual Input. If we call the prop inputMod it could look like this:
dmc.TextInput(id="username", inputMod={"validation-key":"username-validation"})

Which would generate the following html code:

<div autocomplete="off">
  <label id="username-label">Username</label>
   <div  data-variant="default">
      <input data-validation-key="username-validation" id="username" value="" >
    </div>
</div>

The idea is that we can create data-XXX variables on the actual input element rather than only the root element.

@AnnMarieW AnnMarieW changed the title Create a Prop that passes down to the Input component. [Feature Request] Create a Prop that passes down to the Input component. Nov 6, 2024
@AnnMarieW
Copy link
Collaborator

Hi @hellb0rg
This is a good suggestion!

It appears that all Mantine components support a mod prop which enables adding data props to the root element:
https://mantine.dev/styles/data-attributes/#mod-prop

Rather than having a specific inputMod prop, it might be better to have an inputWrapperProps that enables passing any valid prop to the Input component. (similar to the wrapperProps that passes props to the root)

it would be better to a have a generic inputWrapper prop so that you can add any props

@AnnMarieW AnnMarieW added the help wanted Extra attention is needed label Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants