mui / mui/material-ui

[Typography] Add `fontWeightSemiBold` to Typography's FontStyle interface

Open Beginner friendly
#46,488 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

has workaround scope: typography type: new feature waiting for 👍
Dominant language
JavaScript
Stars
99.1k
Forks
32.5k
Avg merge
2d 17h
Merged PRs (30d)
106

Description

Summary

Summary

Currently, MUI's createTheme typography options don't include fontWeightSemiBold in the FontStyle interface, requiring manual type declaration overrides to use semibold font weights in themes.

Problem

When I try to use fontWeightSemibold in my custom theme, TypeScript throws an error because it's not defined in the FontStyle interface. This means I have to manually extend the interface with module declaration, which feels unnecessary for such a common font weight.

Current Workaround

I currently have to add this module declaration to make it work:

declare module '@mui/material/styles' {
  interface TypographyVariants {
    fontWeightSemibold: React.CSSProperties['fontWeight'];
  }

  interface TypographyVariantsOptions {
    fontWeightSemibold?: React.CSSProperties['fontWeight'];
  }
}

Proposed Solution

Add fontWeightSemiBold to the FontStyle interface in createTypography.d.ts.

Current interface:
export interface FontStyle {
  fontFamily: React.CSSProperties['fontFamily'];
  fontSize: number;
  fontWeightLight: React.CSSProperties['fontWeight'];
  fontWeightRegular: React.CSSProperties['fontWeight'];
  fontWeightMedium: React.CSSProperties['fontWeight'];
  fontWeightBold: React.CSSProperties['fontWeight'];
  htmlFontSize: number;
}
Proposed interface:
export interface FontStyle {
  fontFamily: React.CSSProperties['fontFamily'];
  fontSize: number;
  fontWeightLight: React.CSSProperties['fontWeight'];
  fontWeightRegular: React.CSSProperties['fontWeight'];
  fontWeightMedium: React.CSSProperties['fontWeight'];
  fontWeightSemibold: React.CSSProperties['fontWeight'];
  fontWeightBold: React.CSSProperties['fontWeight'];
  htmlFontSize: number;
}

Benefits

  • Would eliminate the need for manual module declaration overrides or using sx to override fontweight 600
  • Provides consistency with other font weight options
  • Would improve the developer experience with better TypeScript support

Environment

  • MUI version: 7.1.2
  • TypeScript version: 5.8.2
Examples

It's happen when I try to use theme.typography.fontWeightSemibold from theme object but here's what I see from accessing theme.typography.fontWeight...

Image
Motivation

No response

Search keywords: fontweightsemibold

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with packages/mui-material/src/styles/createTypography.d.ts at the FontStyle interface referenced in the issue. Confirm how the existing font-weight options are typed, add the requested semibold option consistently, and verify that theme.typography.fontWeightSemibold is accepted by TypeScript.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
developer-experience, frontend
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.