material-components-web

Modular and customizable Material Design UI components for the web

Github星跟蹤圖

Version
Build Status
codecov
Chat
Screenshots

Material Components for the web

Material Components for the web (MDC Web) helps developers execute Material Design.
Developed by a core team of engineers and UX designers at Google, these components enable a reliable development workflow to build beautiful and functional web projects.

MDC Web strives to seamlessly incorporate into a wider range of usage contexts, from simple static websites to complex, JavaScript-heavy applications to hybrid client/server rendering systems. In short, whether you're already heavily invested in another framework or not, it should be easy to incorporate Material Components into your site in a lightweight, idiomatic fashion.

Material Components for the web is the successor to Material Design Lite. In addition to implementing the Material Design guidelines, it provides more flexible theming customization, not only in terms of color, but also typography, shape, states, and more. It is also specifically architected for adaptability to various major web frameworks.

NOTE: Material Components Web tends to release breaking changes on a monthly basis, but follows
semver so you can control when you incorporate them.
We typically follow a 2-week release schedule which includes one major release per month with breaking changes,
and intermediate patch releases with bug fixes.

Quick start

Using via CDN

<!-- Required styles for MDC Web -->
<link rel="stylesheet" href="https://unpkg.com/material-components-web@latest/dist/material-components-web.min.css">

<!-- Render textfield component -->
<label class="mdc-text-field">
  <input type="text" class="mdc-text-field__input" aria-labelledby="my-label">
  <span class="mdc-floating-label" id="my-label">Label</span>
  <div class="mdc-line-ripple"></div>
</label>

<!-- Required MDC Web JavaScript library -->
<script src="https://unpkg.com/material-components-web@latest/dist/material-components-web.min.js"></script>
<!-- Instantiate single textfield component rendered in the document -->
<script>
  mdc.textField.MDCTextField.attachTo(document.querySelector('.mdc-text-field'));
</script>

Please see quick start demo on codepen for full example.

Using NPM

This guide assumes you have webpack configured to compile Sass into CSS. To configure webpack, please see the full getting started guide. You can also see the final code and result in the Material Starter Kit.

Install textfield node module to your project.

npm install @material/textfield

HTML

Sample usage of text field component. Please see MDC Textfield component page for more options.

<label class="mdc-text-field">
  <input type="text" class="mdc-text-field__input" aria-labelledby="my-label">
  <span class="mdc-floating-label" id="my-label">Label</span>
  <div class="mdc-line-ripple"></div>
</label>

CSS

Load styles required for text field component.

@import "@material/textfield/mdc-text-field";

JavaScript

Import MDCTextField module to instantiate text field component.

import {MDCTextField} from '@material/textfield/index';
const textField = new MDCTextField(document.querySelector('.mdc-text-field'));

This'll initialize text field component on a single .mdc-text-field element.

Please see quick start demo on glitch for full example.

Need help?

We're constantly trying to improve our components. If Github Issues don't fit your needs, then please visit us on our Discord Channel.

概覽

名稱與所有者material-components/material-components-web
主編程語言TypeScript
編程語言JavaScript (語言數: 4)
平台
許可證MIT License
發布數619
最新版本名稱v14.0.0 (發布於 )
第一版名稱v0.1.0 (發布於 2016-12-15 12:39:07)
創建於2016-12-05 16:04:09
推送於2024-04-30 01:04:33
最后一次提交2024-04-25 11:42:41
星數17.1k
關注者數377
派生數2.2k
提交數7.4k
已啟用問題?
問題數2922
打開的問題數398
拉請求數3794
打開的拉請求數98
關閉的拉請求數1163
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?
去到頂部