1.1.2 • Published 4 years ago

mui-typography v1.1.2

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

mui-typography

High order component for Material-UI Typography. For correct work required "mui-app-theme" >= "1.2.2"

Installation

npm install mui-typography

How to use

// MyTitle.tsx
import React, { FunctionComponent } from "react";
import { IAppTheme } from "mui-app-theme";
import { Typography } from "mui-typography";
import { makeStyles } from "@material-ui/core";

const useStyles = makeStyles((theme: IAppTheme) =>({
    title: {
        paddingLeft: 24,
    },
}));

const MyTitle: FunctionComponent = () => {
    const classes = useStyles();

    return (
        <Typography
            size={700} 
            color={"strong"}
            bold
            noWrap 
            className={classes.title} 
            component={"p"}
        >
            My Title
        </Typography>
    );
};

You can override default styles

// MyAppThemeTypography.ts
import { AppThemeTypography } from "mui-app-theme";

export class MyAppThemeTypography extends AppThemeTypography {
    constructor() {
        super();
        this["100"] = this.createVariant(300, 11, "15px", 0.03333);
    }
}
// App.tsx
import { createAppTheme } from "mui-app-theme";
import React, { FunctionComponent } from "react";
import { ThemeProvider } from "@material-ui/styles";

import { MyAppThemeTypography } from "./MyAppThemeTypography";

const App: FunctionComponent = () => {
    const appTheme = createAppTheme({ themeTypography: new MyAppThemeTypography() });

    return (
        <ThemeProvider theme={appTheme}>
            {
            // children
            }
        </ThemeProvider>
    );
};

Props

nametypedefaultdescription
size50 | 100 | 175 | 200 | 300 | 400 | 700200font size
color"strong" | "medium" | "light" | "disabled" | "default" | "default.text" | "primary" | "primary.text" | "secondary" | "secondary.text" | "destructive" | "destructive.text""medium"font color
classNamestringcss class name
componentElementType"span"The component used for the root node. Either a string to use a HTML element or a component.
boldbooleanfalseIf true font weight will be 400
disabledbooleanfalseIf true the color will be default
noWrapbooleanfalseIf true, the text will not wrap, but instead will truncate with a text overflow ellipsis. Note that text overflow can only happen with block or inline-block level elements (the element needs to have a width in order to overflow)
forwardedRefRef\<any>undefinedThe ref is forwarded to the root element.
1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.9.0

4 years ago

0.8.0

4 years ago