mui / mui/material-ui

Add a "dummy" Mui-component processed in the custom them `overrides` prop to enable "targetting" without impacting layout

Open
#27,143 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

package: styled-engine scope: system support: question
Dominant language
JavaScript
Stars
99.1k
Forks
32.5k
Avg merge
2d 17h
Merged PRs (30d)
106

Description

The pain-point

I use the overrides prop a lot. In order to target a component there must be a Mui parent as the starting point for my selectors to latch-onto.

Sometimes, I have a component that uses "straight-up" React components encoded using plain-old html tags. As of now, I can't include this component in my custom theme. Of course I can "hack-it" using something like Container but that is not good design as it introduces a false intent.

The solution

In many programming languages there is the concept of the "identity function".

identity :: a -> a

The function outputs what was inputted. However, there is a related function with an important "extra": in a typed language the output might be "cast" to something that remains true to the identity value, but augments where the value can now operate (lifts the value).

pure :: a -> c a

... the idea:

muiTag :: html -> mui html

I propose a Mui component with no effect on the layout; i.e., does not distort/interact with the meaning of the child elements.

<MuiOverride className='My-Custom-Class'>
   <html-element />
</MuiOverride>

... where the MuiOverride -> html

<span class="MuiOverride My-Custom-Class">
   <html-element />
</span>

Note: while the name might seem heavy-handed, I chose it because it suggests using it with the overrides prop. While naming is important, the idea is not meant to hinge on it. e.g., <MuiId>, <MuiTag>, <MuiSpan> are others that come to mind.

Summary

Create a Mui component that generates a html element that does not change the layout (e.g., <span>. With support for this component, users can unify the configuration of their design under a single Mui banner.

Finally

Thank you for all of your efforts. The quality of this resource is top-tier.

  • I have searched the issues of this repository and believe that this is not a duplicate.

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

The issue proposes a new MuiOverride component that wraps plain HTML children without changing their layout and allows them to be targeted through the theme overrides prop. Start by locating the existing component and theme-override entry points, then define the component's rendered element and verify that its styling and layout behavior meet the proposal.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.