Giter Site home page Giter Site logo

anthonyleung-dev / react-material-web Goto Github PK

View Code? Open in Web Editor NEW
10.0 1.0 1.0 1.01 MB

This project aims to provide React components based on the Material Web design guidelines originally from https://github.com/material-components/material-web.

License: MIT License

TypeScript 99.03% CSS 0.55% MDX 0.11% JavaScript 0.31%

react-material-web's Introduction

React Material Web Components

This library provides a set of React components styled with Material Design, leveraging the capabilities of @material/web and @lit/react.

Installation

To install Material Web React, you can use npm or yarn. Run one of the following commands in your project directory:

npm install react-material-web

or

yarn add react-material-web

Usage

Here's a quick example to get you started. After installing, you can import and use Material Components like any other React component.

Add styles to your project:

import 'react-material-web/styles'

Then, you can use the components like this:

import React from 'react';
import { MdFilledButton } from 'react-material-web';

function Example() {
  return (
    <div>
      <MdFilledButton>Click me</MdFilledButton>
    </div>
  );
}

For more detailed documentation on each component and its API, please refer to Material Components Web.

Storybook

You can also check out our Storybook to see all the components in action. To run the Storybook, use the following command:

npm run storybook

or

Storybook

Available Components

Base

  • ✅ Button
  • ✅ FAB
  • ✅ Icon
  • ✅ Icon button
  • ✅ Checkbox
  • ✅ Chips
  • ✅ Dialog
  • ✅ Divider
  • ✅ Elevation
  • ✅ Focus ring
  • ✅ List
  • ✅ Menu
  • ✅ Progress indicators
  • ✅ Radio
  • ✅ Ripple
  • ✅ Select
  • ✅ Slider
  • ✅ Switch
  • ✅ Tabs
  • ✅ Text field

Labs 🚧

WARNING ⚠️ This folder contains experimental features that are not recommended for production.

  • ✅ Card
  • ✅ Segmented button
  • ✅ Navigation bar

Core Dependencies

Our library is built upon the solid foundation of Material Design and modern web technologies, including:

License

Distributed under the MIT License. See LICENSE for more information.

react-material-web's People

Contributors

anthonyleung-dev avatar zzhorizonzz avatar

Stargazers

Leandro Gaspari avatar  avatar André Ribeiro avatar Rúben Garrido avatar  avatar luiza dragonetti avatar Josef Ježek avatar Yuvaraj Thiagarajan avatar Iriseplosc avatar  avatar

Watchers

 avatar

Forkers

zzhorizonzz

react-material-web's Issues

import issue: Unable to resolve @import "~@fontsource/roboto" from xxx/node_modules/react-material-web/dist when using vite as bundler

Me and my colleague can reproduce this issue by following steps below:

  1. create a new react app using vite as bundler by running command npm init vite@latest --template and choose react and typescript as scaffold;
  2. run npm install react-material-web (at the moment its version is 1.0.5);
  3. using the library components in project;
  4. when run npm run dev to start server, the error raised: Unable to resolve @import "~@fontsource/roboto" from xxx/node_modules/react-material-web/dist

A temporary solution would be removing the ~ symbol in the import statement at the 2nd line in /node_modules/react-material-web/dist/styles.css which means to turn
@import '~@fontsource/roboto';
into
@import '@fontsource/roboto';

After doing this little tweak it works.
I don't know if this is an issue related to vite bundler, but I think it's beneficial to first summit an issue here as it may affect some projects using vite.

Optional CSS import

The default exported file in src/index.tsx imports the CSS file containing fonts (Roboto, Material Symbols) and additional styles. This import is currently mandatory, but it would be beneficial to make it optional.

import './styles.css'

Here's why:

  • Not all projects use Roboto font or Material Symbols.
  • Material Symbols are imported even if the Icon component isn't used.

Possible solutions:

  • Export individual components: Instead of just exporting the default (.) and styles, consider exporting each component individually. This allows developers to import specific components without pulling in the entire CSS file.
  • Remove default CSS import: This is a breaking change, but it removes the mandatory import of styles. Developers would then need to import the CSS file explicitly when needed.

Thanks for working on this!

Nextjs - "use client"

Is there a reason components are not annotated with 'use client' or was this not considered yet? If there's no issue, I'd like to submit a PR with these annotations, as I think Material Web doesn't currently support SSR for its components.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.