TypeScript React
This is a simple TypeScript Type Extension Library for Material UI 6, React 18 & also for Next.js 14
I made this library so that I can use it in all of my Next.js 14 projects without writing the same codes over and over again
- It provides total intellisense of material ui styles in separate files to be used as
sx
- This type will help to de-clutter your jsx/tsx components because you can create
sx
styles outside the components and later use it inside them - For usage instruction, see
Usage
section
- React
- Next.js
This library has peer dependency for React & React DOM of minimum 18.3.1. It may or may not work on 19.x
- 💀 Minimum react Version:
18.3.1
- 💀 Minimum @types/react Version:
18.3.3
- 💀 Minimum react-dom Version:
18.3.1
- 💀 Minimum @types/react-dom Version:
18.3.0
- 💀 Minimum next Version:
14.2.3
- 💀 Minimum material-ui Version:
6.0.1
npm add -D @best-skn/mui-types #or yarn add -D @best-skn/mui-types #or pnpm add -D @best-skn/mui-types #or bun add -D @best-skn/mui-types
Create a directory called types
in the root location of your project, and create a file called mui.d.ts
, then do this
import "@best-skn/mui-types";
Check your tsconfig.json
if includes
property has **/*.ts
, **/*.tsx
otherwise the type definition file may not work
import type { Sx } from "@mui/material"; type Key = "container" | "box"; // * Create sx names here export const sx: Sx<Key> = { //* You'll get total intellisense for `sx` names container: { //* You'll get intellisense for Material UI SX styles inside display: "flex", //* other styles here... }, box: { color: "blue", //* other styles here... }, };
"use client" import Typography from "@mui/material/Typography"; import { sx } from "./sx.ts"; const HomeComponent: React.FC<unknown> = () => { return ( <Typography variant="h6" component="div" sx={sx.box} //* Use `sx` style here > Home Component </Typography> ); }; export default HomeComponent;
- 👩⚕️
Tanjila Hasan Trina
: The long lost love of my life. The course of nature separated us from our paths and put us in separate places far away from each other. But no matter how separated we are right now, each and every moment of mine is only dedicated to you. We may not see each other in this lifetime as it seems but I will find you again in the next life. I just want to say:世界は残酷だ それでも君を愛すよ
- 💯
My Parents
: The greatest treasures of my life ever.
Copyright (C) 2024 SKN Shukhan
Licensed under the MIT License