Skip to main content

Heading

Creates appropriately sized heading elements.

Submit feedback
github
import { Heading } from '@uhg-abyss/mobile';
        <Heading>Heading</Heading>

        Set Global Heading 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, $heading, to be added in the createTheme function, which will add the font to all Heading components globally.

        In the example below, the font 'UHCSerif' is set as the heading font and will now be applied to all Heading components.

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

        Offset

        If you want to have heading levels relative to the current level, you can provide an offset prop. These are equivalent to using a heading element in HTML. A Heading with an offset of 1 would be the equivalent of an <h1>. Headings 1-4 have a default color of $core.color.brand.100 and Headings 5 & 6 have a default color of $core.color.neutral.100.

        You can use offset={1|2|3|4|5|6}.

        Level

        Headings 5 and 6 have an optional property called level that allows you to use a lighter version of the text. The default is level 1, the heavier version. The level two prop makes the heading lighter.

        Color

        Use the color property to set the color of the text. The default is set to $core.color.brand.100.

        Text Align

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

        Heading Props

        Prop NameTypeDefaultDescription
        animatedbooleanfalseFlag to enable component animation
        childrenstring-The text to be input into the heading component
        colorstringHeadings 1-4: "#002677", Headings 5-6: "#000000"Set the color of the heading text
        fontFamilystring-Set the font family of the heading
        level1 | 21Set the level of the heading. Used for offset 5 and 6 headings
        offset1 | 2 | 3 | 4 | 5 | 6 1The offset hierarchy of heading. 1 is <h1>, and so on
        textAlign"left" | "center" | "right"leftSpecifies text alignment of the heading text

        Heading Classes

        Class NameDescription
        abyss-heading-rootHeading root element

        Heading Tokens

        Token NameValue
        heading.color.text.default
        #002677
        heading.color.text.five
        #000000
        heading.color.text.six
        #000000
        Table of Contents