• Docs
  • Blog
    • 0.25.1

    • light

      dark

      system

      Switch mode
    • Cerberus

      Acheron

      Elysium

    Get Started
    Components
    Styling
    Theming

    Concepts

    OverviewCompositionTesting

    Layout

    Aspect RatioBleedBoxCenterContainerDividerFlexFloatGridLink OverlayScrollableStackWrap

    Components

    AccordionAdmonitionAvatarButtonCarouselCheckboxClipboardCollapsibleComboboxConfirm ModalCTAModalDate PickerDialogFieldFieldsetFile UploaderIcon ButtonInputLoading StatesMenuNotificationsNumber InputPin InputProgressPrompt ModalRadioRatingSelectSplit ButtonSwitchTableTabsTagTextTextareaToggleTooltip

    Utilities

    Client OnlyDownload TriggerEnvironmentFeature FlagsFocus TrapForFormat ByteFormat NumberFormat Relative TimeFrameHighlightJSON Tree ViewLocaleLocal StoragePortalPresenceShowsplitPropsTheme

    Text

    A component for rendering text.

    • npm
    • source
    import { Text } from '@cerberus/react'

    Usage

    Hello, world!

    This is normal text

    This is small text
    Copy
    Basic usage
    import { Text } from '@cerberus/react'
    function TextDemo() {
    return (
    <>
    <Text
    as="h1"
    color="page.text.100"
    textStyle={{
    base: 'heading-md',
    md: 'heading-lg',
    }}
    >
    Hello, world!
    </Text>
    <Text>This is normal text</Text>
    <Text as="small" color="info.text.100" textStyle="body-sm">
    This is small text
    </Text>
    </>
    )
    }

    Raw HTML

    To render raw HTML, you can utilize the React dangerouslySetInnerHTML combined with the whiteSpace property.

    This is a raw paragraph with a bold word and a
    line break.

    Copy
    Basic usage
    import { Text } from '@cerberus/react'
    function DangerouslySetDemo() {
    const rawHTML =
    '<p>This is a raw paragraph with a <strong>bold</strong> word and a <br /> line break.</p>'
    return (
    <Text
    dangerouslySetInnerHTML={{
    __html: rawHTML,
    }}
    textStyle="body-sm"
    whiteSpace="pre-wrap"
    />
    )
    }

    API

    export type Headings = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'
    export type TextElements = 'p' | 'strong' | 'em' | 'small' | 'span'
    export interface TextProps extends BoxProps {
    as?: TextElements | Headings
    }
    define function Text(props: TextProps): ReactNode

    Props

    The Text component accepts the following props along with the props from the Box component.

    NameDefaultDescription
    asThe text-based element to render the component as.

    On this page

    • Edit this page on Github
    Cerberus Design System | Docs