Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[@mantine/core] make MantineThemeColorsOverride an interface instead of type #4816

Merged
merged 2 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions docs/pages/theming/colors.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,19 @@ function Demo() {
## Default colors

<ThemeColors />

## Add custom colors types

TypeScript will only autocomplete Mantine's default colors when accessing the theme. To add your custom colors to the MantineColor type, you can use TypeScript module declaration.

```ts
import { DefaultMantineColor, MantineColorsTuple } from '@mantine/core';

type ExtendedCustomColors = 'primaryColorName' | 'secondaryColorName' | DefaultMantineColor;

declare module '@mantine/core' {
export interface MantineThemeColorsOverride {
colors: Record<ExtendedCustomColors, MantineColorsTuple>;
}
}
```
2 changes: 1 addition & 1 deletion src/mantine-core/src/core/MantineProvider/theme.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export type DefaultMantineColor =
| 'teal'
| (string & {});

export type MantineThemeColorsOverride = {};
export interface MantineThemeColorsOverride {}

export type MantineThemeColors = MantineThemeColorsOverride extends {
colors: Record<infer CustomColors, MantineColorsTuple>;
Expand Down