forked from mui/material-ui
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[docs] Show how to change the color of the TextField (mui#8880)
- Loading branch information
1 parent
7820eec
commit 5f2331a
Showing
4 changed files
with
112 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
// @flow weak | ||
|
||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { withStyles } from 'material-ui/styles'; | ||
import Input, { InputLabel } from 'material-ui/Input'; | ||
import TextField from 'material-ui/TextField'; | ||
import { FormControl } from 'material-ui/Form'; | ||
import purple from 'material-ui/colors/purple'; | ||
|
||
const styles = theme => ({ | ||
container: { | ||
display: 'flex', | ||
flexWrap: 'wrap', | ||
}, | ||
formControl: { | ||
margin: theme.spacing.unit, | ||
}, | ||
inputLabelFocused: { | ||
color: purple[500], | ||
}, | ||
inputInkbar: { | ||
'&:after': { | ||
backgroundColor: purple[500], | ||
}, | ||
}, | ||
textFieldRoot: { | ||
padding: 0, | ||
'label + &': { | ||
marginTop: theme.spacing.unit * 3, | ||
}, | ||
}, | ||
textFieldInput: { | ||
borderRadius: 4, | ||
background: theme.palette.common.white, | ||
border: '1px solid #ced4da', | ||
fontSize: 16, | ||
padding: '10px 12px', | ||
width: 'calc(100% - 24px)', | ||
transition: theme.transitions.create(['border-color', 'box-shadow']), | ||
'&:focus': { | ||
borderColor: '#80bdff', | ||
boxShadow: '0 0 0 0.2rem rgba(0,123,255,.25)', | ||
}, | ||
}, | ||
textFieldFormLabel: { | ||
fontSize: 18, | ||
}, | ||
}); | ||
|
||
function CustomizedInputs(props) { | ||
const { classes } = props; | ||
|
||
return ( | ||
<div className={classes.container}> | ||
<FormControl className={classes.formControl}> | ||
<InputLabel | ||
FormControlClasses={{ | ||
focused: classes.inputLabelFocused, | ||
}} | ||
htmlFor="custom-color-input" | ||
> | ||
Name | ||
</InputLabel> | ||
<Input | ||
classes={{ | ||
inkbar: classes.inputInkbar, | ||
}} | ||
id="custom-color-input" | ||
/> | ||
</FormControl> | ||
<TextField | ||
defaultValue="react-bootstrap" | ||
label="Bootstrap" | ||
InputProps={{ | ||
disableUnderline: true, | ||
classes: { | ||
root: classes.textFieldRoot, | ||
input: classes.textFieldInput, | ||
}, | ||
}} | ||
InputLabelProps={{ | ||
shrink: true, | ||
className: classes.textFieldFormLabel, | ||
}} | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
CustomizedInputs.propTypes = { | ||
classes: PropTypes.object.isRequired, | ||
}; | ||
|
||
export default withStyles(styles)(CustomizedInputs); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters