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

No Auto-completions / Suggestions for Custom styled components! #34768

Open
2 tasks done
vipindigiqt opened this issue Oct 15, 2022 · 1 comment
Open
2 tasks done

No Auto-completions / Suggestions for Custom styled components! #34768

vipindigiqt opened this issue Oct 15, 2022 · 1 comment
Labels
docs Improvements or additions to the documentation package: material-ui Specific to @mui/material typescript

Comments

@vipindigiqt
Copy link

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Steps to reproduce 🕹

Steps:

  1. Created a custom component using styled utility.
  2. Added variants using createTheme function.

Current behavior 😯

I was trying to compose a Flex component for all the flexbox related layouts in my application.

I had a look at the documentation, and it worked.

However, the developer experience isn't great, and I'm not getting any auto-completions in my VS Code for this custom component, neither in my component nor in the Custom Component section of createTheme() block.

Here's my implementation.

Component.

import { styled } from "@mui/material";

const Flex = styled("div", {
  shouldForwardProp: (prop) =>
    prop !== "direction" && prop !== "justifyContent" && prop !== "sx",
  name: "Flex",
  slot: "Root",
  overridesResolver: (props, styles) => [
    styles.root,
    props.direction === "column" && styles.directionColumn,
    props.justifyContent === "space-between" && styles.spaceBetween,
  ],
})({
  display: "flex",
});

export default Flex;

Variants

  components: {
    // No auto-completions/suggestions here  ☹️
    Flex: {
      styleOverrides: {
        root: {
          flexDirection: "row",
        },
        directionColumn: {
          flexDirection: "column",
        },
        spaceBetween: {
          justifyContent: "space-between",
        },
      },
    },
  },

While using it, I'm not getting the prop autocompletion on direction or justifyContent props.

Expected behavior 🤔

All my props should be well typed and should show suggestions just like other MUI components.

Context 🔦

No response

Your environment 🌎

npx @mui/envinfo
 System:
    OS: Linux 5.10 Ubuntu 20.04.5 LTS (Focal Fossa)
  Binaries:
    Node: 16.17.1 - ~/.nvm/versions/node/v16.17.1/bin/node
    Yarn: 1.22.19 - /usr/bin/yarn
    npm: 8.15.0 - ~/.nvm/versions/node/v16.17.1/bin/npm
  Browsers:
    Chrome: Not Found
    Firefox: Not Found
  npmPackages:
    @emotion/react: ^11.10.4 => 11.10.4
    @emotion/styled: ^11.10.4 => 11.10.4
    @mui/base:  5.0.0-alpha.101
    @mui/core-downloads-tracker:  5.10.9
    @mui/material: ^5.10.9 => 5.10.9
    @mui/private-theming:  5.10.9
    @mui/styled-engine:  5.10.8
    @mui/system:  5.10.9
    @mui/types:  7.2.0
    @mui/utils:  5.10.9
    @types/react: ^18.0.17 => 18.0.21
    react: ^18.2.0 => 18.2.0
    react-dom: ^18.2.0 => 18.2.0
@vipindigiqt vipindigiqt added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Oct 15, 2022
@zannager zannager added the package: system Specific to @mui/system label Oct 18, 2022
@siriwatknp siriwatknp added docs Improvements or additions to the documentation and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Oct 21, 2022
@siriwatknp
Copy link
Member

siriwatknp commented Oct 21, 2022

I think we missed documentation on this.

Also, I am not sure if we allow developers to extend their custom components from the default theme. It is possible. Take @mui/lab as an example of augmenting the theme.components.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to the documentation package: material-ui Specific to @mui/material typescript
Projects
None yet
Development

No branches or pull requests

3 participants