React Bootstrap Text
React Text - Bootstrap 4 & Material Design
Note: This documentation is for an older version of Bootstrap (v.4). A
newer version is available for Bootstrap 5. We recommend migrating to the latest version of our product - Material Design for
Bootstrap 5.
Go to docs v.5
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.
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
.
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.
Bolder weight text (relative to the parent element).
Normal weight text.
Light weight text.
Lighter weight text (relative to the parent element).
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-bolder">Bolder weight text (relative to the parent element).</p>
<p className="font-weight-normal">Normal weight text.</p>
<p className="font-weight-light">Light weight text.</p>
<p className="font-weight-lighter">Lighter weight text (relative to the parent element).</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;
Reset color
Reset a text or link’s color with .text-reset
, so that it inherits the color from its parent.
Muted text with a reset link.
import React from 'react'
import { MDBContainer } from 'mdbreact';
const TextPage = () => {
return (
<MDBContainer>
<p class="text-muted">
Muted text with a <a href="#" class="text-reset">reset link</a>.
</p>
</MDBContainer>
)
}
export default TextPage;
Text decoration
Remove a text decoration with a .text-decoration-none
class.
import React from 'react'
import { MDBContainer } from 'mdbreact';
const TextPage = () => {
return (
<MDBContainer>
<a href="#" class="text-decoration-none">Non-underlined link</a>
</MDBContainer>
)
}
export default TextPage;