/mantine:mantine-custom-componentsfrom mantine
Build custom Mantine components that integrate with theming, Styles API, factory functions, and MantineProvider. Covers factory(), createVarsResolver, useStyles, compound components, and Component.extend().
Ships in mantine. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Written for Mantine 10.x. Upgrading code written for 9.x: see Coming from 9.x.
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:
getStyles('selector') gets the static class mantine-MyComponent-selector.classNames, styles, vars and attributes props, and the same keys in MyComponent.extend() in the theme.unstyled removes the CSS module classes. Static classes and the CSS variables on the root stay.MyComponent.extend() and MyComponent.withProps() static functions. withProps presets props at
runtime but does not change types: a required prop stays required for TypeScript, so make props you
intend to preset optional.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, which is true by default
(9.x: false), so filled text is black on light colors. 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.
| 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 sparingly — it adds TypeScript overhead and slows IDE autocomplete.
Every factory component also accepts renderRoot={(props) => <a {...props} />} as an alternative to component.
Factory<{
props: MyComponentProps; // required
ref: HTMLDivElement; // element type for the forwarded ref
stylesNames: 'root' | 'inner'; // union of Styles API selectors
vars: { root: '--my-var' }; // CSS variable map per selector
variant: 'filled' | 'outline'; // accepted variant strings
staticComponents: { // sub-components (compound pattern)
Item: typeof MyComponentItem;
};
compound: true; // only for sub-components; disables theme classNames/styles/vars
ctx: { stepsCount: number }; // only if needed; passed to classNames/styles/vars functions as third arg
signature?: (...) => JSX.Element; // only for genericFactory
}>
Users and the theme can override defaults via Component.extend():
const theme = createTheme({
components: {
MyComponent: MyComponent.extend({
defaultProps: { radius: 'xl' },
classNames: { root: 'my-root' },
styles: { root: { color: 'red' } },
vars: (_theme, props) => ({ root: { '--my-radius': getRadius(props.radius) } }),
}),
},
});
In theme.components, sub-components are registered without the dot: MyCardSection: MyCard.Section.extend({ defaultProps }).
--mantine-color-* variables and theme.colors shades are oklch() strings, not hex. Use them
as CSS values only; alpha, darken and lighten from @mantine/core accept them.theme.autoContrast defaults to true: theme.variantColorResolver returns black text for light
filled colors unless the component passes autoContrast: false.--mantine-color-surface-panel,
--mantine-color-border, --mantine-color-hover, --mantine-color-neutral-N) instead of
light-dark() pairs of gray-N / dark-N. The dark scheme is darker, so retest dark-N choices.opacity: var(--mantine-disabled-opacity). --mantine-color-disabled,
--mantine-color-disabled-color and --mantine-color-disabled-border are removed.--mantine-color-focus-ring; override it, not the primary filled color.Read the part that matches the task before writing code:
references/patterns.md — complete examples. Read "Compound component with context" for components with sub-components (Card.Section), "Wrapping a Mantine component" when the component renders an existing Mantine input or component inside and must forward classNames / styles to it, "Components that share theme configuration" for a family of components with a common base, "Converting an existing component" when migrating a forwardRef component with inline styles, "Polymorphic component" for a component prop, "Generic component" for props that depend on a type parameter, "Theme integration" for extend and withPropsreferences/api.md — read it for any component beyond the template above: it is the only place that documents getStyles options (focusable), the mod prop, theme helper outputs, MantineThemeProvider and what theme functions receive. Every function and type: factory variants, useProps, useStyles and getStyles options, createVarsResolver, createSafeContext, StylesApiProps, CompoundStylesApiProps, BoxProps (including mod), ElementProps, theme helpers (getSize, getRadius, getThemeColor...)If the references do not cover what you need, do not guess:
@mantine/mcp-server) is connected, use search_docs, get_item_doc and get_apihttps://mantine.dev/llms.txt and open the Styles API, variants and sizes, and custom components pagesWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub mantinedev/skills --plugin mantine9 skills in this plugin
/mantine-calendarBuild custom calendars and date pickers with @mantine/dates: per-day content and states, your own selection rules, custom periods and display-only calendars. Use this skill when: (1) a calendar shows data per day (prices, free slots, event dots, activity heatmap), (2) days are unavailable with a reason, or a range must not cross booked days, (3) the selection is not a plain date, dates or range (stays, fixed-length periods, fiscal quarters, week or custom-period pickers), (4) a calendar sits next to time slots, presets or a toolbar, or (5) any task involving Calendar, useCalendar, getDayProps, renderDay, excludeDate, getMonthControlProps, Month, Day, CalendarHeader or PickerControl.
/mantine-comboboxBuild custom dropdown/select/autocomplete/multiselect components using Mantine's Combobox primitives. Use this skill when: (1) creating a new custom select-like component with Combobox primitives, (2) building a searchable dropdown, (3) implementing a multi-select or tags input variant, (4) customizing option rendering, (5) adding custom filtering logic, or (6) any task involving useCombobox, Combobox.Target, Combobox.Option, or Combobox.Dropdown.
/mantine-data-gridBuild data tables with `@mantine/data-grid` (DataGrid on TanStack Table v9). Use this skill when: (1) building an admin list, orders table or any table with sorting, filtering or pagination, (2) connecting a grid to an API with server-side sorting, filtering and pagination, (3) adding row selection with bulk actions, row actions or inline cell/row editing, (4) rendering grouped rows, tree data, pinned or resizable columns, or 10k+ rows with virtualization, (5) adding a toolbar, filter controls, export or a custom footer to a grid, or (6) any task involving `DataGrid`, `useDataGrid`, `DataGridColumnDef` or `@tanstack/react-table` inside a Mantine app.
/mantine-formBuild forms using @mantine/form. Use this skill when: (1) setting up a form with useForm, (2) adding validation rules, schema validation (zod, valibot, arktype) or async validation, (3) working with nested object or array fields, (4) reading values, dirty or touched state during render (useWatchValue, useDirty, useTouched), (5) splitting a form into components or reusing field components across forms (createFormContext, getField), (6) building custom inputs that work with getInputProps (useFormField), (7) using the standalone useField hook, or (8) any task involving useForm, getInputProps, onSubmit, insertListItem, or form validation.
/mantine-scheduleBuild calendar and scheduling interfaces with @mantine/schedule. Use this skill when: (1) adding a day, week, month, year or agenda calendar (Schedule, DayView, WeekView, MonthView, YearView, AgendaView, MobileMonthView), (2) building a booking page, team rota, room planner or any view with people, rooms or machines as rows (ResourcesSchedule, ResourcesDayView, ResourcesWeekView, ResourcesMonthView), (3) creating events by clicking or drag-selecting slots, (4) moving or resizing events with drag and drop and rejecting invalid placements, (5) recurring events (rrule, exceptions, single-occurrence edits), (6) business hours, blocked time or other background events, (7) custom event rendering, or (8) any task involving ScheduleEventData, onEventDrop, onSlotDragEnd or onTimeSlotClick.
/mantine-testingWrite and run component tests for interfaces built with Mantine (React Testing Library, user-event, jsdom with vitest or jest). Use this skill whenever a task asks for tests of a Mantine component or form, or when existing tests of Mantine UI fail in jsdom: (1) render setup and jsdom stubs, (2) how to interact with Mantine inputs in tests (selects, number inputs, date pickers, phone input, checkboxes, segmented controls), (3) modals, drawers, notifications and other portals, (4) drag and drop with dnd-kit, (5) forms built with @mantine/form, (6) fake timers and async validation, or (7) test structure and naming.
Other plugins' skills for the same job