galki / material-ui-form

State and validation support for Material-UI form components
MIT License
11 stars 3 forks source link

Not work styling form element #53

Closed Slavenin closed 6 years ago

Slavenin commented 6 years ago

Hi! I try add style to form element, but className and style attributes did not work.

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);

image

galki commented 6 years ago

@Slavenin thanks for pointing this out. should be working in alpha22