Paragraph component is rendered as <p> and with default bottom margin of spacingM (1rem) applied. It is one of the most commonly used typography components.
Import
import { Paragraph } from '@contentful/f36-components';// orimport { Paragraph } from '@contentful/f36-typography';
Examples
Basic
Margins
By default Paragraph component has a margin bottom of spacingM (1rem). You can override the default margin bottom by specifying it explicitly on the component level by marginBottom="none" or any other value from our spacing options
Truncated text
Sometimes you might have to truncate the text in the Paragraph component, so we provide the prop especially for that. Under the hood, what it does is add overflow: hidden and set text-overflow to ellipsis. Have a look at the example below:
Props (API reference)
- Namechildren(required)ReactNode
- NameclassNameDescriptionCSS class to be appended to the root element string
- NameisTruncatedfalsetrue
- NamemarginDescriptionsets margin to one of the corresponding spacing tokens "none""spacing2Xs""spacingXs""spacingS""spacingM""spacingL""spacingXl""spacing2Xl""spacing3Xl""spacing4Xl"
- NamemarginBottomDescriptionsets margin-bottom to one of the corresponding spacing tokens "none""spacing2Xs""spacingXs""spacingS""spacingM""spacingL""spacingXl""spacing2Xl""spacing3Xl""spacing4Xl"
- NamemarginLeftDescriptionsets margin-left to one of the corresponding spacing tokens "none""spacing2Xs""spacingXs""spacingS""spacingM""spacingL""spacingXl""spacing2Xl""spacing3Xl""spacing4Xl"
- NamemarginRightDescriptionsets margin-right to one of the corresponding spacing tokens "none""spacing2Xs""spacingXs""spacingS""spacingM""spacingL""spacingXl""spacing2Xl""spacing3Xl""spacing4Xl"
- NamemarginTopDescriptionsets margin-top to one of the corresponding spacing tokens "none""spacing2Xs""spacingXs""spacingS""spacingM""spacingL""spacingXl""spacing2Xl""spacing3Xl""spacing4Xl"
- NametestIdDescriptionA [data-test-id] attribute used for testing purposes Defaultstringcf-ui-paragraph