Convert Figma logo to code with AI

material-components logomaterial-web

Material Design Web Components

9,172
872
9,172
134

Top Related Projects

Material Design Components in HTML/CSS/JS

Material UI: Comprehensive React component library that implements Google's Material Design. Free forever.

Component infrastructure and Material Design components for Angular

39,623

🐉 Vue Component Framework

20,694

A React-based UI toolkit for the web

Materialize, a CSS Framework based on Material Design

Quick Overview

Material Web is an open-source project by Google that provides web components implementing Material Design 3. These components are built using modern web technologies and are designed to be lightweight, customizable, and easy to integrate into web applications. Material Web aims to bring the latest Material Design principles to the web platform.

Pros

  • Implements Material Design 3, providing a modern and consistent UI
  • Built with web components, offering excellent encapsulation and reusability
  • Lightweight and performant, with a focus on minimal bundle size
  • Highly customizable through CSS custom properties and parts

Cons

  • Still in development, with some components and features not yet fully implemented
  • Limited browser support compared to more established UI libraries
  • Requires understanding of web components, which may have a learning curve for some developers
  • Documentation is still evolving and may not be as comprehensive as more mature projects

Code Examples

  1. Basic button usage:
<script type="module">
  import '@material/web/button/filled-button.js';
</script>

<md-filled-button>Click me</md-filled-button>
  1. Customizing a text field:
<script type="module">
  import '@material/web/textfield/filled-text-field.js';
</script>

<style>
  md-filled-text-field {
    --md-filled-text-field-container-color: #f0f0f0;
    --md-filled-text-field-label-text-color: #006400;
  }
</style>

<md-filled-text-field label="Enter your name"></md-filled-text-field>
  1. Using a checkbox:
<script type="module">
  import '@material/web/checkbox/checkbox.js';
</script>

<md-checkbox touch-target="wrapper">
  <input type="checkbox" slot="input">
  <span>Check me</span>
</md-checkbox>

Getting Started

To start using Material Web components in your project:

  1. Install the package:

    npm install @material/web
    
  2. Import and use components in your HTML:

    <script type="module">
      import '@material/web/button/filled-button.js';
      import '@material/web/checkbox/checkbox.js';
    </script>
    
    <md-filled-button>Click me</md-filled-button>
    <md-checkbox>
      <input type="checkbox" slot="input">
      <span>Check me</span>
    </md-checkbox>
    
  3. Customize components using CSS custom properties:

    md-filled-button {
      --md-filled-button-container-color: #4CAF50;
      --md-filled-button-label-text-color: white;
    }
    

Competitor Comparisons

Material Design Components in HTML/CSS/JS

Pros of Material Design Lite

  • Lightweight and easy to integrate into existing projects
  • Broad browser compatibility, including older versions
  • Simpler learning curve for developers new to Material Design

Cons of Material Design Lite

  • No longer actively maintained or updated
  • Limited component set compared to newer alternatives
  • Lacks some modern features and customization options

Code Comparison

Material Design Lite:

<button class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect">
  Button
</button>

Material Web:

<md-filled-button>Button</md-filled-button>

Material Design Lite uses classes to define component styles and behaviors, while Material Web uses custom elements for a more declarative approach. Material Web's implementation is generally more concise and aligns better with modern web component standards.

Material Web offers a more extensive set of components, better customization options, and follows the latest Material Design guidelines. It's actively maintained and developed by Google, ensuring compatibility with current web standards and practices.

However, Material Design Lite may still be suitable for projects requiring support for older browsers or those looking for a simpler implementation of Material Design principles. Its lightweight nature can be advantageous for smaller projects or quick prototypes.

Material UI: Comprehensive React component library that implements Google's Material Design. Free forever.

Pros of Material-UI

  • Extensive component library with a wide range of pre-built components
  • Strong community support and frequent updates
  • Comprehensive documentation and examples

Cons of Material-UI

  • Larger bundle size due to the extensive feature set
  • Steeper learning curve for customization and theming
  • Less adherence to Material Design specifications compared to Material Web

Code Comparison

Material-UI:

import Button from '@mui/material/Button';

function App() {
  return <Button variant="contained">Hello World</Button>;
}

Material Web:

<script type="module">
  import '@material/web/button/filled-button.js';
</script>

<md-filled-button>Hello World</md-filled-button>

Material Web focuses on web components and custom elements, while Material-UI uses React components. Material Web aims for closer alignment with Material Design guidelines and potentially smaller bundle sizes. Material-UI offers more flexibility and a broader ecosystem but may require more setup and configuration. Both libraries provide robust solutions for implementing Material Design in web applications, with different trade-offs in terms of ease of use, customization, and performance.

Component infrastructure and Material Design components for Angular

Pros of Angular Components

  • Tightly integrated with Angular framework, providing seamless compatibility
  • Extensive documentation and community support
  • Offers a wide range of pre-built, customizable components

Cons of Angular Components

  • Limited to Angular applications, not framework-agnostic
  • Steeper learning curve for developers new to Angular
  • Larger bundle size due to Angular dependencies

Code Comparison

Material Web:

<md-filled-button>Click me</md-filled-button>

Angular Components:

<button mat-raised-button>Click me</button>

Summary

Material Web is a framework-agnostic implementation of Material Design components, while Angular Components is specifically designed for Angular applications. Material Web offers greater flexibility and lighter weight, but Angular Components provides deeper integration with the Angular ecosystem and more extensive documentation. The choice between the two depends on the project's requirements and the development team's familiarity with Angular.

39,623

🐉 Vue Component Framework

Pros of Vuetify

  • Extensive ecosystem with a large community and comprehensive documentation
  • Offers a wide range of pre-built components and layouts
  • Seamless integration with Vue.js framework

Cons of Vuetify

  • Larger bundle size due to its comprehensive feature set
  • Customization can be more complex for highly specific designs
  • Steeper learning curve for beginners due to its extensive API

Code Comparison

Material Web:

<md-filled-button>Click me</md-filled-button>

Vuetify:

<v-btn color="primary">Click me</v-btn>

Key Differences

  • Material Web focuses on web components, making it framework-agnostic
  • Vuetify is specifically designed for Vue.js applications
  • Material Web aims for lighter weight and closer adherence to Material Design guidelines
  • Vuetify offers more customization options out of the box

Use Cases

  • Choose Material Web for lightweight, standards-compliant Material Design implementations
  • Opt for Vuetify when building feature-rich Vue.js applications with extensive UI requirements

Community and Support

  • Material Web: Backed by Google, with growing community support
  • Vuetify: Large, active community with extensive third-party resources and plugins

Performance Considerations

  • Material Web generally offers better performance due to its lighter weight
  • Vuetify may have slightly longer initial load times but provides more features
20,694

A React-based UI toolkit for the web

Pros of Blueprint

  • Extensive component library with a focus on data-heavy applications
  • Strong TypeScript support and comprehensive documentation
  • Customizable theming system with SASS variables

Cons of Blueprint

  • Larger bundle size due to its comprehensive nature
  • Steeper learning curve for developers new to the framework
  • Less suitable for mobile-first or lightweight applications

Code Comparison

Material Web:

<md-filled-button>Click me</md-filled-button>

Blueprint:

<Button intent="primary">Click me</Button>

Key Differences

  • Material Web focuses on implementing Material Design guidelines, while Blueprint offers a more customizable design system
  • Material Web uses Web Components, making it framework-agnostic, whereas Blueprint is React-based
  • Blueprint provides more complex components for data visualization and enterprise applications
  • Material Web has a smaller footprint and is better suited for mobile-first designs

Use Cases

Material Web is ideal for:

  • Projects adhering to Material Design principles
  • Lightweight, mobile-friendly applications
  • Developers working with various frameworks or vanilla JavaScript

Blueprint is better for:

  • Data-heavy enterprise applications
  • React-based projects requiring complex UI components
  • Applications with extensive data visualization needs

Materialize, a CSS Framework based on Material Design

Pros of Materialize

  • Easier to set up and use, with a more traditional CSS and JavaScript approach
  • Broader browser support, including older versions
  • More extensive documentation and community resources

Cons of Materialize

  • Less frequently updated, with slower adoption of new Material Design guidelines
  • Heavier file size, potentially impacting page load times
  • Not as customizable or modular as Material Web

Code Comparison

Materialize (CSS-based):

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<a class="waves-effect waves-light btn">Button</a>

Material Web (Web Components):

<script type="module" src="@material/web/button/filled-button.js"></script>
<md-filled-button>Button</md-filled-button>

Material Web uses modern web components, resulting in cleaner HTML and more encapsulated functionality. Materialize relies on traditional CSS classes and JavaScript initialization, which may be more familiar to some developers but less modular.

Both libraries aim to implement Material Design, but Material Web offers a more up-to-date and customizable approach, while Materialize provides a simpler integration path for projects that don't require the latest features or have broader browser support requirements.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Material Web

A collection of Material web components

Published on npm Join our Discord Test status npm Downloads jsDelivr hits (npm)

@material/web is a library of web components that helps build beautiful and accessible web applications. It uses Material 3, the latest version of Google's open-source design system.

Note: MWC is in maintenance mode pending new maintainers.

Resources

Quick start

Tip: Using Angular? We recommend using Angular Material components instead.

This code snippet is a buildless example that loads @material/web from a CDN. Check out the quick start guide to install and build for production.

<head>
  <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap" rel="stylesheet">
  <script type="importmap">
    {
      "imports": {
        "@material/web/": "https://esm.run/@material/web/"
      }
    }
  </script>
  <script type="module">
    import '@material/web/all.js';
    import {styles as typescaleStyles} from '@material/web/typography/md-typescale-styles.js';

    document.adoptedStyleSheets.push(typescaleStyles.styleSheet);
  </script>
</head>
<body>
  <h1 class="md-typescale-display-medium">Hello Material!</h1>
  <form>
    <p class="md-typescale-body-medium">Check out these controls in a form!</p>
    <md-checkbox></md-checkbox>
    <div>
      <md-radio name="group"></md-radio>
      <md-radio name="group"></md-radio>
      <md-radio name="group"></md-radio>
    </div>

    <md-outlined-text-field label="Favorite color" value="Purple"></md-outlined-text-field>

    <md-outlined-button type="reset">Reset</md-outlined-button>
  </form>
  <style>
    form {
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      gap: 16px;
    }
  </style>
</body>

NPM DownloadsLast 30 Days