Rate this docs

React Bootstrap Text

React Text - Bootstrap 4 & Material Design

React Bootstrap text utilities are a group of text modifiers which change text alignment, wrapping, letter capitalization, weight, and italics.


Text alignment

Easily realign text to components with text alignment classes.

Ambitioni dedisse scripsisse iudicaretur. Cras mattis iudicium purus sit amet fermentum. Donec sed odio operae, eu vulputate felis rhoncus. Praeterea iter est quasdam res quas ex communi. At nos hinc posthac, sitientis piros Afros. Petierunt uti sibi concilium totius Galliae in diem certam indicere. Cras mattis iudicium purus sit amet fermentum.



        import React from 'react'
        import { MDBContainer } from 'mdbreact';

        const TextPage = () => {
          return (
            <MDBContainer>
              <p className="text-justify">Ambitioni dedisse scripsisse iudicaretur. Cras mattis iudicium purus sit amet fermentum.
                Donec sed odio operae,
                eu vulputate felis rhoncus. Praeterea iter est quasdam res quas ex communi. At nos hinc posthac, sitientis
                piros Afros. Petierunt uti sibi concilium totius Galliae in diem certam indicere. Cras mattis iudicium
                purus sit amet fermentum.</p>
            </MDBContainer>
          )
        }

        export default TextPage;

      

For left, right, and center alignment, responsive classes are available that use the same viewport width breakpoints as the grid system.

Left aligned text on all viewport sizes.

Center aligned text on all viewport sizes.

Right aligned text on all viewport sizes.

Left aligned text on viewports sized SM (small) or wider.

Left aligned text on viewports sized MD (medium) or wider.

Left aligned text on viewports sized LG (large) or wider.

Left aligned text on viewports sized XL (extra-large) or wider.


        import React from 'react'
        import { MDBContainer } from 'mdbreact';

        const TextPage = () => {
          return (
          <MDBContainer>
            <p className="text-left">Left aligned text on all viewport sizes.</p>
            <p className="text-center">Center aligned text on all viewport sizes.</p>
            <p className="text-right">Right aligned text on all viewport sizes.</p>
            <p className="text-sm-left">Left aligned text on viewports sized SM (small) or wider.</p>
            <p className="text-md-left">Left aligned text on viewports sized MD (medium) or wider.</p>
            <p className="text-lg-left">Left aligned text on viewports sized LG (large) or wider.</p>
            <p className="text-xl-left">Left aligned text on viewports sized XL (extra-large) or wider.</p>
          </MDBContainer>
          )
        }

        export default TextPage;
      

Text wrapping and overflow

Prevent text from wrapping with a .text-nowrap class.

This text should overflow the parent.

        import React from 'react'
        import { MDBContainer } from 'mdbreact';

        const TextPage = () => {
          return (
            <MDBContainer>
              <div className="text-nowrap bd-highlight" style={{width: "8rem"}}>
                This text should overflow the parent.
              </div>
            </MDBContainer>
          )
        }

        export default TextPage;
      

        .bd-highlight {
          background-color: rgba(86, 61, 124, .15);
          border: 1px solid rgba(86, 61, 124, .15);
        }
      

For longer content, you can add a .text-truncate class to truncate the text with an ellipsis. Requires display: inline-block or display: block.

Praeterea iter est quasdam res quas ex communi.
Praeterea iter est quasdam res quas ex communi.

      import React from 'react'
      import { MDBContainer } from 'mdbreact';

      const TextPage = () => {
        return (
          <MDBContainer>
            <div className="row">
              <div className="col-2 text-truncate">
                Praeterea iter est quasdam res quas ex communi.
              </div>
            </div>

            <span className="d-inline-block text-truncate" style={{maxWidth: "150px"}}>
              Praeterea iter est quasdam res quas ex communi.
            </span>
          </MDBContainer>
        )
      }

      export default TextPage;
      

Text transform

Transform text in components with text capitalization classes.

Lowercased text.

Uppercased text.

CapiTaliZed text.


        import React from 'react'
        import { MDBContainer } from 'mdbreact';

        const TextPage = () => {
          return (
            <MDBContainer>
              <p className="text-lowercase">Lowercased text.</p>
              <p className="text-uppercase">Uppercased text.</p>
              <p className="text-capitalize">CapiTaliZed text.</p>
            </MDBContainer>
          )
        }

        export default TextPage;
      

Note how text-capitalize only changes the first letter of each word, leaving the case of any other letters unaffected.


Font weight and italics

Quickly change the weight (boldness) of text or italicize text.

Bold text.

Normal weight text.

Italic text.


        import React from 'react'
        import { MDBContainer } from 'mdbreact';

        const TextPage = () => {
          return (
            <MDBContainer>
              <p className="font-weight-bold">Bold text.</p>
              <p className="font-weight-normal">Normal weight text.</p>
              <p className="font-italic">Italic text.</p>
            </MDBContainer>
          )
        }

        export default TextPage;
      

Monospace

Change a selection to our monospace font stack with .text-monospace.

This is in monospace


        import React from 'react'
        import { MDBContainer } from 'mdbreact';

        const TextPage = () => {
          return (
          <MDBContainer>
            <p className="text-monospace">This is in monospace</p>
          </MDBContainer>
          )
        }

        export default TextPage;