Skip to content

Responsive Layout ​

No breakpoints to learn. Stack components the way you would on the web — SGrid, SColumns, SFlow and every SparkUI component measure the space they actually get and lay themselves out.

arkts
SGrid({ minItemWidth: 200 }) {          // no breakpoints: columns follow the width
  SGridItem() { StatCard(...) }
  SGridItem() { StatCard(...) }
  SGridItem({ span: 2 }) { ... }        // spans 2 columns when there are 2+
}

SColumns({ minColumnWidth: 280 }) {     // side by side, or stacked when narrow
  SColumn({ weight: 2 }) { SCard() { ... } }
  SColumn() { SCard() { ... } }
}

Primitives ​

PrimitiveWeb equivalentNotes
SGrid({ minItemWidth, gap, maxColumns })repeat(auto-fill, minmax(x, 1fr))Automatic column count; SGridItem({ span, full }) spans.
SColumns({ minColumnWidth, gap }) + SColumn({ weight })wrapping flex columnsSide by side (weighted) when they fit, stacked otherwise.
SFlow({ gap, justify })flex-wrap: wrapWraps automatically.
SStack({ gap, alignment }) / SRow({ gap, justify })flex column / rowGaps from tokens.
SPage({ title, description, maxWidth, safeArea })page containerAdaptive margins, max width, optional safe area and scrolling.

Resize the browser window to see the preview reflow:

Approximate web preview — the HarmonyOS rendering is the reference.

Why SGridItem / SColumn wrappers? ​

An ArkUI parent cannot size arbitrary children (slot content in particular): Grid / List / WaterFlow require specific child types and a Flex child's flexBasis can only be set by the child itself. Grid cells and columns therefore need a thin wrapper — the <div class="col"> of the web.

Components adapt too ​

Components tune details to the width they get:

  • SCard tightens its padding from 24 to 16 below 360vp;
  • SField puts the label beside the control when wide and above it when narrow (orientation: 'responsive');
  • STabsList scrolls horizontally when it doesn't fit, SPagination shows only previous / page / next when narrow;
  • SItem moves its actions under the text below 360vp;
  • overlays become bottom drawers on compact touch screens (see Overlays).

For window-level signals (input modality, fold posture) see Adaptive Context.

MIT Licensed