What is MaterializeCSS?
From what I've seen, it's a CSS framework that's been used by thousands of websites around the world. List from wappalyzer.com. So far, I can see how it has a similar principles with Bootstrap but HTML! While a lot of times compared to Bootstrap, I learned that Bootstrap mainly uses JS-based templates unlike MaterializeCSS that mainly uses HTML & vanilla JS. But like Bootstrap, it's free, is an open-source tool and has a public repo on Github.
So how are we going to try our Materialize today? We'll try to apply some components to one of my projects and see how it works! I'm going to tinker this project with materialize!
So this is what we're working with..
You can download it to you local machine with the link they provided, through npm (
npm install materialize-css@next) or through a link that you can add to your html(which we'll be using today).
Copy & paste these inside the
<head> tag in your index.html.
And viola! Now we can use Materialize to add more components to our mini project!
If you saw the page, it seems like it needed more components like a navbar. Application goes so easy like this;
- Go to Components, then Navbar
- For demo purposes, let's just choose the first one.
Once done, our code would look like this;
And for our page, now it has a navbar!
Now you may ask, the examples on the website has icons. Yes! Materialize can also provide icons for your project with easy steps and a lot of options to choose from.
- Go to Components, then Icons
- Copy & paste the script they have and paste it in the tag of your index.html, just like how we installed Materialize in the beginning.
<link href="https://fonts.googleapis.com/iconfamily=Material+Icons" rel="stylesheet">
<i className="[SIZE] material-icons">[NAME OF ICON]</i> //So, if we want a small sun icon <i className="small material-icons">wb_sunny</i>
Then after adding it to our code, now we have this cool navbar with some nifty icons!
Now we have our navbar, but I want to change its color? Definitely can do this with CSS, but let's try and utilize more of our framework here. Materialize also provides a range of colors we can apply to our components!
You can use SASS/CSS for this. But the one we're using will be the className method.
To add a specific color to our Navbar, let's add it in it's className:
<div className="nav-wrapper pink lighten-3"> ... </div>
Results using a couple of the color palettes:
Finishing touches & Results
Now that we had a chance to play around with some components, I tried to add more things in our mock website and this is how it turned out!
I hope i got you curious on MaterializeCSS's potential and inspire you to use it on your projects!
Will definitely keep this in my arsenal and keep trying it out! What do you guys think of it? Let me know in comments below. Until the next!
Top comments (1)
Materialize is death