Skip to content

Commit

Permalink
[docs] Document TextField helperText height (mui#22146)
Browse files Browse the repository at this point in the history
  • Loading branch information
morgan-sam authored Aug 13, 2020
1 parent 8dfe01c commit d625cec
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 0 deletions.
20 changes: 20 additions & 0 deletions docs/src/pages/components/text-fields/HelperTextAligned.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import * as React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import TextField from '@material-ui/core/TextField';

const useStyles = makeStyles({
root: {
display: 'flex',
alignItems: 'center',
},
});

export default function HelperTextAligned() {
const classes = useStyles();
return (
<div className={classes.root}>
<TextField helperText="Please enter your name" label="Name" />
<TextField helperText=" " label="Name" />
</div>
);
}
20 changes: 20 additions & 0 deletions docs/src/pages/components/text-fields/HelperTextAligned.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import * as React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import TextField from '@material-ui/core/TextField';

const useStyles = makeStyles({
root: {
display: 'flex',
alignItems: 'center',
},
});

export default function HelperTextAligned() {
const classes = useStyles();
return (
<div className={classes.root}>
<TextField helperText="Please enter your name" label="Name" />
<TextField helperText=" " label="Name" />
</div>
);
}
20 changes: 20 additions & 0 deletions docs/src/pages/components/text-fields/HelperTextMisaligned.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import * as React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import TextField from '@material-ui/core/TextField';

const useStyles = makeStyles({
root: {
display: 'flex',
alignItems: 'center',
},
});

export default function HelperTextMisaligned() {
const classes = useStyles();
return (
<div className={classes.root}>
<TextField helperText="Please enter your name" label="Name" />
<TextField label="Name" />
</div>
);
}
20 changes: 20 additions & 0 deletions docs/src/pages/components/text-fields/HelperTextMisaligned.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import * as React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import TextField from '@material-ui/core/TextField';

const useStyles = makeStyles({
root: {
display: 'flex',
alignItems: 'center',
},
});

export default function HelperTextMisaligned() {
const classes = useStyles();
return (
<div className={classes.root}>
<TextField helperText="Please enter your name" label="Name" />
<TextField label="Name" />
</div>
);
}
10 changes: 10 additions & 0 deletions docs/src/pages/components/text-fields/text-fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,16 @@ For number validation, one viable alternative is to use the default input type="

In the future, we might provide a [number input component](https://github.com/mui-org/material-ui/issues/19154).

### Helper text

The helper text prop affects the height of the text field. If two text fields are placed side by side, one with a helper text and one without, they will have different heights. For example:

{{"demo": "pages/components/text-fields/HelperTextMisaligned.js"}}

This can be fixed by passing a space character to the `helperText` prop:

{{"demo": "pages/components/text-fields/HelperTextAligned.js"}}

## Integration with 3rd party input libraries

You can use third-party libraries to format an input.
Expand Down

0 comments on commit d625cec

Please sign in to comment.