Components/Container

Container

A width-limited, padded container with a 24-column grid.

VerifiedSince 0.3.4

Usage

EXAMPLE.VUE
<template>
  <TxContainer>
    <p>Content inside the container</p>
  </TxContainer>
</template>

Basic

TxContainer owns the max width and side padding; TxRow / TxCol change column spans by breakpoint.

Loading demo...

Width

fluid fills the parent, maxWidth caps the width, and responsive switches the cap by breakpoint.

EXAMPLE.VUE
<template>
  <TxContainer fluid>Fluid container, 100% wide</TxContainer>
  <TxContainer max-width="1200px">Max width 1200px</TxContainer>
  <TxContainer responsive>Responsive container</TxContainer>
</template>

Spacing

EXAMPLE.VUE
<template>
  <TxContainer padding="small">Small padding</TxContainer>
  <TxContainer padding="large">Large padding</TxContainer>
  <TxContainer :padding="32">Custom padding</TxContainer>
  <TxContainer margin="auto">Horizontally centered</TxContainer>
</template>

Grid

EXAMPLE.VUE
<template>
  <TxRow>
    <TxCol :span="12">Left content</TxCol>
    <TxCol :span="12">Right content</TxCol>
  </TxRow>

  <TxRow :gutter="{ xs: 8, sm: 16, md: 24, lg: 32 }">
    <TxCol v-for="n in 4" :key="n" :xs="24" :sm="12" :md="8" :lg="6">
      Responsive column {{ n }}
    </TxCol>
  </TxRow>
</template>

Best Practices

  • Use one TxContainer per page section; nested containers make width and padding hard to reason about.
  • Change layouts with xs–xl instead of duplicating markup per breakpoint.
  • Match gutter to the page spacing scale; don't mix large gutters with tiny column padding in one row.
  • All three components render neutral divs; put semantic elements (main, aside, nav, section) inside them.
  • Set wrap=false only for horizontally scrolling or fixed-width toolbars.

API Reference

TxContainer

Props

PropTypeDefaultDescription
fluidbooleanfalseRemoves the max width and fills the parent.
maxWidthstring'1200px'Maximum width.
responsivebooleanfalseSwitches the max width by breakpoint: 640 / 768 / 1024 / 1280px.
padding'small' | 'medium' | 'large' | number'medium'Side padding: presets of 12 / 16 / 24px, or pixels clamped at 0.
margin'auto' | string | number'auto'Side margin; auto centers, other values apply as 0 <value>.

Slots

SlotPropsDescription
default-Content constrained by the max width and padding.

TxRow

Props

PropTypeDefaultDescription
gutternumber | Partial<Record<'xs' | 'sm' | 'md' | 'lg' | 'xl', number>>0Column spacing in px, optionally per breakpoint.
align'top' | 'middle' | 'bottom' | 'stretch''stretch'Vertical alignment of the columns.
justify'start' | 'end' | 'center' | 'space-around' | 'space-between' | 'space-evenly''start'Horizontal distribution of the columns.
wrapbooleantrueAllows wrapping.

Slots

SlotPropsDescription
default-TxCol children or other flex items.

TxCol

Props

PropTypeDefaultDescription
spannumber24Columns spanned, out of 24.
offsetnumber0Columns of offset on the left.
xsnumber-Span at the xs breakpoint (< 640px).
smnumber-Span at the sm breakpoint (≥ 640px).
mdnumber-Span at the md breakpoint (≥ 768px).
lgnumber-Span at the lg breakpoint (≥ 1024px).
xlnumber-Span at the xl breakpoint (≥ 1280px).

Slots

SlotPropsDescription
default-Column content.

Overview

  • Breakpoint values carry upward: an unset breakpoint takes the nearest smaller one's value; with none set, TxCol uses span and TxRow uses 0.
  • TxRow writes the active gutter to --tx-row-gutter; each column takes half as left and right padding, and the row cancels the outer halves with negative margins.
  • span and offset are clamped to 0–24.

Technologies

  • Breakpoints follow window.innerWidth and update on resize, regardless of the container's own width.
  • The row is calc(100% + var(--tx-row-gutter)) wide so that, with its negative margins, the outer columns line up with the container padding.
  • Source: packages/tuffex/packages/components/src/container/.
查看源码
packages/tuffex/packages/components/src/container/index.ts

Customization

VariableWritten byPurpose
--tx-container-max-widthmaxWidth / fluidMaximum width.
--tx-container-paddingpaddingSide padding.
--tx-row-guttergutterColumn spacing.

Props write all three as inline styles on the root; adjust them through the props.