Coder Social home page Coder Social logo

mui-styled-engine-sc-ts-fixes's Introduction

Material UI - Create React App example with styled-components in TypeScript

The main difference between this and the non-TypeScript example is that you need to add the following path config to your tsconfig.json:

"paths": {
  "@mui/styled-engine": ["./node_modules/@mui/styled-engine-sc"]
}

and install @types/styled-components:

npm install --save-dev @types/styled-components

Alternatively, to skip this configuration, you can set skipLibCheck: true in your tsconfig.

How to use

Download the example or clone the repo:

curl https://codeload.github.com/mui/material-ui/tar.gz/master | tar -xz --strip=2 material-ui-master/examples/material-ui-cra-styled-components-ts
cd material-ui-cra-styled-components-ts

Install it and run:

npm install
npm start

CodeSandbox

Note that CodeSandbox is not supporting react-app-rewired, yet you can still see the code.

The following link leverages this demo: https://mui.com/guides/interoperability/#change-the-default-styled-engine with Parcel's alias feature within the package.json.

Edit on CodeSandbox

The idea behind the example

This example demonstrates how to set up Material UI with Create React App with styled-components as a style engine for your application using TypeScript.

Versions compatibility

Note, the version 5 of @mui/styled-engine-sc is compatible with version 5 of styled-components, while the version 6 of @mui/styled-engine-sc (currently in alpha), is compatible with v6 of styled-components. When incorporating these dependencies into your project, consider this compatibility requirement. In this example application, both libraries are using version 6.

What's next?

You now have a working example project. You can head back to the documentation and continue by browsing the templates section.

mui-styled-engine-sc-ts-fixes's People

Contributors

mnajdova avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.