Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typography span variant #13196

Closed
Fi1osof opened this issue Oct 10, 2018 · 8 comments
Closed

Typography span variant #13196

Fi1osof opened this issue Oct 10, 2018 · 8 comments
Labels
component: Typography The React component. support: Stack Overflow Please ask the community on Stack Overflow

Comments

@Fi1osof
Copy link
Contributor

Fi1osof commented Oct 10, 2018

Both defaultHeadlineMapping variants body1 and body2 - p (paragraph) tag. Other variants are block-types too (h1-h6) and no one inline/inline-block.

I can do this by

component={(props) => {
  return <span
    {...props}
  />
}}

or

variant="body2"
headlineMapping={{
  body2: 'span',
}}

But it's not useful.

@Fi1osof
Copy link
Contributor Author

Fi1osof commented Oct 10, 2018

UPD: as far as I understand, i can like this:

<Typography
  component="span"
>
  Span text
</Typography>

Is this best practice?

UPD2: This is not best practice(( Styles still for block element and color override parent.

.MuiTypography-body1-136 {
    color: #fff;
    font-size: 0.875rem;
    font-weight: 400;
    font-family: Tahoma, Helvetica, sans-serif;
    line-height: 1.46429em;
}

<style>…</style>
.MuiTypography-root-127 {
    margin: 0;
    display: block;
}

@eps1lon eps1lon added component: Typography The React component. support: Stack Overflow Please ask the community on Stack Overflow labels Oct 11, 2018
@support
Copy link

support bot commented Oct 11, 2018

👋 Thanks for using Material-UI!

We use the issue tracker exclusively for bug reports and feature requests, however,
this issue appears to be a support request or question. Please ask on StackOverflow where the
community will do their best to help. There is a "material-ui" tag that you can use to tag your
question.

If you would like to link from here to your question on SO, it will help others find it.
If your issues is confirmed as a bug, you are welcome to reopen the issue using the issue template.

@support support bot closed this as completed Oct 11, 2018
@kross-italk
Copy link

This is the #1 result for "material ui typography span inline text" and there is no accepted answer. There is nothing on Stack overflow for this question. You need to treat your community better

@joshwooding
Copy link
Member

joshwooding commented Jul 29, 2019

@kross-italk I think it’s kind of unfair to accuse us of treating our community badly considering how much time we spend answering questions and improving Material UI. Now to answer your question:

We changed Typography‘s implementation in v4 so it uses the default display for the element you choose i.e. inline for span. If you want to override this you can use the display prop e.g. display="inline"

@kgregory
Copy link
Member

kgregory commented Aug 1, 2019

There is nothing on Stack overflow for this question

Seems like a good opportunity for you to change that! Have you asked the question there?

@julianwilkinson
Copy link

Hi~ Maybe I should reopen a diff issue but one thing about using Typography with display="inline" is it still renders it as <p> instead of a <span>— the implications being this may confuse users with screen readers

@Fi1osof
Copy link
Contributor Author

Fi1osof commented Jul 5, 2022

@julianwilkinson i think you should use both display="inline" and component="span"

@julianwilkinson
Copy link

Ah! I didn't realize that was an option — thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: Typography The React component. support: Stack Overflow Please ask the community on Stack Overflow
Projects
None yet
Development

No branches or pull requests

6 participants