Skip to content

Commit

Permalink
add hiddenLabel proptype to FilledInput
Browse files Browse the repository at this point in the history
  • Loading branch information
siriwatknp committed May 14, 2021
1 parent e526be5 commit c33350f
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/pages/api-docs/filled-input.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"endAdornment": { "type": { "name": "node" } },
"error": { "type": { "name": "bool" } },
"fullWidth": { "type": { "name": "bool" } },
"hiddenLabel": { "type": { "name": "bool" } },
"id": { "type": { "name": "string" } },
"inputComponent": { "type": { "name": "elementType" }, "default": "'input'" },
"inputProps": { "type": { "name": "object" }, "default": "{}" },
Expand Down
11 changes: 10 additions & 1 deletion docs/src/pages/components/text-fields/TextFieldHiddenLabel.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import * as React from 'react';
import Box from '@material-ui/core/Box';
import FilledInput from '@material-ui/core/FilledInput';
import TextField from '@material-ui/core/TextField';

export default function TextFieldHiddenLabel() {
return (
<Box
component="form"
sx={{
'& .MuiTextField-root': { m: 1, width: '25ch' },
'& .MuiFilledInput-root': { m: 1, width: '25ch' },
}}
noValidate
autoComplete="off"
Expand All @@ -31,6 +32,14 @@ export default function TextFieldHiddenLabel() {
variant="filled"
/>
</Box>
<Box sx={{ display: 'flex', alignItems: 'center' }}>
<label htmlFor="filled-hidden-label-input">Hidden label</label>
<FilledInput
hiddenLabel
id="filled-hidden-label-input"
defaultValue="Filled Input"
/>
</Box>
</Box>
);
}
11 changes: 10 additions & 1 deletion docs/src/pages/components/text-fields/TextFieldHiddenLabel.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import * as React from 'react';
import Box from '@material-ui/core/Box';
import FilledInput from '@material-ui/core/FilledInput';
import TextField from '@material-ui/core/TextField';

export default function TextFieldHiddenLabel() {
return (
<Box
component="form"
sx={{
'& .MuiTextField-root': { m: 1, width: '25ch' },
'& .MuiFilledInput-root': { m: 1, width: '25ch' },
}}
noValidate
autoComplete="off"
Expand All @@ -31,6 +32,14 @@ export default function TextFieldHiddenLabel() {
variant="filled"
/>
</Box>
<Box sx={{ display: 'flex', alignItems: 'center' }}>
<label htmlFor="filled-hidden-label-input">Hidden label</label>
<FilledInput
hiddenLabel
id="filled-hidden-label-input"
defaultValue="Filled Input"
/>
</Box>
</Box>
);
}
1 change: 1 addition & 0 deletions docs/translations/api-docs/filled-input/filled-input.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"endAdornment": "End <code>InputAdornment</code> for this component.",
"error": "If <code>true</code>, the <code>input</code> will indicate an error. The prop defaults to the value (<code>false</code>) inherited from the parent FormControl component.",
"fullWidth": "If <code>true</code>, the <code>input</code> will take up the full width of its container.",
"hiddenLabel": "If <code>true</code>, the label is hidden. This is used to increase density for a <code>FilledInput</code>. Be sure to add <code>aria-label</code> to the <code>input</code> element.",
"id": "The id of the <code>input</code> element.",
"inputComponent": "The component used for the <code>input</code> element. Either a string to use a HTML element or a component.",
"inputProps": "<a href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#Attributes\">Attributes</a> applied to the <code>input</code> element.",
Expand Down
7 changes: 7 additions & 0 deletions packages/material-ui/src/FilledInput/FilledInput.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ export interface FilledInputProps extends StandardProps<InputBaseProps> {
/** Styles applied to the input element if `endAdornment` is provided. */
inputAdornedEnd?: string;
};
/**
* If `true`, the label is hidden.
* This is used to increase density for a `FilledInput`.
* Be sure to add `aria-label` to the `input` element.
* @default false
*/
hiddenLabel?: boolean;
/**
* If `true`, the input will not have an underline.
*/
Expand Down
7 changes: 7 additions & 0 deletions packages/material-ui/src/FilledInput/FilledInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,13 @@ FilledInput.propTypes /* remove-proptypes */ = {
* @default false
*/
fullWidth: PropTypes.bool,
/**
* If `true`, the label is hidden.
* This is used to increase density for a `FilledInput`.
* Be sure to add `aria-label` to the `input` element.
* @default false
*/
hiddenLabel: PropTypes.bool,
/**
* The id of the `input` element.
*/
Expand Down

0 comments on commit c33350f

Please sign in to comment.