question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[TextField] Add "input" property for custom Input component

See original GitHub issue

Like Select does, It’d be useful to allow TextField to receive a custom Input component.

  • I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

Passing a custom Input element via the input prop.

<TextField
  label="Name"
  input={<CustomInput name="amount" id="amount-simple" />}
/>

Current Behavior

Having to stick to the default Mui Input

<TextField
  label="Name"
/>

Context

My custom Input shows a specific icon depending on the error prop

Your Environment

Tech Version
Material-UI 1.0.0-beta.31

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
oliviertassinaricommented, Jan 31, 2018

@alltom You can already do it this way:

<TextField
  label="Name"
  InputProps={{
    inputComponent: <CustomInput name="amount" id="amount-simple" />,
  }}
/>

We should minimize as much as possible the API surface. I don’t think that adding a inputComponent component to the TextField will be wise. At some point, we removed inputProps too. But people were complaining about it as it’s a common use case. I don’t think we are in a common use case here. Thanks for raising this point 👍 .

0reactions
ElAnonimocommented, Apr 17, 2020

@rastegars Did you get the CustomInput to show on the screen? I couldn’t get mine and also my custom Input component doesn’t show the auto suggestion list.

EDIT. Got the custom Input component to show with

<TextField
  label="inputData"
  InputProps={{
    inputComponent: () => <Input name="inputData" />
  }}
/>
Read more comments on GitHub >

github_iconTop Results From Across the Web

[TextField] Add "input" property for custom Input component
Passing a custom Input element via the input prop. <TextField label="Name" input={<CustomInput name="amount" id="amount-simple" />} / ...
Read more >
React - Material UI - TextField controlled input with custom ...
InputProps : This provides properties to the Material UI component that is selected based on the variant property i.e. OutlinedInput , ...
Read more >
React Text Field component - Material UI - MUI
Text Fields let users enter and edit text. Text fields allow users to enter text into a UI. They typically appear in forms...
Read more >
Create and style a text field - Flutter documentation
TextField is the most commonly used text input widget. By default, a TextField is decorated with an underline. You can add a label,...
Read more >
How to Create Your Own React Text Field | brettfisher.dev
import React from 'react'; const TextField = () => { return <input />; }; export default TextField;. Test it out in your App.tsx...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found