Skip to main content

Custom components

A custom component is the exception, since a themed Mantine component meets most needs. This page shows how to decide whether you need one, which tier it belongs to and how to build it.

Claude Code skill​

The repository ships a Claude Code skill in .claude/skills/mantine-custom-components/. Ask Claude Code for a component in your own words, such as «lag en ny komponent for …» or «TextInput skal kunne vise en enhet», and it loads the skill automatically. You can also invoke it directly with /mantine-custom-components.

The skill breaks the request down and picks the tier before it writes any code. It follows the file layout, naming and token rules on this page. It asks whether a component is needed at all, and stops to ask when a design value is missing.

In a project built on the design system, copy the folder into that project's .claude/skills/ to apply the same pattern there.

Assessment​

List what the component consists of: the parts that are Mantine components as they already look, the parts that are new, and the behaviour it adds. Check Mantine's documentation for each new part first. An existing upstream prop is always preferred over a rebuild.

If the stock components already look right and can be composed where they are used, a documented example on the Mantine component's page may be enough.

Tiers​

Answer the questions in order. The first one that fits decides the tier.

TierQuestionWhat you build
1Is it only a new look for a stock Mantine component?No component. A theme override, built with the style-override skill.
3Does it have named parts that consumers must style through classNames, or sub-components that share a context?A full Mantine factory component with the Styles API.
2Everything else.A plain function component that wraps one or more Mantine components, or none.

Tier 2 covers most components. State, effects and conditional rendering do not move a component to tier 3. Neither does combining two Mantine components, or adding a part that is styled internally and not exposed to consumers.

We recommend the lower tier when in doubt. Moving up to tier 3 later adds API. Moving down removes API, which is a breaking change — see Versioning.

Reference implementations​

Read the one that matches your tier before you write a new component.

TierComponentShows
2TextInputA wrapper with one internal part of its own
2FieldLabelNo Mantine component underneath
3ChipOwn root element, Styles API, variants
3SplitButtonComposes other Mantine components without a root of its own

Implementation rules​

These apply to tier 2 and tier 3.

  • Theme defaults. The component reads its props from the theme under its own key, so an application can set defaults once in its provider. A component that keeps a Mantine name prefixes the key with Ds, to keep it separate from Mantine's entry.
  • Own stylesheet. Styling lives in the component's own CSS module, including any restyling of the Mantine parts it wraps. Theme overrides define how a stock component looks everywhere.
  • Tokens only. Every colour, size, radius and spacing value comes from a design token. If no token fits, ask before you hardcode a value.
  • Overridable texts. Every visible string and aria-label is a prop with a Norwegian default, so a project in another language can replace it.
  • Accessibility. See Accessibility.

Documentation​

Every new component needs a page under Components. The docs-component-page skill writes it. Use that page to check the component in both colour schemes.