Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sherweb/ngx-materialize
Angular wrap around Materialize library
https://github.com/sherweb/ngx-materialize
angular component material material-design materialize materialize-css ngx
Last synced: 3 months ago
JSON representation
Angular wrap around Materialize library
- Host: GitHub
- URL: https://github.com/sherweb/ngx-materialize
- Owner: sherweb
- License: apache-2.0
- Created: 2016-12-22T20:37:47.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-04-01T08:34:17.000Z (almost 2 years ago)
- Last Synced: 2024-10-28T17:36:48.400Z (3 months ago)
- Topics: angular, component, material, material-design, materialize, materialize-css, ngx
- Language: TypeScript
- Homepage: https://sherweb.github.io/ngx-materialize/
- Size: 21.5 MB
- Stars: 314
- Watchers: 23
- Forks: 75
- Open Issues: 39
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
This library is an Angular wrap around Materialize library, a responsive CSS/JS framework that implements Material Design specifications from Google.
Demo and documentation : https://sherweb.github.io/ngx-materialize/
## Why ngx-materialize?
The main purpose of this library is to simplify the usage of Materialize within the Angular framework which make it more dynamic. To illustrate this, we have Playground sections in several component demo pages.
In other words, we ...
- Simplify components usage
- Initialize components automatically
- Handle Angular "quirks" with Materialize library
- Offer component injection when possible
- Provide a MediaService that allow customization according to view port size
- Add support for ReactiveForm with validation### Table of contents
- [Installation](#installation)
- [Icons](#icons)
- [Animation](#animation)
- [Usage](#usage)
- [Available features](#available-features)
- [Demo application](#demo-application)
- [Contribute](#contribute)
- [Credits](#credits)## Installation
The following commands will add ngx-materialize library to your `package.json` file along with its dependencies: Materialize CSS and jQuery.
```
npm install --save ngx-materialize
```Don't forget to include Materialize and jQuery in your application.
If you are using [Angular-CLI](https://github.com/angular/angular-cli) you can follow the example below :
#### angular.json
```diff
"styles": [
"src/styles.scss",
+ "node_modules/materialize-css/dist/css/materialize.min.css"
],
"scripts": [
+ "node_modules/jquery/dist/jquery.min.js",
+ "node_modules/materialize-css/dist/js/materialize.min.js"
],
```#### tsconfig
```diff
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"module": "es2015",
"types": [
+ "jquery",
+ "materialize-css"
]
},
"exclude": [
"src/test.ts",
"**/*.spec.ts"
]
}
```See also [Angular CLI 3rd Party Library Installation](https://github.com/angular/angular-cli/wiki/overview#global-library-installation) and [Using MaterializeCSS with your Angular 2 Angular CLI App](https://medium.com/@ladyleet/using-materializecss-with-your-angular-2-angular-cli-app-2eb64b05a1d2#.8p3uba85g).
## Icons
Ngx-materialize offers two "out-of-the-box" options for icons although you are free to use the library of your choice.
### Material Design Icons
To use [Material Design Icons](https://materialdesignicons.com/) (community project based on Google Material Icons with lots of added icons), which is used with `mz-icon-mdi` directive, you will need to add the library with the following command:```
npm install --save @mdi/font
```Don't forget to include Mdi library to your application.
If you are using [Angular-CLI](https://github.com/angular/angular-cli) you can follow the example below :
#### angular.json
```diff
"styles": [
"src/styles.scss",
"node_modules/materialize-css/dist/css/materialize.min.css",
+ "node_modules/@mdi/font/css/materialdesignicons.min.css"
],
```### Material Icons
To use [Material Icons](https://material.io/icons/) (official Google Material Icons library), which is used with `mz-icon` directive, you will need to add the following into the `` tag of your `index.html` file:```html
```
## Animation
Some components are using advance animation transition. You need to install `@angular/animations` and include `BrowserAnimationsModule` if you want those animation to work.```
npm install --save @angular/animations
```
```diff
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
+ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';import { AppModule } from './app.module';
@NgModule({
imports: [
+ BrowserAnimationsModule,
],
})
export class AppModule { }
```If you don't want to install a new dependency in your application, you can include `NoopAnimationsModule`.
```diff
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
+ import { NoopAnimationsModule } from '@angular/platform-browser/animations';import { AppModule } from './app.module';
@NgModule({
imports: [
+ NoopAnimationsModule,
],
})
export class AppModule { }
```## Usage
You must import component module you want to use inside your module to be able to use Materialize components.
```diff
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
+ import { MzButtonModule, MzInputModule } from 'ngx-materialize';import { HomeComponent } from './home.component';
@NgModule({
imports: [
CommonModule,
+ MzButtonModule,
+ MzInputModule,
],
declarations: [ HomeComponent ],
})
export class HomeModule { }
```### MaterializeModule deprecated
We will continue to maintain this module for a period of time to allow you to migrate your existing components to the new way.
We recommend to use the new component modules when you are building new component/application.If you still want to import only one module, you can create a separate `NgModule` in your application that imports all the `ngx-materialize` components. You will be able to include this module anywhere you like to use the components.
```
import { MzInputModule, MzValidationModule } from 'ngx-materialize';@NgModule({
imports: [
MzInputModule,
MzValidationModule,
],
exports: [
MzInputModule,
MzValidationModule,
],
})
export class CustomMaterializeModule { }
```## Available features
Page listed in [Native CCS Class](./native-css-class) will not be wrapped.
### Components
* Badge
* Button
* Card
* Checkbox
* Chip
* Collapsible
* Collection
* Datepicker
* Dropdown
* Feature discovery
* Form validation
* Icon
* Input
* Modal
* Navbar
* Pagination
* Parallax
* Progress
* Radio-Button
* Select
* Sidenav
* Spinner
* Switch
* Tab
* Textarea
* Timepicker
* Toast
* Tooltip### Services
* Media
## Demo application
A demo application is available at [https://sherweb.github.io/ngx-materialize/](https://sherweb.github.io/ngx-materialize/), or refer to the `./demo` folder and its [README](./demo/README.md).
## Road map
We (at SherWeb) are currently wrapping the components as we need them, and unfortunately, we cannot provide a specific road map.
If some components are missing, feel free to contribute.
## Contribute
Contributions are always welcome.
Make sure that :
- Your code style matches with the rest of the project
- Unit tests pass
- Linter passesAnd you are ready to go!
## Credits
Thanks to [Ali Mohammadi](https://github.com/ayalma) for donating the npm package name.