npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@paulobrandao/react-material

v0.3.4

Published

React Material is a component library that is built based on the principles of the Material 3 design system.

Downloads

250

Readme

React Material

React Material is a component library that is built based on the principles of the Material 3 design system.

Coverage

This isn't the official release yet, just a beta release to validate the development while the documentation is writing.

Quick setup

First - Install

npm i @paulobrandao/react-material

Second - styling

Import the required stylesheet into RootLayout or your (main|index).ts:

import '@paulobrandao/react-material/dist/react-material.css';

To make use of MaterialSymbol component, it is necessary to import the icon font stylesheet too, according to the style chosen:

// Outlined
import '@paulobrandao/react-material/dist/react-material-symbols-outlined.css';
// Rounded
import '@paulobrandao/react-material/dist/react-material-symbols-rounded.css';
// Sharp
import '@paulobrandao/react-material/dist/react-material-symbols-sharp.css';

Third - Theming

For correct use of the components and to customize the interface, it is necessary to fill some CSS variables. You have some utils to do this task.

You just need to pass the main color of your interface, the color scheme (“light” or “dark”) and the font face names and the util will make the job.

More info about theme utils in the Utils section of this page.

For each necessity, a specific util is applied:

With Next.js

In this case, the right way is to set these vars on server side, with the RootLayout:

import { applyThemeOnHtmlStyleTag } from '@paulobrandao/react-material/utils';
...

return (
  <html
    style={applyThemeOnHtmlStyleTag({
      seedColor: '#4285F4', // main color as hex
      colorScheme: 'dark', // the recommendation is to use a cookie value
      font: { // if you prefer to make use of Next.js font variable, just set `false` here
        title: '"Roboto"', // or set the `--font-title` var
        content: '"Roboto"', // or set the `--font-content` var
        code: '"Roboto Mono"', // or set the `--font-code` var
      },
    })}
  >
    <body>{children}</body>
  </html>
);

With client

In this case, call the applyTheme util into (main|index).tsx:

import { applyTheme } from '@paulobrandao/react-material/utils';
// before createRoot
applyTheme({
  seedColor: '#4285F4',
  colorScheme: 'light',
  font: {
    title: '"Roboto"',
    content: '"Roboto"',
    code: '"Roboto Mono"',
  },
});

Setup done! Just start to make use.

Components

This list is organized according to Material Docs.

  • Style
    • [x] ~~MaterialSymbols~~
  • Actions
    • [x] ~~Button~~
    • [x] ~~IconButton~~
    • [ ] FloatActionButton (coming soon)
    • [ ] SegmentedButton (planning)
  • Communication
    • [ ] Snackbar (coming soon)
    • [ ] Tooltip (partially available with IconButton)
    • [ ] Badges (planning)
    • [ ] Progress (planning)
    • [ ] RichTooltip (planning)
  • Containment
    • [x] ~~Divider~~
    • [x] ~~Card~~
    • [x] ~~Dialog~~
    • [ ] List (coming soon)
    • [ ] SideSheet (coming soon)
    • [ ] BottomSheet (coming soon)
    • [ ] Carousel (planning)
  • Navigation
    • [x] ~~Appbar~~
    • [x] ~~Navbar~~
    • [x] ~~Navdrawer~~
    • [x] ~~Navrail~~
    • [ ] Tabs (coming soon)
  • Selection
    • [ ] Checkbox (coming soon)
    • [ ] Chip (coming soon)
    • [ ] Menu (coming soon)
    • [ ] RadioButton (coming soon)
    • [ ] Switch (coming soon)
    • [ ] DatePicker (planning)
    • [ ] Slider (planning)
    • [ ] TimePicker (planning)
  • Form
    • [ ] Search (coming soon)
    • [ ] SelectField (coming soon)
    • [ ] TextField (coming soon)
  • Layout
    • [x] ~~Box~~

Utils

Theme utils

These functions will help you to create dynamic color schemes by the content-based color of your product/application.

applyThemeOnHtmlStyleTag

Solution to server side render

This function returns the CSS variables required to customize the library components as CSSProperties and need to be applied in the style prop of the <html> tag.

import { applyThemeOnHtmlStyleTag } from '@paulobrandao/react-material/utils';
...

return (
  <html
    style={applyThemeOnHtmlStyleTag({
      seedColor: '#4285F4',
      colorScheme: 'dark',
      font: {
        title: '"Roboto"',
        content: '"Roboto"',
        code: '"Roboto Mono"',
      },
    })}
  >
    <body>{children}</body>
  </html>
);
applyThemeOnHtmlStyleTag types
type FontSettings = {
  title?: string;
  content?: string;
  code?: string;
};

type Settings = {
  seedColor: string; // content-based color of your product/application
  colorScheme: 'dark' | 'light;
  font: FontSettings | false;
}

function applyThemeOnHtmlStyleTag(settings: Settings): CSSProperties

applyTheme

Solution to client side render

This function applies the CSS variables required to customize the library components in the document element.

import { applyTheme } from '@paulobrandao/react-material/utils';
// before createRoot
applyTheme({
  seedColor: '#4285F4',
  colorScheme: 'light',
  font: {
    title: '"Roboto"',
    content: '"Roboto"',
    code: '"Roboto Mono"',
  },
});
applyTheme types
type FontSettings = {
  title?: string;
  content?: string;
  code?: string;
};

type Settings = {
  seedColor: string; // content-based color of your product/application
  colorScheme: 'dark' | 'light;
  font: FontSettings | false;
}

function applyTheme(settings: Settings): void