# SectionTitle

> A component for rendering headings of major sections within a page. It helps to create a clear and accessible document structure.

Source: https://vaneui.com/docs/typography-components/section-title

Import: `import { SectionTitle, Card, Col, Divider, PageTitle, Section, Text, Title } from "@vaneui/ui"`

SectionTitle opens each major part of a page, such as features, pricing or FAQ. Like the other heading components, its font size steps down at tablet and mobile widths, and passing `href` renders an `<a>` in place of the `<h2>`. Keep [PageTitle](/docs/typography-components/page-title) for the `<h1>` that names the page, and use [Title](/docs/typography-components/title) for headings inside a section, such as card titles.

## Basic usage

SectionTitle renders an `<h2>` heading for major section headings. It defaults to `fontSemibold` weight, `fontHeading` font family, `inheritAppearance` appearance, and left-aligned text.

```tsx demo
<SectionTitle>Getting Started</SectionTitle>
```

## Sizes

Section titles come in five sizes: `xs`, `sm`, `md` (default), `lg`, `xl`.

```tsx demo
<Col>
  <SectionTitle xs>Extra Small Section Title</SectionTitle>
  <SectionTitle sm>Small Section Title</SectionTitle>
  <SectionTitle>Medium Section Title (default)</SectionTitle>
  <SectionTitle lg>Large Section Title</SectionTitle>
  <SectionTitle xl>Extra Large Section Title</SectionTitle>
</Col>
```

## Appearances

By default, SectionTitle uses the `inheritAppearance` appearance: it inherits color from its parent. Use explicit appearances like `primary`, `secondary`, `success`, `warning`, `danger`, `info` to override.

```tsx demo
<Col>
  <SectionTitle primary>Primary Section Title</SectionTitle>
  <SectionTitle secondary>Secondary Section Title</SectionTitle>
  <SectionTitle success>Success Section Title</SectionTitle>
  <SectionTitle warning>Warning Section Title</SectionTitle>
  <SectionTitle danger>Danger Section Title</SectionTitle>
  <SectionTitle info>Info Section Title</SectionTitle>
</Col>
```

## Variants

Headings never paint a background, so the variant only picks which colour of the appearance the heading is painted in. `outline`, the default, uses the appearance's own colour. `filled` uses the "on this fill" colour, for a heading sitting on a filled surface of the same appearance.

```tsx demo
<Col>
  <SectionTitle info>outline info, on the page surface</SectionTitle>
  <SectionTitle danger>outline danger, on the page surface</SectionTitle>
  <Card info filled>
    <SectionTitle info filled>filled info, on a matching filled Card</SectionTitle>
  </Card>
  <Card danger filled>
    <SectionTitle danger filled>filled danger, on a matching filled Card</SectionTitle>
  </Card>
</Col>
```

## PageTitle vs SectionTitle vs Title

Three heading components for a clean semantic hierarchy.

```tsx demo
<Col>
  <PageTitle>Page Heading (h1)</PageTitle>
  <SectionTitle>Section Heading (h2)</SectionTitle>
  <Title>Subsection Heading (h3)</Title>
</Col>
```

## Font weights

SectionTitle is `fontSemibold` by default. Override with any weight prop: `fontThin`, `fontExtralight`, `fontLight`, `fontNormal`, `fontMedium`, `fontSemibold`, `fontBold`, `fontExtrabold`, `fontBlack`.

```tsx demo
<Col>
  <SectionTitle fontLight>Light Section Title</SectionTitle>
  <SectionTitle fontNormal>Normal Section Title</SectionTitle>
  <SectionTitle fontMedium>Medium Section Title</SectionTitle>
  <SectionTitle>Semibold Section Title (default)</SectionTitle>
  <SectionTitle fontBold>Bold Section Title</SectionTitle>
  <SectionTitle fontBlack>Black Section Title</SectionTitle>
</Col>
```

## Font families

Switch between `fontSans`, `fontSerif`, and `fontMono` font families.

```tsx demo
<Col>
  <SectionTitle fontSans>Sans-serif Section Title</SectionTitle>
  <SectionTitle fontSerif>Serif Section Title</SectionTitle>
  <SectionTitle fontMono>Monospace Section Title</SectionTitle>
</Col>
```

## Italic

Use the `italic` prop for italic emphasis.

```tsx demo
<SectionTitle italic>Italic Section Title</SectionTitle>
```

## Uppercase

Use the `uppercase` prop to render the title in all caps.

```tsx demo
<SectionTitle uppercase>Uppercase Section Title</SectionTitle>
```

## Text alignment

SectionTitle is left-aligned by default. Use `textCenter`, `textRight`, or `textJustify` to change alignment.

```tsx demo
<Col>
  <SectionTitle wFull>Left Aligned (default)</SectionTitle>
  <SectionTitle wFull textCenter>Center Aligned</SectionTitle>
  <SectionTitle wFull textRight>Right Aligned</SectionTitle>
</Col>
```

## Custom HTML tag

Override the rendered tag with the `tag` prop when the visual style of SectionTitle is wanted but a different semantic level is required.

```tsx demo
<Col>
  <SectionTitle tag="h1">Rendered as h1</SectionTitle>
  <SectionTitle>Rendered as h2 (default)</SectionTitle>
  <SectionTitle tag="h3">Rendered as h3</SectionTitle>
  <SectionTitle tag="h4">Rendered as h4</SectionTitle>
</Col>
```

## SectionTitle in a Section

`SectionTitle` is designed to head a `<Section>`. Use them together so the visual structure matches the semantic outline.

```tsx demo
<Col>
  <Section>
    <SectionTitle>Installation</SectionTitle>
    <Text>Install VaneUI using npm or yarn.</Text>
  </Section>
  <Section>
    <SectionTitle>Usage</SectionTitle>
    <Text>Import components and start building.</Text>
  </Section>
</Col>
```

## SectionTitle in context

Section titles work well with other typography components in cards.

```tsx demo
<Card>
  <SectionTitle lg primary>Product Features</SectionTitle>
  <Text secondary>Everything you need to build modern applications.</Text>
  <SectionTitle sm>Performance</SectionTitle>
  <Text>Optimized for speed and efficiency.</Text>
  <SectionTitle sm>Accessibility</SectionTitle>
  <Text>Built with ARIA best practices.</Text>
</Card>
```

## Section header pattern

Combine SectionTitle with Divider and content for a structured section.

```tsx demo
<Col>
  <SectionTitle primary>Getting Started</SectionTitle>
  <Divider />
  <Text>Follow the steps below to set up your project.</Text>
  <SectionTitle primary>Configuration</SectionTitle>
  <Divider />
  <Text>Customize the settings to match your requirements.</Text>
</Col>
```

## Frequently asked questions

### Why doesn't `textCenter` center my SectionTitle?

SectionTitle is `wFit` by default, so its box is as wide as its text, and centering the text inside that box moves nothing. Add `wFull` so the box spans its parent and the text centers in it, as in [Text alignment](#text-alignment). To center the heading box itself, put `itemsCenter` on the parent; a heading that wraps onto several lines then also needs `textCenter`.

### How do I add an anchor link to a SectionTitle?

Give the SectionTitle an `id` and nest a [Link](/docs/typography-components/link) with `href` set to `#` and that id inside it. Do not pass `href` to the SectionTitle itself: it then renders an `<a>` in place of the `<h2>`, and the page loses the heading. Link takes the heading's size, but it is `fontSans` by default, so add `fontHeading` when your heading font differs.

### How do I put an action next to a SectionTitle?

Put both in `<Row justifyBetween>`: the SectionTitle keeps its fit width, and the Button or Link after it moves to the end edge. Add `itemsBaseline` to line the action up with the heading text rather than its box, and `flexWrap` so that on a narrow screen the action drops below a long heading instead of squeezing it.

## Props

| Prop | Category | Default | Description |
| --- | --- | --- | --- |
| `primary` | Appearance |  | Primary color appearance (gray) |
| `accent` | Appearance |  | Accent color appearance (rose) |
| `secondary` | Appearance |  | Secondary color appearance (gray) |
| `tertiary` | Appearance |  | Tertiary color appearance |
| `success` | Appearance |  | Success color appearance (green) |
| `danger` | Appearance |  | Danger color appearance (red) |
| `warning` | Appearance |  | Warning color appearance (amber) |
| `info` | Appearance |  | Info color appearance (cyan) |
| `inheritAppearance` | Appearance | yes | Inherit appearance from parent — suppresses own data-appearance/data-variant, uses parent's CSS variables |
| `fontSans` | Font Family |  | Sans-serif font family (default) — emits font-sans |
| `fontSerif` | Font Family |  | Serif font family — emits font-serif |
| `fontMono` | Font Family |  | Monospace font family — emits font-mono |
| `fontHeading` | Font Family | yes | Heading font family (defaults to sans, customizable via --font-heading) — emits font-heading |
| `italic` | Font Style |  | Italic font style |
| `notItalic` | Font Style |  | Not italic (normal) font style |
| `fontThin` | Font Weight |  | Thin font weight (100) — emits font-thin |
| `fontExtralight` | Font Weight |  | Extra light font weight (200) — emits font-extralight |
| `fontLight` | Font Weight |  | Light font weight (300) — emits font-light |
| `fontNormal` | Font Weight |  | Normal font weight (400) — emits font-normal |
| `fontMedium` | Font Weight |  | Medium font weight (500) — emits font-medium |
| `fontSemibold` | Font Weight | yes | Semibold font weight (600) — emits font-semibold |
| `fontBold` | Font Weight |  | Bold font weight (700) — emits font-bold |
| `fontExtrabold` | Font Weight |  | Extra bold font weight (800) — emits font-extrabold |
| `fontBlack` | Font Weight |  | Black font weight (900) — emits font-black |
| `inheritColor` | Inherit Color |  | Inherit text color from parent via CSS variable cascade (suppresses data-appearance emission) |
| `noInheritColor` | Inherit Color |  | Keep own text color; do not inherit from parent |
| `inheritSize` | Inherit Size |  | Inherit font-size and line-height from the nearest parent typography element |
| `noInheritSize` | Inherit Size |  | Keep own font-size; do not inherit from parent |
| `trackingTighter` | Letter Spacing |  | Tighter letter spacing (-0.05em) |
| `trackingTight` | Letter Spacing |  | Tight letter spacing (-0.025em) |
| `trackingNormal` | Letter Spacing |  | Normal letter spacing (0) |
| `trackingWide` | Letter Spacing |  | Wide letter spacing (0.025em) |
| `trackingWider` | Letter Spacing |  | Wider letter spacing (0.05em) |
| `trackingWidest` | Letter Spacing |  | Widest letter spacing (0.1em) |
| `margin` | Margin |  | Enable margin on all sides |
| `marginX` | Margin |  | Enable only horizontal (inline) margin |
| `marginY` | Margin |  | Enable only vertical (block) margin |
| `marginT` | Margin |  | Enable only top margin |
| `marginB` | Margin |  | Enable only bottom margin |
| `noMargin` | Margin |  | Disable margin (reset to 0) |
| `xs` | Size |  | Extra small size |
| `sm` | Size |  | Small size |
| `md` | Size | yes | Medium size (default) |
| `lg` | Size |  | Large size |
| `xl` | Size |  | Extra large size |
| `skeleton` | Skeleton |  | Show the component as a loading placeholder in its own size and shape. On a container, every component inside it becomes a placeholder too |
| `srOnly` | Sr Only |  | Hide visually and keep it for screen readers (sr-only) |
| `textLeft` | Text Align | yes | Align text to left (physical side, does not flip under RTL) |
| `textCenter` | Text Align |  | Align text to center |
| `textRight` | Text Align |  | Align text to right (physical side, does not flip under RTL) |
| `textJustify` | Text Align |  | Justify text |
| `textStart` | Text Align |  | Align text to the reading-direction start (left in LTR, right in RTL) |
| `textEnd` | Text Align |  | Align text to the reading-direction end (right in LTR, left in RTL) |
| `underline` | Text Decoration |  | Add underline decoration below text |
| `lineThrough` | Text Decoration |  | Add strikethrough/line-through decoration across text |
| `noUnderline` | Text Decoration |  | Remove ALL text-decoration — underline, line-through, and overline (text-decoration: none) |
| `overline` | Text Decoration |  | Add overline decoration above text |
| `uppercase` | Text Transform |  | Transform text to uppercase |
| `lowercase` | Text Transform |  | Transform text to lowercase |
| `capitalize` | Text Transform |  | Capitalize first letter of each word |
| `normalCase` | Text Transform |  | Normal text case (no transformation) |
| `truncate` | Truncate |  | Single line truncation with ellipsis |
| `lineClamp2` | Truncate |  | Truncate at 2 lines with ellipsis |
| `lineClamp3` | Truncate |  | Truncate at 3 lines with ellipsis |
| `lineClamp4` | Truncate |  | Truncate at 4 lines with ellipsis |
| `lineClamp5` | Truncate |  | Truncate at 5 lines with ellipsis |
| `noTruncate` | Truncate |  | Remove truncation |
| `filled` | Variant |  | Filled variant - solid background with contrasting text color |
| `outline` | Variant | yes | Outline variant - transparent background with border and colored text (default) |
| `ghost` | Variant |  | Ghost variant - transparent background, no border, appearance-colored text, tinted hover background |
| `breakNormal` | Word Break |  | Reset breaking - overflow-wrap and word-break normal |
| `breakWords` | Word Break |  | Break long words to prevent overflow - overflow-wrap: break-word |
| `breakAll` | Word Break |  | Break between any two characters - word-break: break-all |
| `breakKeep` | Word Break |  | Do not break CJK text - word-break: keep-all |

Layout and utility props (Cursor, Display, Height, Hide, Items, Justify, Overflow, Position, Responsive Sizing, Responsive Width, Show, Whitespace, Width) are listed on [Common Props](https://vaneui.com/docs/reference/common-props.md).
