Components/Container
Since 1.0.0BETA

Container

Layout container with flexible options and responsive support

This page was migrated by AI, please review carefully

Migration is complete, but please validate against source code and manual review.

Container

Layout container with flexible options and responsive support

Basic Usage

Container

Demo will load when visible.
<template>
  <div style="width: 600px; border: 1px solid var(--tx-border-color); border-radius: 12px; overflow: hidden;">
    <TxContainer :padding="16">
      <TxRow :gutter="16">
        <TxCol :span="12">
          <div style="padding: 12px; border-radius: 10px; background: var(--tx-fill-color-light, #f5f7fa);">
            Left
          </div>
        </TxCol>
        <TxCol :span="12">
          <div style="padding: 12px; border-radius: 10px; background: var(--tx-fill-color-light, #f5f7fa);">
            Right
          </div>
        </TxCol>
      </TxRow>
    </TxContainer>
  </div>
</template>

Simplest container usage:

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

Container Types

Fluid Containers

Fill the full parent width:

EXAMPLE.VUE
<template>
  <TxContainer fluid>
    <p>Fluid container, width 100%</p>
  </TxContainer>
</template>

Fixed-width Containers

Set max width by breakpoints:

EXAMPLE.VUE
<template>
  <TxContainer max-width="1200px">
    <p>Container with max width 1200px</p>
  </TxContainer>
</template>

Responsive Containers

Different max widths across breakpoints:

EXAMPLE.VUE
<template>
  <TxContainer responsive>
    <p>Responsive container</p>
  </TxContainer>
</template>

Container Spacing

Padding

EXAMPLE.VUE
<template>
  <div class="padding-demo">
    <TxContainer padding="small">Small padding container</TxContainer>
    <TxContainer padding="medium">Medium padding container</TxContainer>
    <TxContainer padding="large">Large padding container</TxContainer>
    <TxContainer :padding="32">Custom padding container</TxContainer>
  </div>
</template>

Margin

EXAMPLE.VUE
<template>
  <TxContainer margin="auto">
    <p>Centered container</p>
  </TxContainer>
</template>

Grid System

Basic Grid

EXAMPLE.VUE
<template>
  <TxContainer>
    <TxRow>
      <TxCol :span="12">
        <div class="col-content">Left content</div>
      </TxCol>
      <TxCol :span="12">
        <div class="col-content">Right content</div>
      </TxCol>
    </TxRow>
  </TxContainer>
</template>

<style scoped>
.col-content {
  background: var(--tx-color-surface);
  padding: 16px;
  text-align: center;
  border-radius: 8px;
}
</style>

Grid Gutter

EXAMPLE.VUE
<template>
  <TxContainer>
    <TxRow :gutter="24">
      <TxCol :span="8">
        <div class="col-content">Column 1</div>
      </TxCol>
      <TxCol :span="8">
        <div class="col-content">Column 2</div>
      </TxCol>
      <TxCol :span="8">
        <div class="col-content">Column 3</div>
      </TxCol>
    </TxRow>
  </TxContainer>
</template>

Responsive Grid

EXAMPLE.VUE
<template>
  <TxContainer>
    <TxRow :gutter="{ xs: 8, sm: 16, md: 24, lg: 32 }">
      <TxCol :xs="24" :sm="12" :md="8" :lg="6">
        <div class="col-content">ResponsiveColumn 1</div>
      </TxCol>
      <TxCol :xs="24" :sm="12" :md="8" :lg="6">
        <div class="col-content">ResponsiveColumn 2</div>
      </TxCol>
      <TxCol :xs="24" :sm="12" :md="8" :lg="6">
        <div class="col-content">ResponsiveColumn 3</div>
      </TxCol>
      <TxCol :xs="24" :sm="12" :md="8" :lg="6">
        <div class="col-content">Responsive column 4</div>
      </TxCol>
    </TxRow>
  </TxContainer>
</template>

Layout Combinations

Page Layout

EXAMPLE.VUE
<template>
  <div class="page-layout">
    <!-- Header -->
    <TxContainer class="header" fluid>
      <TxRow align="middle" justify="space-between">
        <TxCol>
          <div class="logo">Logo</div>
        </TxCol>
        <TxCol>
          <nav class="nav">Navigation menu</nav>
        </TxCol>
      </TxRow>
    </TxContainer>
    
    <!-- Main content -->
    <TxContainer class="main-content">
      <TxRow :gutter="32">
        <TxCol :span="18">
          <main>Main content area</main>
        </TxCol>
        <TxCol :span="6">
          <aside>Sidebar</aside>
        </TxCol>
      </TxRow>
    </TxContainer>
    
    <!-- Footer -->
    <TxContainer class="footer" fluid>
      <footer>Footer content</footer>
    </TxContainer>
  </div>
</template>

<style scoped>
.header {
  background: var(--tx-color-surface);
  padding: 16px 0;
  border-bottom: 1px solid var(--tx-color-border);
}

.main-content {
  min-height: 500px;
  padding: 32px 0;
}

.footer {
  background: var(--tx-color-surface);
  padding: 24px 0;
  border-top: 1px solid var(--tx-color-border);
  text-align: center;
}
</style>

Card Layout

EXAMPLE.VUE
<template>
  <TxContainer>
    <TxRow :gutter="24">
      <TxCol :xs="24" :sm="12" :lg="8" v-for="item in items" :key="item.id">
        <TxCard>
          <h3>{{ item.title }}</h3>
          <p>{{ item.description }}</p>
        </TxCard>
      </TxCol>
    </TxRow>
  </TxContainer>
</template>

API Reference

Container Props

PropTypeDefaultDescription
fluidbooleanfalseRemoves the max-width cap and lets the container fill its parent.
maxWidthstring'1200px'Max width used when fluid is disabled.
responsivebooleanfalseEnables the built-in responsive container width classes.
padding'small' | 'medium' | 'large' | number'medium'Horizontal padding preset or pixel value.
margin'auto' | string | number'auto'Horizontal margin; auto centers the container.

Row Props

PropTypeDefaultDescription
gutternumber | Partial<Record<'xs' | 'sm' | 'md' | 'lg' | 'xl', number>>0Column gutter in pixels, optionally selected by breakpoint.
align'top' | 'middle' | 'bottom' | 'stretch''stretch'Vertical alignment for row children.
justify'start' | 'end' | 'center' | 'space-around' | 'space-between' | 'space-evenly''start'Horizontal distribution for row children.
wrapbooleantrueAllows columns to wrap onto multiple lines.

Col Props

PropTypeDefaultDescription
spannumber24Number of columns occupied in the 24-column grid.
offsetnumber0Left offset in the 24-column grid.
xsnumber-Span used below 640px.
smnumber-Span used from 640px to 767px.
mdnumber-Span used from 768px to 1023px.
lgnumber-Span used from 1024px to 1279px.
xlnumber-Span used at 1280px and above.

Responsive Breakpoints

TouchX UI uses the following breakpoints:

EXAMPLE.CSS
/* Extra small screens */
@media (max-width: 639px) { /* xs */ }

/* Small screens */
@media (min-width: 640px) { /* sm */ }

/* Medium screens */
@media (min-width: 768px) { /* md */ }

/* Large screens */
@media (min-width: 1024px) { /* lg */ }

/* XL screens */
@media (min-width: 1280px) { /* xl */ }

Style Customization

CSS Variables

EXAMPLE.CSS
.custom-container {
  --tx-container-max-width: 1200px;
  --tx-container-padding: 16px;
  --tx-row-gutter: 16px;
}

Best Practices

Usage Tips

  1. Responsive first: prefer the responsive grid system
  2. Semantic layout: use semantic HTML tags
  3. Consistent spacing: keep spacing rules consistent
  4. Performance: avoid excessive container nesting

Common Layout Patterns

EXAMPLE.VUE
<template>
  <!-- Centered content -->
  <TxContainer max-width="800px" margin="auto">
    <div class="content">Main content</div>
  </TxContainer>
  
  <!-- Content with sidebar -->
  <TxContainer>
    <TxRow :gutter="32">
      <TxCol :span="16">Article content</TxCol>
      <TxCol :span="8">Sidebar</TxCol>
    </TxRow>
  </TxContainer>
  
  <!-- Three-column layout -->
  <TxContainer>
    <TxRow :gutter="24">
      <TxCol :span="6">Navigation</TxCol>
      <TxCol :span="12">Main content</TxCol>
      <TxCol :span="6">Details</TxCol>
    </TxRow>
  </TxContainer>
</template>

TouchX UI containers provide flexible layouts to quickly build responsive page structures.