# Section

> Groups related content and owns the outer padding and background of a page band. Renders as a plain wrapper by default; pass tag="section" for a landmark.

Source: https://vaneui.com/docs/layout-components/section

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

Use one Section for each band of a page, such as a hero, a feature list or a footer. A [Container](/docs/layout-components/container) nested inside a Section keeps its content at a readable width. For a bordered panel that sits within the content instead of spanning the page, use [Card](/docs/layout-components/card).

## Basic usage

`md`, `wFull`, `flex`, `column`, `itemsStart`, `gap`, `padding`, `outline`, `sharp`, and `responsiveSizing` are defaults. Padding and gap automatically scale at tablet and mobile breakpoints because `responsiveSizing` is on.

```tsx demo
<Section border>
  <Title>Welcome Section</Title>
  <Text>Sections provide consistent vertical rhythm and full-width backgrounds.</Text>
</Section>
```

## Sizes

Sizes (`xs`, `sm`, `md` default, `lg`, `xl`) control padding and gap.

```tsx demo
<Col>
  <Section xs border>
    <Text fontSemibold>Extra Small Section</Text>
    <Text>Tightest padding</Text>
  </Section>
  <Section sm border>
    <Text fontSemibold>Small Section</Text>
    <Text>Compact padding</Text>
  </Section>
  <Section border>
    <Text fontSemibold>Medium Section (default)</Text>
    <Text>Standard padding</Text>
  </Section>
  <Section lg border>
    <Text fontSemibold>Large Section</Text>
    <Text>Generous padding</Text>
  </Section>
  <Section xl border>
    <Text fontSemibold>Extra Large Section</Text>
    <Text>Widest padding</Text>
  </Section>
</Col>
```

## Appearances

Sections support color appearances: `primary`, `secondary`, `success`, `danger`, etc. Use `secondary` filled bands to create visual rhythm between regular sections.

```tsx demo
<Col>
  <Section secondary filled>
    <Text fontSemibold>Secondary band</Text>
    <Text>Subtle background to break up a long page.</Text>
  </Section>
  <Section primary>
    <Text fontSemibold>Primary Section</Text>
    <Text>Highlighted content area</Text>
  </Section>
  <Section success>
    <Text fontSemibold>Success Section</Text>
    <Text>Positive feedback area</Text>
  </Section>
  <Section danger>
    <Text fontSemibold>Danger Section</Text>
    <Text>Warning or error area</Text>
  </Section>
</Col>
```

## Variants

Use `filled` for solid backgrounds (`outline` is the default), and `shadow` for elevation.

```tsx demo
<Col>
  <Section filled primary>
    <Title filled primary>Filled Section</Title>
    <Text filled primary>Solid background with primary color</Text>
  </Section>
  <Section secondary border>
    <Title secondary>Outline Section (default)</Title>
    <Text secondary>Border-only styling</Text>
  </Section>
  <Section shadow>
    <Title>Shadow Section</Title>
    <Text>Elevated with drop shadow</Text>
  </Section>
</Col>
```

## Shapes

Section is `sharp` by default, since a full-bleed band should meet the viewport edge without a radius. `rounded` suits a section used as an inset panel.

```tsx demo
<Col>
  <Section border>Sharp, the default</Section>
  <Section rounded border>Rounded</Section>
  <Section pill border>Pill</Section>
</Col>
```

## Layout

Use `row` for horizontal layout. `gap` is already on by default; pair with `noPadding` only when a wrapper owns spacing.

```tsx demo
<Col>
  <Section row border>
    <Text fontSemibold>Row Layout</Text>
    <Text>Content flows horizontally</Text>
    <Text>With gap between items</Text>
  </Section>
  <Section border>
    <Text fontSemibold>Column Layout (default)</Text>
    <Text>Content flows vertically</Text>
    <Text>With gap between items</Text>
  </Section>
</Col>
```

## Responsive breakpoints

Use `mobileStack` or `tabletStack` to switch from row to column layout on smaller screens.

```tsx demo
<Section row tabletStack border>
  <Col>
    <Title>Left Content</Title>
    <Text>Switches to stacked layout on tablets and below.</Text>
  </Col>
  <Col>
    <Title>Right Content</Title>
    <Text>Resize your browser to see the responsive behavior.</Text>
  </Col>
</Section>
```

## Responsive sizing

`responsiveSizing` (default) scales padding and gap at tablet and mobile breakpoints using `--py-tablet`, `--gap-mobile`, etc. Pass `responsiveSizing={false}` to lock a single size across all viewports.

```tsx demo
<Col>
  <Section lg border>
    <Text fontSemibold>responsiveSizing (default)</Text>
    <Text>Padding shrinks at tablet and mobile.</Text>
  </Section>
  <Section lg responsiveSizing={false} border>
    <Text fontSemibold>responsiveSizing=&#123;false&#125;</Text>
    <Text>Padding stays fixed at the lg size on every viewport.</Text>
  </Section>
</Col>
```

## Semantic tag

Section renders as `<div>` by default. Pass `tag="section"` for a semantic `<section>` element, or `tag="header"` / `tag="footer"` / `tag="aside"` for other landmarks.

```tsx demo
<Col>
  <Section tag="section" border>
    <Title>Semantic section</Title>
    <Text>Renders as &lt;section&gt; in the DOM.</Text>
  </Section>
  <Section tag="header" secondary filled>
    <Title>Page header</Title>
    <Text>Renders as &lt;header&gt;.</Text>
  </Section>
</Col>
```

## Page layout pattern

The canonical full-bleed page band: a Section owns the outer padding and background, with a nested `Container` capping the inner reading width.

```tsx demo
<Section secondary filled>
  <Container>
    <PageTitle>Getting Started</PageTitle>
    <Text>The Section handles the full-bleed background and outer padding. The Container constrains the inner content to a comfortable reading width.</Text>
  </Container>
</Section>
```

## Frequently asked questions

### Why doesn't my Section paint a background?

A Section has no appearance by default, so it paints nothing and shows whatever is behind it. Give it one: `<Section primary>` paints the page surface, which a `data-theme="dark"` wrapper needs, and `<Section secondary filled>` paints a tinted band like the ones under [Appearances](#appearances). Add `border` when the band also needs a line around it.

### How do I change a Section's padding with a class?

Pass a class that sets the whole value, such as `py-16`, `px-8` or `p-12`. The theme repeats its padding for tablet and mobile, and a class like these replaces it at every width, phones included. A one-sided class such as `pt-16` wins only on desktop and gives way to the theme's padding below 1024px. A size prop such as `lg` keeps the scaling for smaller screens.

### Should a Section render as a `<section>` element?

Use `tag="section"` when the band has its own heading, and point `aria-labelledby` at that heading's `id`: a `<section>` with an accessible name is exposed as a region landmark, while one without a name is no different from a `<div>`. Bands that only hold layout can stay `<div>`. For the site header and footer outside `<main>`, `tag="header"` and `tag="footer"` give the banner and contentinfo landmarks.

## 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 |  | Inherit appearance from parent — suppresses own data-appearance/data-variant, uses parent's CSS variables |
| `desktopStack` | Breakpoint |  | Stack into a column at desktop width and below (max-desktop: 80rem) |
| `tabletStack` | Breakpoint |  | Stack into a column at tablet width and below (max-tablet: 64rem) |
| `mobileStack` | Breakpoint |  | Stack into a column at mobile width and below (max-mobile: 48rem) |
| `flex1` | Flex |  | Take up remaining space (= `flex-1`, i.e. `flex: 1 1 0%`) |
| `flexAuto` | Flex |  | Grow but respect intrinsic size (= `flex-auto`, i.e. `flex: 1 1 auto`) |
| `flexNone` | Flex |  | Don't grow and don't shrink (= `flex-none`, i.e. `flex: none`) |
| `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) |
| `padding` | Padding | yes | Enable internal padding |
| `paddingX` | Padding |  | Enable only horizontal padding |
| `paddingY` | Padding |  | Enable only vertical padding |
| `noPadding` | Padding |  | Disable internal padding |
| `pill` | Shape |  | Fully rounded corners (circular) |
| `sharp` | Shape | yes | No rounded corners (square) |
| `rounded` | Shape |  | Medium rounded corners (default) |
| `noShrink` | Shrink |  | Prevent the flex item from shrinking below its content size (= `shrink-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 |
| `strongBorder` | Strong Border |  | Paint the border in the appearance's strong color instead of its soft one |
| `textLeft` | Text Align |  | 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) |
| `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 |

Layout and utility props (Border, Display, Flex Direction, Gap, Height, Hide, Items, Justify, Overflow, Pointer Events, Position, Responsive Sizing, Responsive Width, Ring, Shadow, Show, Transparent, Whitespace, Width, Wrap) are listed on [Common Props](https://vaneui.com/docs/reference/common-props.md).
