安装 Angular Material UI
安装
ng add @angular/material
? Choose a prebuilt theme name, or "custom" for a custom theme: Custom
? Set up HammerJS for gesture recognition? Yes
? Set up browser animations for Angular Material? Yes
创建 mat.module
$ ng g module mat --flat --module=app
CREATE src/app/mat.module.ts (187 bytes)
UPDATE src/app/app.module.ts (1231 bytes)
在模块中导入
// mat.module.ts
import { NgModule } from "@angular/core";
import { MatButtonModule } from "@angular/material";
@NgModule({
declarations: [],
imports: [MatButtonModule],
exports: [MatButtonModule],
})
export class MatModule {}
使用
<button mat-button>text</button>
自定义主题
// custom-theme.scss
// Custom Theming for Angular Material
// For more information: https://material.angular.io/guide/theming
@import '~@angular/material/theming';
// Plus imports for other components in your app.
// Include the common styles for Angular Material. We include this here so that you only
// have to load a single css file for Angular Material in your app.
// Be sure that you only ever include this mixin once!
@include mat-core();
// Define the palettes for your theme using the Material Design palettes available in palette.scss
// (imported above). For each palette, you can optionally specify a default, lighter, and darker
// hue. Available color palettes: https://material.io/design/color/
$ng7-primary: mat-palette($mat-blue, 500);
$ng7-accent: mat-palette($mat-pink, A200, A100, A400); // 默认值,更亮和更暗
// The warn palette is optional (defaults to red).
$ng7-warn: mat-palette($mat-red);
// Create the theme object (a Sass map containing all of the palettes).
$ng7-theme: mat-light-theme($ng7-primary, $ng7-accent, $ng7-warn);
// Include theme styles for core and each component used in your app.
// Alternatively, you can import and @include the theme mixins for each component
// that you are using.
@include angular-material-theme($ng7-theme);
html, body { height: 100%; }
body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; }
如何使用多个主题?文档
- 编辑 "custom-theme.scss" 添加新的主题:
@import "~@angular/material/theming";
@include mat-core();
// default design
$ng-elm-primary: mat-palette($mat-blue); // primary
$ng-elm-accent: mat-palette($mat-pink, A200, A100, A400); // secondary
$ng-elm-warn: mat-palette($mat-red);
$ng-elm-theme: mat-light-theme($ng-elm-primary, $ng-elm-accent, $ng-elm-warn);
@include angular-material-theme($ng-elm-theme);
// ajanuw design
$ajanuw-primary: mat-palette($mat-purple);
$ajanuw-accent: mat-palette($mat-amber, A200, A100, A400);
$ajanuw-warn: mat-palette($mat-deep-orange);
$ajanuw-theme: mat-dark-theme($ajanuw-primary, $ajanuw-accent, $ajanuw-warn);
// 在父类拥有“.mat-ajanuw-theme”时生效
.mat-ajanuw-theme {
@include angular-material-theme($ajanuw-theme);
}
html,
body {
height: 100%;
}
body {
margin: 0;
font-family: Roboto, "Helvetica Neue", sans-serif;
}
- 使用:
<button mat-button color="primary">default design</button>
<div class="mat-ajanuw-theme">
<button mat-button color="primary">ajanuw design</button>
</div
安装 Angular Material UI的更多相关文章
- Angular 2 to Angular 4 with Angular Material UI Components
Download Source - 955.2 KB Content Part 1: Angular2 Setup in Visual Studio 2017, Basic CRUD applicat ...
- Material使用11 核心模块和共享模块、 如何使用@angular/material
1 创建项目 1.1 版本说明 1.2 创建模块 1.2.1 核心模块 该模块只加载一次,主要存放一些核心的组件及服务 ng g m core 1.2.1.1 创建一些核心组件 页眉组件:header ...
- Angular Material Starter App
介绍 Material Design反映了Google基于Android 5.0 Lollipop操作系统的原生应用UI开发理念,而AngularJS还发起了一个Angular Material ...
- Angular Material & Hello World
前言 Angular Material(下称Material)的组件样式至少是可以满足一般的个人开发需求(我真是毫无设计天赋),也是Angular官方推荐的组件.我们通过用这个UI库来快速实现自己的i ...
- Angular Material design设计
官网: https://material.io/design/ https://meterial.io/components 优秀的Meterial design站点: http://material ...
- ASP.NET Core 2.1 Web API + Identity Server 4 + Angular 6 + Angular Material 实战小项目视频
视频简介 ASP.NET Core Web API + Angular 6的教学视频 我是后端开发人员, 前端的Angular部分讲的比较差一些, 可以直接看代码!!!! 这是一个小项目的实战视频, ...
- 开始使用Material UI
Material-UI采用 Material Design风格的React UI组件,所以要想学习material ui先要了解react. material ui安装 Material-UI 可以使 ...
- Angular Material 的设计之美
前言 Angular Material 作为 Angular 的官方组件库,无论是设计交互还是易用性都有着极高的质量.正如官方所说其目的就是构建基于 Angular 和 Typescript 的高质量 ...
- Angular Material
Angular Material 的设计之美 Ng-Matero 0.3 已发布,新增 module schematic 以及 page schematic,详见 README 前言 Angula ...
随机推荐
- Language Guide (proto3) | proto3 语言指南(十四)选项
Options - 选项 .proto文件中的单个声明可以使用许多 选项 进行注释.选项不会更改声明的总体含义,但可能会影响在特定上下文中处理声明的方式.可用选项的完整列表在google/protob ...
- StreamingContext详解,输入DStream和Reveiver详解
StreamingContext详解,输入DStream和Reveiver详解 一.StreamingContext详解 1.1两种创建StreamingContext的方式 1.2SteamingC ...
- UML——交互图(序列图+协作图)
交互图(interaction diagram):是协作图=通信图UML2.0以后的叫法=合作图=(Collaboration /Communication Diagram)以及序列图=顺序图=时序图 ...
- Pythonchallenge1过关攻略
第一关上来是一个电视,上面写着2^38,这就非常关键了,这时候我们已经有了大致思路,再看一眼电视机下面的话确认一下,"Hint: try to change the URL address. ...
- Java线程 - sleep()和wait()方法的区别, 线程阻塞BLOCKED和等待WAITING的区别
一. sleep()和wait()方法的区别 sleep()方法 sleep()方法是Thread类的方法,通过其定义可知是个native方法,在指定的时间内阻塞线程的执行.而且从其注释中可知,并不会 ...
- vuex-pathify 一个基于vuex进行封装的 vuex助手语法插件
首先介绍一下此插件 我们的目标是什么:干死vuex 我来当皇上!(开个玩笑,pathify的是为了简化vuex的开发体验) 插件作者 davestewart github仓库地址 官方网站,英文 说一 ...
- SPOJ 227 Ordering the Soldiers
As you are probably well aware, in Byteland it is always the military officer's main worry to order ...
- HTTP笔记2--简单的HTTP 协议
HTTP概念 HTTP用于客户端和服务器之间的通信 客户端:请求访问文本或图像等资源的一端 服务器端而提供资源响应的一端 通过请求和响应的交换达成通信 HTTP 协议规定,请求从客户端发出,最后服务器 ...
- 在kubernetes集群里集成Apollo配置中心(1)之交付Apollo-configservice至Kubernetes集群
1.Apollo简介 Apollo(阿波罗)是携程框架部门研发的分布式配置中心,能够集中化管理应用不同环境.不同集群的配置,配置修改后能够实时推送到应用端,并且具备规范的权限.流程治理等特性,适用于微 ...
- LINUX - vim高效操作
(一)可以为操作的一行添加下划线 set cursorline