Skills2026年4月11日·1 分钟阅读

Mantine — Fully Featured React Components Library

Mantine is a modern React components library with 120+ customizable components and 70+ hooks. Dark mode, TypeScript-first, built-in form management, notifications, modals, and rich text editor. The batteries-included alternative to MUI.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
step-1.md
直接安装命令
npx -y tokrepo@latest install ee95461f-3577-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run 确认安装计划,再运行此命令。

TL;DR
Mantine is a React components library with 120+ components, 70+ hooks, and zero-config dark mode.
§01

What it is

Mantine is a fully featured React components library with 120+ customizable components and 70+ hooks. It is TypeScript-first, includes built-in form management, notifications, modals, and a rich text editor. Dark mode works with zero configuration.

Mantine targets React developers who want a batteries-included UI library without the complexity and bundle size of Material UI. MIT licensed with an active maintainer.

§02

How it saves time or tokens

Mantine provides everything a typical web application needs: inputs, buttons, tables, modals, notifications, date pickers, charts, a command palette (Spotlight), and a rich text editor (Tiptap-based). Instead of assembling separate libraries for each feature, you install Mantine and get a consistent design system. The 70+ hooks cover common UI patterns (useDebouncedValue, useLocalStorage, useClipboard, useMediaQuery) that would otherwise require custom code.

§03

How to use

  1. Create a new project with Mantine:
npm create vite@latest my-app -- --template react-ts
cd my-app
npm i @mantine/core @mantine/hooks
  1. Set up the provider and use components:
import '@mantine/core/styles.css';
import { MantineProvider, Button, TextInput, Stack } from '@mantine/core';

function App() {
  return (
    <MantineProvider defaultColorScheme='auto'>
      <Stack p='xl'>
        <TextInput label='Name' placeholder='John' />
        <Button>Submit</Button>
      </Stack>
    </MantineProvider>
  );
}
  1. Add form management:
import { useForm } from '@mantine/form';

const form = useForm({
  initialValues: { email: '', name: '' },
  validate: {
    email: (value) => (/^\S+@\S+$/.test(value) ? null : 'Invalid email'),
  },
});
§04

Example

Building a command palette with Mantine Spotlight:

import { Spotlight, SpotlightActionData } from '@mantine/spotlight';

const actions: SpotlightActionData[] = [
  { id: 'home', label: 'Home', description: 'Go to home page' },
  { id: 'dashboard', label: 'Dashboard', description: 'View analytics' },
  { id: 'settings', label: 'Settings', description: 'Manage preferences' },
];

function App() {
  return (
    <Spotlight
      actions={actions}
      searchProps={{ placeholder: 'Search...' }}
      shortcut='mod + K'
    />
  );
}
// Press Cmd+K to open the command palette
§05

Related on TokRepo

  • Coding tools — More React frameworks and developer tools on TokRepo.
  • Design tools — Browse UI design and component libraries.
§06

Common pitfalls

  • Forgetting to import '@mantine/core/styles.css' causes unstyled components. This CSS import is required at the application root.
  • Using Mantine components outside MantineProvider breaks theming and dark mode. Wrap your entire app with MantineProvider.
  • Installing all Mantine packages at once bloats the bundle. Install only the packages you need (@mantine/core, @mantine/hooks, @mantine/form, etc.).

常见问题

How does Mantine compare to Material UI?+

Mantine is lighter, includes more built-in features (Spotlight, rich text editor, charts), and has a simpler API. Material UI has a larger ecosystem and more third-party integrations. Mantine uses CSS modules while MUI uses Emotion CSS-in-JS.

Does Mantine support server-side rendering?+

Yes. Mantine supports SSR with Next.js, Remix, and other React server frameworks. Version 7+ uses CSS files instead of CSS-in-JS for better SSR performance.

How does dark mode work?+

Set defaultColorScheme to 'auto' in MantineProvider and dark mode follows the system preference. You can also toggle programmatically with useMantineColorScheme hook.

What hooks does Mantine provide?+

Mantine includes 70+ hooks: useDebouncedValue, useLocalStorage, useClipboard, useMediaQuery, useClickOutside, useDisclosure, useIntersection, useScrollIntoView, and many more.

Is Mantine free for commercial use?+

Yes. Mantine is MIT licensed and free for personal and commercial use with no restrictions.

引用来源 (3)

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产