Need help with angular2-materialize?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

416 Stars 146 Forks MIT License 298 Commits 130 Opened issues


Angular 2 support for Materialize CSS framework.

Services available


Need anything else?

Contributors list

Angular2 Materialize

travis build version downloads MIT Licence semantic-release Commitizen friendly PRs Welcome


Angular 2 support for Materialize CSS framework

This library adds support for the Materialize CSS framework in Angular 2. It is needed to add the dynamic behavior of Materialize CSS that is using JavaScript rather than plain CSS.

View demo here:

To use the library you need to import it once per project and then use its MaterializeDirective directive for binding it to any component that needs a dynamic behavior, like collapsible panels, tooltips, etc.

Using angular2-materialize

Start by following the Angular CLI or webpack instructions below to add the required dependencies to your project.

Add the MaterializeModule to your NgModule: ```js import { MaterializeModule } from "angular2-materialize";

@NgModule({ imports: [ //... MaterializeModule, ], //... }) ```

In your component, use it for dynamic behavior. For example, for collapsible panels: ``

    selector: "my-component",
  • filter_dramaFirst

    Lorem ipsum dolor sit amet.

  • placeSecond

    Lorem ipsum dolor sit amet.

  • whatshotThird

    Lorem ipsum dolor sit amet.

Apply an empty [MaterializeDirective]( attribute directive for top level components, like forms:

The MaterializeDirective attribute directive (materialize) accepts any MaterializeCSS initialization call to apply to the element. The list of supported functions are provided by MaterializeCSS. Examples: collapsible, modal, tooltip, dropdown, tabs, material_select, sideNav, etc.

For example, to apply tooltip:

Hover me!

The Materialize attribute directive also allows specifying parameters to be passed to the function, but providing a materializeParams attribute returning an array of params. Use it with a function call or even by inlining the params in the HTML.

Another useful option is emitting actions on an element. You may want to do that for calling Materialize functions, like closing a modal dialog or triggering a toast. You can do that by setting the materializeActions attribute, which accepts an EventEmitter. The emitted events can either be a "string" type action (Materialize function call) or a structure with action and parameters:

The example below shows how you'd create a modal dialog and use the actions to open or close it. ```html <!-- Modal Trigger --> Modal

  import {MaterializeAction} from 'angular2-materialize';
  modalActions = new EventEmitter();
  openModal() {
  closeModal() {

For dynamic select elements apply the materializeSelectOptions directive to trigger element updates when the options list changes:



Installing & configuring angular2-materialize in projects created with the Angular CLI

Install MaterializeCSS and angular2-materialize from npm

npm install materialize-css --save
npm install angular2-materialize --save

jQuery 2.2 and Hammer.JS are required

npm install [email protected]^2.2.4 --save
npm install hammerjs --save

Edit the angular-cli.json : * Go to section apps and find styles array inside it (with only styles.css value by default), add the following line inside array before any styles:

  • Go to section apps and find scripts array inside it, and add the following lines inside array

Add to the top of app.module.ts

import { MaterializeModule } from 'angular2-materialize';

Add MaterializeModule inside imports array of @NgModule decorator in app.module.ts

Add this line to header of index.html

Installing and configuring angular2-materialize with webpack

Install MaterializeCSS and angular2-materialize from npm

npm install materialize-css --save
npm install angular2-materialize --save

MaterializeCSS required jQuery and HammerJS. Check the exact version materialize-css is compatible with:

npm install [email protected]^2.2.4 --save
npm install hammerjs --save

Add the Google MD fonts to your index.html:


Import materialize-css styles:


Add the following plugin to your webpack configuration to provide jQuery:

const ProvidePlugin = require('webpack/lib/ProvidePlugin');
module.exports = {
  plugins: [
      new ProvidePlugin({
          "window.jQuery": "jquery",
          Hammer: "hammerjs/hammer"

Import MaterializeCSS programatically, in the same place where you import angular2-materialize module (usually in your main module, or shared module):

import 'materialize-css';
import { MaterializeModule } from 'angular2-materialize';

Loading additional resources

Another thing you would need to confirm is being able to load web fonts properly:

{ test: /.(png|woff(2)?|eot|ttf|svg)(\?[a-z0-9=\.]+)?$/, loader: 'url-loader?limit=100000' },
Notice that the url-loader is required for this to work (npm install it).

The following example project is a fork of the angular2-webpack-starter with the addition of angular2-materialize: InfomediaLtd/angular2-webpack-starter

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.