@bug-on/md3-react
v4.0.5
Published
Material Design 3 Expressive React components
Maintainers
Readme
@bug-on/md3-react
⚠️ Work in progress — Material Design 3 Expressive React Component Library.
Thư viện UI component hiệu năng cao cho React được thiết kế theo ngôn ngữ thiết kế Material Design 3 Expressive. Mang đến hiệu ứng mượt mà, khả năng hỗ trợ tiếp cận (a11y) mạnh mẽ và tương thích hoàn hảo với SSR / Next.js App Router.
📖 Tài liệu hướng dẫn & Demo
Để xem hướng dẫn chi tiết về API của từng Component, các thuộc tính chỉnh sửa cũng như xem demo tương tác trực quan nhất, vui lòng truy cập: 👉 Tài liệu & Demo chính thức (GitHub Repository)
📦 Cài đặt
Cài đặt gói React component cùng với các package cốt lõi đi kèm trong hệ sinh thái:
npm install @bug-on/md3-react @bug-on/md3-tailwind @bug-on/md3-tokens
# hoặc
pnpm add @bug-on/md3-react @bug-on/md3-tailwind @bug-on/md3-tokensPeer Dependencies thiết yếu
Đảm bảo bạn đã cài đặt đầy đủ các peer dependencies sau trong dự án:
npm install react react-dom
# Yêu cầu cài đặt thêm thư viện motion cho các component có hiệu ứng động (Fab, Tabs, Dialog...):
npm install motion🛠️ Configuration & Setup (Tailwind CSS v4)
[!WARNING] The library only supports Tailwind CSS v4 (peer dependency
tailwindcss: ">=4.0.0"). Tailwind CSS v3 is no longer supported.
This system is designed around the CSS-first architecture of Tailwind CSS v4. Setup is extremely simple and requires no JS/TS configuration files. Just import the stylesheets directly into your application's main CSS entry point (e.g., globals.css or index.css):
/* 1. Import core Tailwind CSS v4 */
@import "tailwindcss";
/* 2. Register core Design Tokens + Tailwind Theme + Resets (Zero Config) */
@import "@bug-on/md3-react/index.css";
/* 3. (Optional) Integrate MD3 advanced utility classes (elevations, transitions, icons) */
@import "@bug-on/md3-tailwind";
/* 4. (Optional) Integrate specialized Typography CSS for React Components */
@import "@bug-on/md3-react/typography.css";Zero Config: Once
@bug-on/md3-react/index.cssis imported, basic MD3 utility classes (bg-m3-primary,text-m3-on-surface,rounded-m3-xl, etc.) work immediately. For the full set of utilities like depth shadows (elevation-3), icon axis control (icon-fill-1), or physics-based transitions (transition-m3-fast-spatial), import@bug-on/md3-tailwindas well. Do NOT use JS plugins in Tailwind v4.
Cấu hình Icons (Material Symbols)
Thư viện tích hợp sẵn component <Icon /> sử dụng font Material Symbols Outlined. Bạn cần import stylesheet của icon tại root của ứng dụng (ví dụ layout.tsx hoặc main.tsx):
// app/layout.tsx hoặc src/main.tsx
import '@bug-on/md3-react/material-symbols-cdn.css';
import { MaterialSymbolsPreconnect } from '@bug-on/md3-react';
export default function RootLayout({ children }) {
return (
<html>
<head>
{/* Hỗ trợ tải trước font giúp hiển thị icon cực nhanh */}
<MaterialSymbolsPreconnect />
</head>
<body>{children}</body>
</html>
);
}(Nếu cần hỗ trợ offline không qua CDN, bạn có thể import bản self-hosted: @bug-on/md3-react/material-symbols-self-hosted.css)
🚀 Sử dụng cơ bản
import { Button, Icon } from '@bug-on/md3-react';
export default function Page() {
return (
<div className="p-8 bg-m3-surface min-h-screen flex items-center justify-center">
<Button colorStyle="filled" size="md" icon={<Icon name="add" />}>
Get Started
</Button>
</div>
);
}⚖️ Giấy phép
MIT
