Skip to content

simplified prop types for dash toolchain#685

Merged
AnnMarieW merged 4 commits intosnehilvj:masterfrom
AnnMarieW:fix-style-props-types
Jan 22, 2026
Merged

simplified prop types for dash toolchain#685
AnnMarieW merged 4 commits intosnehilvj:masterfrom
AnnMarieW:fix-style-props-types

Conversation

@AnnMarieW
Copy link
Copy Markdown
Collaborator

@AnnMarieW AnnMarieW commented Jan 16, 2026

Partially addresses #559

See more details in an alternate PR #686 which was closed in favor of this one.

This PR simplifies the Mantine style props

See also the DMC Style Prop docs

The style props include Mantine types such as MantineSize and MantineColor. These are complex types that include literals and string & {} in the type definition. Dash dash does not parse those correctly when creating Python types.

Background:

DMC extensively uses prop types that look like this:

size?: MantineSize | number;

The MantineSize type includes sizes defined in the theme object and string & {}, which enables literal type hints while still allowing arbitrary strings.

Dash cannot handle the string & {} pattern, so it is ignored. As a result, Dash generates the following Python type, which does not allow arbitrary strings:

typing.Optional[typing.Union[NumberType, Literal["xs"], Literal["sm"], Literal["md"], Literal["lg"], Literal["xl"]]] = None,

If it's changed to this:

size?: MantineSize | string | number;

it drops the MantineSize definitions.

 typing.Optional[typing.Union[str, NumberType]] = None,

This fixes the typing issue in Dash, but we lose the type hints for the Mantine literals.

Mantine Style Props - responsive styles:

The Mantine Style props also accept a dict with breakpoints for responsive styles. The type is defined as Partial<Record<MantineBreakpoint This is dropped by dash.

I tried defining the breakpoint dict like this: Record<string, string> but dash just drops this as well. For simplicity the breakpoint dicts are typed as object in this PR.

@AnnMarieW AnnMarieW merged commit 10625ab into snehilvj:master Jan 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant