Skip to content

Instantly share code, notes, and snippets.

@ilan-schemoul
Created April 9, 2017 08:44
Show Gist options
  • Save ilan-schemoul/dfab1fc90b40d507d6adb001bcb50969 to your computer and use it in GitHub Desktop.
Save ilan-schemoul/dfab1fc90b40d507d6adb001bcb50969 to your computer and use it in GitHub Desktop.
Search box with react@next
import React from 'react';
import Icon from '/node_modules/material-ui/Icon/Icon';
import Layout from '/node_modules/material-ui/Layout/Layout';
import Paper from '/node_modules/material-ui/Paper/Paper';
import Magnify from '/node_modules/mdi-react/MagnifyIcon.js';
import injectSheet from 'react-jss';
const styles = {
outsideContainer: {
width: '100%',
height: '70%',
},
insideContainer: {
marginTop: '0 !important',
height: '100%',
},
inputBox: {
flexGrow: '1 !important',
},
input: {
width: '100%',
border: 0,
'&:focus': {
outline: 0,
},
},
iconContainer: {
marginLeft: 8,
paddingRight: '0 !important',
},
};
function SearchBar({ classes }) {
return (
<Paper className={classes.outsideContainer}>
<Layout container align="center" className={classes.insideContainer}>
<Layout item className={classes.iconContainer}>
<Icon><Magnify /></Icon>
</Layout>
<Layout item className={classes.inputBox}>
<input type="text" className={classes.input} />
</Layout>
</Layout>
</Paper>
);
}
export default injectSheet(styles)(SearchBar);
@devuxer
Copy link

devuxer commented May 16, 2017

Interesting. I'd like to try something based on this, but I'm curious where Layout comes from. My install of material-ui seems to be lacking that component.

@doofy
Copy link

doofy commented May 28, 2017

@devuxer I guess Layout comes from material ui next (its the next version of material ui that is not released yet)

@cilf
Copy link

cilf commented Mar 7, 2018

Got here looking for search input. In the end I took the solution from MUI docs site itself. The search input in their blue topbar is located here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment