mantine-custom-components

>

INSTALLATION
npx skills add https://github.com/mantinedev/skills --skill mantine-custom-components
Run in your project or agent environment. Adjust flags if your CLI version differs.

SKILL.md

$28

export interface MyComponentProps

extends BoxProps, StylesApiProps, ElementProps<'div'> {

radius?: MantineRadius;

}

export type MyComponentFactory = Factory<{

props: MyComponentProps;

ref: HTMLDivElement;

stylesNames: MyComponentStylesNames;

vars: MyComponentCssVariables;

variant: MyComponentVariant;

}>;

const defaultProps = { radius: 'md' } satisfies Partial;

const varsResolver = createVarsResolver((_theme, { radius }) => ({

root: { '--my-radius': getRadius(radius) },

}));

export const MyComponent = factory((_props) => {

const props = useProps('MyComponent', defaultProps, _props);

const { classNames, className, style, styles, unstyled, vars, attributes, radius, ...others } = props;

const getStyles = useStyles({

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

}),

},

});

BrowserAct

Let your agent run on any real-world website

Bypass CAPTCHA & anti-bot for free. Start local, scale to cloud.

Explore BrowserAct Skills →

Stop writing automation&scrapers

Install the CLI. Run your first Skill in 30 seconds. Scale when you're ready.

Start free
free · no credit card