Skip to content

docusaurus-theme-classic > Heading's className prop does nothing #8327

@JoshuaKGoldberg

Description

@JoshuaKGoldberg

Have you read the Contributing Guidelines on issues?

Prerequisites

Description

The <Heading> component in docusaurus-theme-classic can be given a className prop:

<Heading as="h2" className="something">Hi!</Heading>

However, the component's manual className=clsx(...) prop ignores props.className:

<As
{...props}
className={clsx(
'anchor',
hideOnScroll
? styles.anchorWithHideOnScrollNavbar
: styles.anchorWithStickyNavbar,
)}

This means any className added in user-land is ignored.

Reproducible demo

https://github.com/typescript-eslint/typescript-eslint/pull/5951/files#diff-3b034ddb6525c7b93f97ced8a696c78c1837f072b9d1e70c46049675e0e09bf4R112-R116

Steps to reproduce

  1. Checkout that PR -> yarn -> yarn start
  2. Change
    ...
    to ...
  3. Observe that the site page does not center the heading text

Expected behavior

The className should be added to the clsx in Heading.

Actual behavior

The className is ignored.

Your environment

Self-service

  • I'd be willing to fix this bug myself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAn error in the Docusaurus core causing instability or issues with its executiongood first issueIf you are just getting started with Docusaurus, this issue should be a good place to begin.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions