Productivity

mantine-custom-components

mantinedev/skills · updated Apr 8, 2026

$npx skills add https://github.com/mantinedev/skills --skill mantine-custom-components
summary

Use polymorphicFactory sparingly — it adds TypeScript overhead and slows IDE autocomplete.

skill.md

Mantine Custom Components Skill

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 = { radius: 'md' } satisfies Partial<MyComponentProps>;

const varsResolver = createVarsResolver<MyComponentFactory>((_theme, { radius }) => ({
  root: { '--my-radius': 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 = '@mantine/core/MyComponent';
MyComponent.classes = classes;

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 sparingly — it adds TypeScript overhead and slows IDE autocomplete.

Factory type fields

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?: boolean;            // true = sub-component; disables theme classNames/styles/vars
  ctx?: MyContextType;           // passed to styles/vars resolvers as third arg
  signature?: (...) => JSX.Element; // only for genericFactory
}>

Theme integration

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) } }),
    }),
  },
});

References

  • references/api.md — All imports: factory, useProps, useStyles, createVarsResolver, createSafeContext, StylesApiProps, CompoundStylesApiProps, BoxProps, ElementProps, theme helpers (getSize, getRadius, etc.)
  • references/patterns.md — Full examples: compound components with context, polymorphic component, generic component, theme integration
general reviews

Ratings

4.656 reviews
  • Neel Brown· Dec 24, 2024

    mantine-custom-components is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.

  • Michael Park· Dec 20, 2024

    mantine-custom-components reduced setup friction for our internal harness; good balance of opinion and flexibility.

  • Liam Kim· Dec 20, 2024

    Keeps context tight: mantine-custom-components is the kind of skill you can hand to a new teammate without a long onboarding doc.

  • Anika Kapoor· Dec 16, 2024

    Solid pick for teams standardizing on skills: mantine-custom-components is focused, and the summary matches what you get after install.

  • Shikha Mishra· Dec 8, 2024

    mantine-custom-components is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.

  • Chen Anderson· Dec 8, 2024

    I recommend mantine-custom-components for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.

  • Michael Dixit· Nov 27, 2024

    mantine-custom-components fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.

  • Kofi Ramirez· Nov 23, 2024

    Useful defaults in mantine-custom-components — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.

  • Liam Diallo· Nov 11, 2024

    Registry listing for mantine-custom-components matched our evaluation — installs cleanly and behaves as described in the markdown.

  • Ishan Diallo· Nov 11, 2024

    We added mantine-custom-components from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.

showing 1-10 of 56

1 / 6