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

Using with Material UI #391

Open
andrwo opened this issue Sep 11, 2021 · 3 comments · May be fixed by #395
Open

Using with Material UI #391

andrwo opened this issue Sep 11, 2021 · 3 comments · May be fixed by #395

Comments

@andrwo
Copy link

andrwo commented Sep 11, 2021

Hi, I am trying to use this in Material UI.

Anyone here know how I can configure it so that it looks like the rest of the material UI TextField? Please help point the way.

Thanks in advance!

@andrewsantarin
Copy link
Contributor

andrewsantarin commented Sep 16, 2021

@andrwo Do share what your code looks like. It helps clear some uncertainties moving along.

  1. What versions of Material UI and React Intl Tel Input did you try?
  2. Do you use any wrappers to make things happen (e.g. <FormControl> wraps <IntlTelInput>)?
  3. Have you read the inner workings of both Material UI and React Intl Tel Input?

Disclaimer: I don't use Material UI at work, but I did try it out of curiosity.

Short answer

You have to write some logic yourself.

Long answer

See this CodeSandbox. Material UI implements a lot of logic under the hood just for the presentation, especially when some of has to be done via JS, such as focus state. This model code is just for the outline variant. If you want a solid API, you'll have to extend it some more. A HACK-y approach is necessary to get the fieldset-like effect of the outline variant label.

@andrwo
Copy link
Author

andrwo commented Sep 20, 2021

Thanks, @andrewsantarin for the detailed answer!

I very much appreciate it. It looks like I can adapt it for my usage.

@andrwo
Copy link
Author

andrwo commented Oct 18, 2021

Just to update this track, I found a way to make it work nicely without hacking the CSS, but it involves modifying the underlying code in IntlTelInput.js.

Currently, the code is fixed to render the component using a <div> wrapper around the <FlagDropDown> component and an standard <input> component. I've made a PR (#395) to allow users to override and customize using their own rendering function. This allows the user to take control of the rendering to suit their own usage.

I have also shown in the PR how it can be adapted for use with Material UI and Reactstrap in the PR, both which I have tested.

I hope the group admins can help guide the way on how I can get the PR approved as I do feel this will be a very useful addition to the library (this is also my first time submitting a PR).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants