Typography is Material-UI component to present your design and content as clearly and efficiently as possible.

Typography with Material-UI

Typography is a Material-UI component to present your design and content as clearly and efficiently as possible.

Typography is a Material-UI component to present your design and content as clearly and efficiently as possible. In this blog, you are going to learn about the Typography component of Material-UI.

This blog is part of the Material-UI basics video series on Cules Coding YouTube channel.

Watch the video about Material-UI Typography:

Watch the full video series Material-UI basics

What is a Typography component?

Typography is simply a component that handles the text-based content of your application like paragraphs, headers, etc.

Usage

It is a very easy use Typography component. Just import and insert on your application.

import React from 'react'
import Typography from '@material-ui/core/Typography'
const Text = () => {
return (
<div>
<Typography>This is a Typography component.</Typography>
</div>
)
}
export default Text

It will give you a body1 text.

Alt Text

Apply styles to Typography with variant Prop

Variant Prop will allow you use different type of style like h1, h2, body2, subtitle1, subtitle2, caption etc.

import React from 'react'
import Typography from '@material-ui/core/Typography'
const Text = () => {
return (
<div>
<Typography>This is a Typography component.</Typography>
<Typography variant='h1'>This a H1 text</Typography>
<Typography variant='body2'>This a body2 text</Typography>
</div>
)
}
export default Text

Alt Text

Change tags with component prop.

Suppose you want to use the h1 tag but want to use the h5 style. You can easily do it with Component Prop

import React from 'react'
import Typography from '@material-ui/core/Typography'
const Text = () => {
return (
<div>
<Typography>This is a Typography component.</Typography>
<Typography variant='h1'>This a H1 text</Typography>
<Typography variant='body2'>This a body2 text</Typography>
<Typography component='h1' variant='h5'>
This a h5 text
</Typography>
</div>
)
}
export default Text

Alt Text

You can also use react component

import React from 'react'
import Typography from '@material-ui/core/Typography'
const Text = () => {
return (
<div>
<Typography>This is a Typography component.</Typography>
<Typography variant='h1'>This a H1 text</Typography>
<Typography variant='body2'>This a body2 text</Typography>
<Typography component='h1' variant='h5'>
This a h5 text
</Typography>
<Typography component={Button}>This a h5 text</Typography>
</div>
)
}
export default Text

We have used material-UI Button as a component Alt Text

Change colors

You can change colors with color props. Check the documentation for the color values

import React from 'react'
import Typography from '@material-ui/core/Typography'
const Text = () => {
return (
<div>
<Typography>This is a Typography component.</Typography>
<Typography variant='h1'>This a H1 text</Typography>
<Typography variant='body2'>This a body2 text</Typography>
<Typography component='h1' variant='h5'>
This a h5 text
</Typography>
<Typography component={Button}>This a h5 text</Typography>
<Typography color='primary' variant='h1'>
This a Primary text
</Typography>
<Typography color='secondary' variant='h1'>
This a Secondary text
</Typography>
<Typography color='error' variant=h1'>
This a Error text
</Typography>
</div>
)
}
export default Text

Alt Text

Align text

You can easily align text with the align prop.

import React from 'react'
import Typography from '@material-ui/core/Typography'
const Text = () => {
return (
<div>
<Typography>This is a Typography component.</Typography>
<Typography variant='h1'>This a H1 text</Typography>
<Typography variant='body2'>This a body2 text</Typography>
<Typography component='h1' variant='h5'>
This a h5 text
</Typography>
<Typography component={Button}>This a h5 text</Typography>
<Typography color='primary' variant='h1'>
This a Primary text
</Typography>
<Typography color='secondary' variant='h1' align='center'>
This a Centered aligned Secondary text
</Typography>
<Typography color='error' variant='h1' align='right'>
This a Error text
</Typography>
</div>
)
}
export default Text

Alt Text

So, that's it for today. Watch my video about typography. If you have any questions, please comment down below.
If you want to reach out to me, You can follow me on any social media as @thatanjan. Until then stay safe and goodbye. '

Shameless Plug

Want to create your own blog? Well, I am creating a video series where you will learn about how to create a JAMstack blog with Nextjs and Chakra-UI.

Lessons

Demo

You can demo the website from here

Features

  • Static Blog pages will make the website load faster.
  • Blogs will have code blocks with syntax highlighting and many embed components like youtube videos, GitHub gist, Tweets, and so many other things.
  • Autocomplete search feature for the blog posts.
  • Real-time view counter and so on.

Please like and subscribe to Cules Coding. It motivates me to create more content like this.

That's it for this blog. I have tried to explain things simply. If you get stuck, you can ask me questions.

By the way, I am looking for a new opportunity in a company where I can provide great value with my skills. If you are a recruiter, looking for someone skilled in full-stack web development and passionate about revolutionizing the world, feel free to contact me. Also, I am open to talking about any freelance project. I am available on Upwork

Contacts

Blogs you might want to read:

Videos might you might want to watch:

Previous PostWhat is CSS in JS?
Next Post13 reasons why you should use Nextjs