Heading

Represents a heading text

đź“”

Heading follows the basic rules of the HTML heading elements (<h1>, ..., <h6>).

For the shorthand versions see their reference page: H1, H2, H3, H4, H5, H6.

Properties

ellipses (default: true)

This property indicates whether ellipses should be displayed (true) when the heading text is cropped or not (false).

<App>
  <VStack width="200px">
    <H3
      backgroundColor="cyan"
      maxLines="1"
      ellipses="false">
      Though this long text does is about to crop!
    </H3>
    <H3
      backgroundColor="cyan"
      maxLines="1">
      Though this long text does is about to crop!
    </H3>
  </VStack>
</App>

level (default: "h1")

This property sets the visual significance (level) of the heading.

Available values: h1 (default), h2, h3, h4, h5, h6

ValueDescription
h1(default) Equivalent to the <h1 /> HTML element
h2Equivalent to the <h2 /> HTML element
h3Equivalent to the <h3 /> HTML element
h4Equivalent to the <h4 /> HTML element
h5Equivalent to the <h5 /> HTML element
h6Equivalent to the <h6 /> HTML element

For a visual example, see the component description.

maxLines

This property determines the maximum number of lines the component can wrap to. If there is not enough space for all of the text, the component wraps the text up to as many lines as specified.

<App>
  <H2
    maxWidth="160px"
    backgroundColor="cyan"
    value="A long heading text that will likely overflow" maxLines="2" />
</App>

omitFromToc (default: false)

If true, this heading will be excluded from the table of contents.

preserveLinebreaks

This property indicates whether linebreaks should be preserved when displaying text.

<App>
  <HStack>
    <H3
      width="200px"
      backgroundColor="cyan"
      preserveLinebreaks="true"
      value="(preserve) This long text
  with several line breaks
          does not fit into a viewport with a 200-pixel width." />
    <H3
      width="200px"
      backgroundColor="cyan"
      value="(do not preserve) This long text
  with several line breaks
          does not fit into a viewport with a 200-pixel width." />
  </HStack>
</App>

You can observe the effect of using preserveLinebreaks:

đź“”

Remember to use the value property of Heading. Linebreaks are converted to spaces when nesting the text in the Heading component.

value

This property determines the text displayed in the heading. Heading also accepts nested text instead of specifying the value. If both value and a nested text are used, the value will be displayed.

<App>
  <Heading value="This is level 3 (value)" level="h3" />
  <Heading level="h3">This is level 3 (child)</Heading>
  <Heading value="Value" level="h3"><Icon name="trash" /></Heading>
</App>

Events

This component does not have any events.

Exposed Methods

This component does not expose any methods.

Styling

Theme Variables

VariableDefault Value (Light)Default Value (Dark)
fontFamily-H1

none

none

fontFamily-H2

none

none

fontFamily-H3

none

none

fontFamily-H4

none

none

fontFamily-H5

none

none

fontFamily-H6

none

none

fontFamily-Heading$fontFamily$fontFamily
fontWeight-H1

none

none

fontWeight-H2

none

none

fontWeight-H3

none

none

fontWeight-H4

none

none

fontWeight-H5

none

none

fontWeight-H6

none

none

fontWeight-Heading$fontWeight-bold$fontWeight-bold
letterSpacing-H1

none

none

letterSpacing-H2

none

none

letterSpacing-H3

none

none

letterSpacing-H4

none

none

letterSpacing-H5

none

none

letterSpacing-H6

none

none

letterSpacing-Heading00
textColor-H1

none

none

textColor-H2

none

none

textColor-H3

none

none

textColor-H4

none

none

textColor-H5

none

none

textColor-H6

none

none

textColor-Headinginheritinherit
textDecorationColor-H1

none

none

textDecorationColor-H2

none

none

textDecorationColor-H3

none

none

textDecorationColor-H4

none

none

textDecorationColor-H5

none

none

textDecorationColor-H6

none

none

textDecorationLine-H1

none

none

textDecorationLine-H2

none

none

textDecorationLine-H3

none

none

textDecorationLine-H4

none

none

textDecorationLine-H5

none

none

textDecorationLine-H6

none

none

textDecorationStyle-H1

none

none

textDecorationStyle-H2

none

none

textDecorationStyle-H3

none

none

textDecorationStyle-H4

none

none

textDecorationStyle-H5

none

none

textDecorationStyle-H6

none

none

textDecorationThickness-H1

none

none

textDecorationThickness-H2

none

none

textDecorationThickness-H3

none

none

textDecorationThickness-H4

none

none

textDecorationThickness-H5

none

none

textDecorationThickness-H6

none

none

textUnderlineOffset-H1

none

none

textUnderlineOffset-H2

none

none

textUnderlineOffset-H3

none

none

textUnderlineOffset-H4

none

none

textUnderlineOffset-H5

none

none

textUnderlineOffset-H6

none

none