Skip to main content

Text

Used to create segments of text such as phrases, sentences, and paragraphs.

Submit feedback
github
import { Text } from '@uhg-abyss/mobile';
      <Text>Enter message here</Text>

      Set Global Text Font

      One of the limitations of our library is the inability to install fonts into applications. Because of this, we have reserved a special token, $text, to be added in the createTheme function, which will add the font to all Heading components globally.

      In the example below, the font 'UHCSans' is set as the text font and will now be applied to all Text components.

      import { ThemeProvider, createTheme } from '@uhg-abyss/mobile';
      const theme = createTheme('uhc', {
      theme: {
      fonts: {
      text: 'UHCSans',
      },
      },
      });
      const App = () => {
      return <ThemeProvider theme={theme}>...</ThemeProvider>;
      };

      Any individual Text component can override the font with the fontFamily prop.

      Color

      Use the color property to set the color of the text. The default is set to black.

      Sizes

      Use the size property to change the size of the text. The default is set to md which is 16px. The values for each size are represented by FontSize - LineHeight.

      Font Weight

      Use the fontWeight property to change the weight of the text.

      Transform

      Use the transform property to change the formatting of the text. Variants available include the default case, capitalize the first letter of each word, lowercase all letters, or uppercase all letters.

      Text Align

      Use the textAlign prop to change the alignment of the text. Options include left, center and right. Default is left.

      Animated

      Use the animated prop to use animation styles on the component. The default is set to false.

      Nesting

      Nested text components will inherit properties from the outer Text.

      Text Props

      Prop NameTypeDefaultDescription
      animatedbooleanfalseFlag to enable component animation
      childrenstring-The contents of the text component
      colorstring-Set the color of the text
      fontFamilystring-Set the font family of text
      fontWeightstringregularSet the font weight of text
      sizenumber | string-Set the size of the text
      textAlign"left" | "center" | "right"-Specifies text alignment
      transformstring-Reformat the text by changing whether letters are capitalized or not

      Text Classes

      Class NameDescription
      abyss-text-rootText root element

      Text Tokens

      Token NameValue
      text.color.text
      #4B4D4F
      Table of Contents