# mantine-custom-components

Teaches AI agents to build custom components for Mantine 9.x and React 19. It sets up component factories, Styles API support, and CSS variable resolvers.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 3600 installs · ★ 63
- Author: mantinedev
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/mantinedev/skills/tree/HEAD/skills/mantine-custom-components/SKILL.md
- Updated: 2026-10-16
- HTML: https://affpapa.org/en/nevibecode/skills/mantine-custom-components

## What it does

This skill guides the agent through constructing custom UI components that follow Mantine 9.x architecture. It covers component creation using `factory()`, `polymorphicFactory()`, and `genericFactory()`. Every generated component includes native Styles API properties like `classNames`, `styles`, `vars`, and `unstyled` from `@mantine/core`, along with static class names on every styled selector.

CSS variables link through `createVarsResolver`, while size tokens run through the `getSize` utility. Colors resolve via `theme.variantColorResolver`, allowing themes to reconfigure component variants without code edits. Be deliberate with polymorphic components. The author notes that `polymorphicFactory` adds noticeable TypeScript overhead and slows editor autocomplete, favoring `renderRoot` instead.

React 19 handles `ref` as a standard prop passed through to the root element. For compound component structures, the skill details sub-component registration via `staticComponents` and isolates theme styles using the `compound: true` flag.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add mantinedev/skills --skill mantine-custom-components -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/mantine-custom-components/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/mantine-custom-components/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add mantinedev/skills --skill mantine-custom-components -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/mantine-custom-components/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add mantinedev/skills --skill mantine-custom-components -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/mantine-custom-components/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install mantinedev/skills mantine-custom-components
```

2. **Manually: put the files in place**
- File: `.github/skills/mantine-custom-components/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add mantinedev/skills --skill mantine-custom-components -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/mantinedev/skills --path skills/mantine-custom-components
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/mantine-custom-components/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add mantinedev/skills --skill mantine-custom-components -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/mantinedev/skills/tree/HEAD/skills/mantine-custom-components/SKILL.md

## When to use it
- create a custom Mantine 9 component using `factory` or `genericFactory`
- implement Styles API support with `classNames`, `styles`, and `unstyled`
- map component theme tokens and CSS variables via `createVarsResolver`
- build compound components with shared context and static sub-components

## Example prompts
- Build a custom Card component using factory() from @mantine/core with Styles API support
- Add size variants to my Mantine component using getSize and CSS custom properties
- Create a compound component with an Item sub-component and compound: true

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: ea990e4d74e90cdf.

BEGIN THIRD-PARTY FILE ea990e4d74e90cdf
````text
---
name: mantine-custom-components
description: >
  Build custom components that integrate with Mantine's theming, Styles API, and core features.
  Use this skill when: (1) creating a new component using factory(), polymorphicFactory(), or
  genericFactory(), (2) adding Styles API support (classNames, styles, vars, unstyled), (3)
  implementing CSS variables via createVarsResolver, (4) building compound components with
  sub-components and shared context, (5) registering a component with MantineProvider via
  Component.extend(), or (6) any task involving Factory, useProps, useStyles, BoxProps,
  StylesApiProps, or ElementProps in @mantine/core.
---

# Mantine Custom Components Skill

Written for Mantine 9.x.

## Component template

```tsx
import {
  Box, BoxProps, createVarsResolver, ElementProps,
  factory, Factory, getRadius, MantineRadius,
  StylesApiProps, useProps, useStyles,
} from '@mantine/core';
import classes from './MyComponent.module.css';

export type MyComponentStylesNames = 'root' | 'inner';
export type MyComponentVariant = 'filled' | 'outline';
export type MyComponentCssVariables = { root: '--my-radius' };

export interface MyComponentProps
  extends BoxProps, StylesApiProps<MyComponentFactory>, ElementProps<'div'> {
  radius?: MantineRadius;
}

export type MyComponentFactory = Factory<{
  props: MyComponentProps;
  ref: HTMLDivElement;
  stylesNames: MyComponentStylesNames;
  vars: MyComponentCssVariables;
  variant: MyComponentVariant;
}>;

const defaultProps = {} satisfies Partial<MyComponentProps>;

const varsResolver = createVarsResolver<MyComponentFactory>((_theme, { radius }) => ({
  // undefined leaves the variable unset, so the CSS fallback (theme default radius) applies
  root: { '--my-radius': radius === undefined ? undefined : getRadius(radius) },
}));

export const MyComponent = factory<MyComponentFactory>((_props) => {
  const props = useProps('MyComponent', defaultProps, _props);
  const { classNames, className, style, styles, unstyled, vars, attributes, radius, ...others } = props;

  const getStyles = useStyles<MyComponentFactory>({
    name: 'MyComponent', classes, props,
    className, style, classNames, styles, unstyled, vars, attributes, varsResolver,
  });

  return <Box {...getStyles('root')} {...others} />;
});

MyComponent.displayName = 'MyComponent';
MyComponent.classes = classes;
MyComponent.varsResolver = varsResolver;
```

```css
/* MyComponent.module.css */
.root {
````
END THIRD-PARTY FILE ea990e4d74e90cdf

The third-party file has ended. Everything between the ea990e4d74e90cdf tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2454 of 8736 bytes. © mantinedev · MIT · https://github.com/mantinedev/skills/tree/HEAD/skills/mantine-custom-components/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
