Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Align content to center with variant as caption in Material UI Typography

I have two Typography elements with default and caption variants. How do I center the content with align="center" property with variant as caption as this doesn't seem to work.

  render() {
    return (
      <div>
        <Typography align="center">Centered text</Typography>
        <Typography color="textSecondary" variant="caption" align="center">A Caption!</Typography>
      </div>
    );
  }

I created a working example using StackBlitz. Could anyone please help?

like image 481
scriobh Avatar asked Nov 27 '25 11:11

scriobh


1 Answers

import React from "react";
import Typography from "@material-ui/core/Typography";

export default function DisableElevation() {
  return (
    <div>
      <Typography align="center">Centered text</Typography>
      <Typography
        display="block"
        color="textSecondary"
        variant="caption"
        align="center"
      >
        A Caption!
      </Typography>
    </div>
  );
}
like image 193
SaimumIslam27 Avatar answered Nov 28 '25 23:11

SaimumIslam27



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!