Closed Slavenin closed 6 years ago
Hi! I try add style to form element, but className and style attributes did not work.
form
className
style
import React from 'react'; import PropTypes from 'prop-types'; import { withStyles } from '@material-ui/core/styles'; import MaterialUIForm from 'material-ui-form' import TextField from '@material-ui/core/TextField'; import Button from '@material-ui/core/Button'; const styles = theme => ({ form: { display: 'flex', flexDirection: 'row', textAlign: 'center' } }); class Login extends React.Component { submit(values, pristineValues) { console.log(values, pristineValues) // get all values and pristineValues on form submission } render() { const { classes } = this.props; return ( <div className={classes.form} > <MaterialUIForm onSubmit={this.submit} style={{ margin: '0 auto' }}> <TextField label="Login" type="text" name="username" value="" data-validators="isRequired" style={{ display: 'flex' }} /> <TextField label="Password" type="password" name="password" value="" data-validators="isRequired" /> <Button variant="raised" style={{ display: 'flex' }} type="submit">Submit</Button> </MaterialUIForm> </div> ); } } Login.propTypes = { classes: PropTypes.object.isRequired, }; export default withStyles(styles)(Login);
@Slavenin thanks for pointing this out. should be working in alpha22
Hi! I try add style to
form
element, butclassName
andstyle
attributes did not work.