mantine-custom-components
БесплатноБез исполняемых скриптовНе проверенBuild custom components that integrate with Mantine's theming, Styles API, and core features. Use this skill when: (1) creating a new component using…
от mantinedev★ 68 звёзд на GitHubОб этом скилле
Mantine Custom Components Skill
Written for Mantine 9.x.
Component template
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;
/* MyComponent.module.css */
.root {
border-radius: var(--my-radius, var(--mantine-radius-default));
}
ref is a regular prop in React 19: it arrives in props and reaches the root element through ...others.
What you get without extra code:
- Every element rendered with
getStyles('selector')gets the static classmantine-MyComponent-selector. classNames,styles,varsandattributesprops, and the same keys inMyComponent.extend()in the theme.unstyledremoves the CSS module classes. Static classes and the CSS variables on the root stay.MyComponent.extend()andMyComponent.withProps()static functions.withPropspresets props at runtime but does not change types: a required prop stays required for TypeScript, so make props you intend to preset optional.
Variants and sizes
Pass variant and size to Box: it sets data-variant and data-size attributes to style in CSS.
Passing variant to getStyles additionally applies the root--{variant} class when the CSS module defines one:
const { variant, size, ...others } = props;
<Box variant={variant} size={size} {...getStyles('root', { variant })} {...others} />
.root {
&[data-variant='outline'] { border: 1px solid var(--my-color); }
&[data-size='lg'] { height: 50px; }
}
Sizes driven by one size prop: define the token values in CSS and select one with getSize. A
number or any CSS value passed as size is used as is (getSize(60, 'x') returns calc(3.75rem * var(--mantine-scale))).
root: { '--card-padding': getSize(size, 'card-padding'), '--card-fz': getFontSize(size) },
.root {
--card-padding-sm: 12px;
--card-padding-md: 16px;
--card-padding-lg: 24px;
padding: var(--card-padding, var(--card-padding-md));
}
For colors that follow the theme, resolve them in the vars resolver with
theme.variantColorResolver({ color: color || theme.primaryColor, theme, variant: variant || 'filled', autoContrast })
— it returns background, hover and color as colors and border as a full border shorthand value
(1px solid transparent). It knows the variants filled, light, outline, subtle, transparent, white and
default; autoContrast: undefined falls back to theme.autoContrast. For a single color use
getThemeColor(color, theme): it accepts 'blue', 'teal.7' and CSS colors.
.root {
background-color: var(--my-bg);
color: var(--my-color);
border: var(--my-bd); /* the whole shorthand, not border-color */
}
Because the resolver comes from the theme, an app can add its own variant (variant="danger") or
recolor an existing one without touching the component. Do not redeclare variant in your props
interface: StylesApiProps already types it as your variants plus any string.
Factory variant — which to use
| Scenario | Factory function | Type |
|---|---|---|
| Standard component | factory() |
Factory<{}> |
Supports component prop (polymorphic) |
polymorphicFactory() |
PolymorphicFactory<{}> — add defaultComponent and defaultRef |
Props change based on a generic (e.g. multiple) |
genericFactory() |
Factory<{ signature: ... }> |
Use polymorphicFactory sparin
Установить mantine-custom-components в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл mantine-custom-components?
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?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл mantine-custom-components запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic