Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Text field input props (#80)
Browse files Browse the repository at this point in the history
* Passing down `inputProps` from `input` object to MUI component

This change makes it possible to set <input> HTML's props like
min and max values, by passing them onto <TextField> `input` obj

* Added <TextField> story with example of a number field

Co-authored-by: Leandro Boscariol <leandro.boscariol@gnosis.io>
  • Loading branch information
alfetopito and Leandro Boscariol authored Jan 4, 2021
1 parent 3918dc1 commit 7d4d590
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/inputs/TextField/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function TextField({
<CustomTextField
{...rest}
{...customProps}
{...inputRest}
inputProps={inputRest}
className={className}
size={undefined}
name={name}
Expand Down
15 changes: 15 additions & 0 deletions src/inputs/TextField/textField.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@ export const SimpleTextField = (): React.ReactElement => {
);
};

export const SimpleNumberField = (): React.ReactElement => {
const [value, setValue] = useState<string>('');
return (
<form noValidate autoComplete="off" onSubmit={onSubmit}>
<TextField
id="standard-name"
label="Name"
value={value}
onChange={(e) => setValue(e.target.value)}
input={{ type: 'number', min: 5, max: 10, step: 1 }}
/>
</form>
);
};

export const Error = (): React.ReactElement => {
const [value, setValue] = useState<string>('some incorrect value');
return (
Expand Down

0 comments on commit 7d4d590

Please sign in to comment.