Created
March 14, 2018 09:26
-
-
Save iamdanthedev/4c30ae4c6c416af2e7a14905c7357464 to your computer and use it in GitHub Desktop.
Styling material-ui components with not hussle
This file contains hidden or 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
import React from "react"; | |
import { withStyles } from "material-ui"; | |
import Select, { SelectProps } from "material-ui/Select"; | |
import { MenuItem } from "material-ui/Menu"; | |
type OwnProps = SelectProps & { | |
options: Array<{ label: string; value: string }>; | |
} | |
type Props = OwnProps & { | |
classes: any; | |
}; | |
const styles = theme => ({ | |
root: { | |
fontSize: "0.8rem" | |
}, | |
selectMenu: { | |
padding: 0 | |
}, | |
select: { | |
paddingRight: 20 | |
} | |
}); | |
export const InlineSelect: React.SFC<Props> = ({ options, ...rest }) => { | |
return ( | |
<Select {...rest}> | |
{options.map(option => <MenuItem value={option.value}>{option.label}</MenuItem>)} | |
</Select> | |
); | |
}; | |
export default withStyles(styles)(InlineSelect) as React.SFC<OwnProps>; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment