block

row

Wire value: "row"

Appears on: Documentation Topic, Tutorial (Project), Tutorial Article

1. How swift-docc-render consumes this

Grepping src/components/ for the literal string 'row' lands on src/components/ContentNode.vue's wire-constant table (ContentNode.vue#L37-L54), whose row key holds BlockType.row = 'row' (line 50). That constant is matched in the renderNode() factory function's switch (node.type) dispatch table:

case BlockType.row: {
  const columns = node.numberOfColumns ? { large: node.numberOfColumns } : undefined;
  return createElement(
    Row, { props: { columns } }, node.columns.map(col => (
      createElement(
        Column, { props: { span: col.size } }, renderChildren(col.content),
      )
    )),
  );
}

(ContentNode.vue#L395-L404.) Two dedicated child components are imported at the top of the file — Column from ./ContentNode/Column.vue (line 27) and Row from ./ContentNode/Row.vue (line 28) (ContentNode.vue#L27-L28). Only node.numberOfColumns and, per-column, col.size and col.content are forwarded; the kind discriminator is consumed only by the switch and never passed through. Note that numberOfColumns is mapped exclusively onto the large breakpoint slot of the columns prop — the wire data does not distinguish per-breakpoint column counts, so medium/small behavior comes entirely from the Row component's own defaults, not from anything in the RenderNode.

Row.vue's template is a single wrapper <div class="row"> that renders its default slot (the mapped Column elements) and exposes an optional columns prop (an object keyed by breakpoint name, validated against BreakpointName) and an optional gap prop, both consumed purely as CSS custom properties:

<div class="row" :style="style" :class="{ 'with-columns': columns }">
  <slot />
</div>

style: ({ columns = {}, gap }) => ({
  '--col-count-large': columns.large,
  '--col-count-medium': columns.medium,
  '--col-count-small': columns.small || 1,
  '--col-gap': gap && `${gap}px`,
}),

(Row.vue#L10-L46.) Row has no JavaScript state of its own beyond this computed inline-style object; all layout behavior (equal-width columns by default, exact column counts when columns is supplied, stacking to a single column at the small breakpoint) is delegated entirely to CSS grid, described in Section 4. Column.vue is equally thin — a <div class="column"> wrapping its slot, with a single span prop (default null) turned into a --col-span custom property (Column.vue#L10-L29). Each column's inner content is recursively rendered via renderChildren(), the same block-content dispatcher used everywhere else in ContentNode.vue, so a column can legally contain any other block kind — paragraphs, images, further nested rows, etc.

2. Example JSON and rendered mockup

No fixture containing a "kind": "row" RenderNode was found in Tests/DocCArchiveTests/Fixtures/ (ExampleDocs.doccarchive and SampleLibrary.doccarchive only reference the string inside bundled/minified DocC-render JavaScript, not in any data/ RenderNode JSON), nor in swift-project/swift-docc/Tests/SwiftDocCTests/ as rendered-JSON output (that suite only has authoring-side Markdown fixtures using @Row/@Column directives, e.g. Test Bundles/BookLikeContent.docc/MyArticle.md, and a unit test, Tests/SwiftDocCTests/Semantics/Reference/RowTests.swift, that exercises the directive parser rather than a captured RenderNode). The example below is therefore hand-written to match the confirmed schema (Section 3), deliberately restricted to the fields present in the vendored spec — it omits the Swift-side-only alignment field discussed in Section 3's drift note.

{
  "kind": "row",
  "numberOfColumns": 3,
  "columns": [
    {
      "size": 1,
      "content": [
        { "kind": "paragraph", "inlineContent": [ { "type": "text", "text": "Ice power" } ] }
      ]
    },
    {
      "size": 1,
      "content": [
        { "kind": "paragraph", "inlineContent": [ { "type": "text", "text": "Fire power" } ] }
      ]
    },
    {
      "size": 1,
      "content": [
        { "kind": "paragraph", "inlineContent": [ { "type": "text", "text": "Wind power" } ] }
      ]
    }
  ]
}
Ice power
Fire power
Wind power

mockup: three columns of equal size: 1 render as three equal-width CSS grid tracks (grid-template-columns: repeat(3, 1fr), driven by numberOfColumns: 3 via the --col-count-large custom property). At the small breakpoint this collapses to a single stacked column (see Section 4) regardless of numberOfColumns.

3. Data sheet

Source: Sources/DocCArchive/Vendored/RenderNode.spec.json, schema object #/components/schemas/Row (lines 571–593) and its nested #/components/schemas/Column (lines 594–611), cross-checked against Components.Schemas.Row and Components.Schemas.Column in Sources/DocCArchive/generated/Types.swift (lines 3905–3937 and 3938–3960 respectively). Row is one arm of the RenderBlockContent discriminated union (referenced at spec line 432).

FieldTypeRequiredEnum values / defaultNote
kind string yes "row" (single-value enum) Generated as KindPayload: String, Codable, Hashable, Sendable, CaseIterable { case row = "row" }, decoded/encoded under the Swift property name kind (no renaming needed here, unlike some sibling kinds that use type on the wire).
columns array of Column yes — Generated as [Components.Schemas.Column]. Each Column is itself an object with required content (array of RenderBlockContent) and required size (number) — see the two rows below. The Column schema object has no kind/ type discriminator of its own; it's only ever reached by way of the parent Row.
numberOfColumns number yes — (no schema-level constraint) Generated as plain Swift.Double, unconstrained. As documented on the swift-docc production side (see below), this is not always equal to columns.count — it may exceed it if the row is not fully filled, or be smaller if individual columns span more than one column via their own size.
columns[].content array of RenderBlockContent yes — Recursive: any other block-content kind (including a nested row) can appear inside a column.
columns[].size number yes — (no schema-level constraint) Generated as plain Swift.Double. Consumed by DocC-render as the Column component's span prop, becoming the CSS --col-span custom property (see Section 4).

Schema/production drift worth flagging explicitly: swift-docc's production-side Swift model, RenderBlockContent.Row.Column (Sources/SwiftDocC/Model/Rendering/Content/RenderBlockContent.swift, lines 793–812), declares a third, required member on Column that does not appear anywhere in the vendored RenderNode.spec.json's Column schema:

public struct Column: Equatable {
    public var size: Int
    public var alignment: Alignment          // NOT present in Sources/DocCArchive/Vendored/RenderNode.spec.json
    public var content: [RenderBlockContent]

    public enum Alignment: String, Codable, Equatable {
        case leading, center, trailing
    }
}

This struct conforms to Codable (synthesized, since every member is itself Codable), so a real archive built with a swift-docc that supports the alignment argument (introduced in Swift-DocC 6.4, per the doc comment on Semantics/Reference/Row.swift's Column directive) would emit a required "alignment": "leading"|"center"|"trailing" field on every column object on the wire. The vendored spec this repository ships predates that addition, and the generated Components.Schemas.Column Swift type in this repository has no alignment member at all — so decoding a current-swift-docc archive containing that field with this repository's generated types would silently ignore the extra JSON key (OpenAPI-generator-produced Decodable conformances ignore unrecognized keys by default) rather than fail, but round-tripping/re-encoding would drop it. This is a genuine, verified staleness in the vendored schema, not speculation: grepping swift-docc-render at the pinned commit confirms Column.vue and ContentNode.vue only ever read col.size, never col.alignment, for the row kind (unlike Table, whose alignments array is genuinely wired up to cell classes) — so even on the render side at this pinned commit, an alignment value would currently have no visible effect if it were present.

On the swift-docc production side (secondary/flavor source, not authoritative for wire shape), the enclosing enum case is case row(Row) (Sources/SwiftDocC/Model/Rendering/Content/RenderBlockContent.swift, line 66: "A row in a grid-based layout system that describes a collection of columns"), and the Row struct itself is declared at lines 781–813 of the same file, matching numberOfColumns and columns field-for-field with the wire schema (modulo the alignment drift noted above). Authoring-side, a row node is what the @Row/@Column block directives compile to (Sources/SwiftDocC/Semantics/Reference/Row.swift, lines 14–45 for the doc comment and example, lines 174–194 for the RenderableDirectiveConvertible conformance that actually builds the RenderBlockContent.Row value): an author nests one or more @Column directives inside an @Row directive, optionally supplying numberOfColumns on the row and size/alignment on each column; if numberOfColumns is omitted, swift-docc computes it as the sum of the columns' size values (Row.swift, line 72).

DocCArchive's own transform layer does not yet do anything with this kind: MyHTMLTransformer and MyMarkdownTransformer (Sources/DocCArchive/DocCArchive.swift, lines 242–254) are still stub placeholders that return a hardcoded HTML comment and an empty string respectively for an entire RenderNode, with no per-block-kind switch reached yet — so a row node parsed via Components.Schemas.Row is available on the decoded model today, but nothing in this repository currently converts it into HTML or Markdown output.

4. HTML/CSS mapping in DocC-Render output

Rendered DOM for a row node, in context:

SCSS: Row.vue's scoped style block (Row.vue#L49-L79):

.row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  grid-gap: var(--col-gap, #{$article-stacked-margin-small});

  @include breakpoint(small) {
    grid-template-columns: 1fr;
    grid-auto-flow: row;
  }

  &.with-columns {
    --col-count: var(--col-count-large);
    grid-template-columns: repeat(var(--col-count), 1fr);
    grid-auto-flow: row;

    @include breakpoint(medium) {
      --col-count: var(--col-count-medium, var(--col-count-large));
    }
    @include breakpoint(small) {
      --col-count: var(--col-count-small);
    }
  }

  @include space-out-between-siblings(var(--spacing-stacked-margin-xlarge));
}

and Column.vue's scoped style block (Column.vue#L31-L41):

.column {
  grid-column: span var(--col-span);
  min-width: 0;
  @include breakpoint(small) {
    grid-column: span 1;
  }
}

Without an explicit column count (numberOfColumns absent/zero on the wire, so no .with-columns class), .row falls back to an auto-flowing grid with grid-auto-columns: 1fr, effectively splitting width equally across however many .column children exist. With .with-columns applied, grid-template-columns: repeat(var(--col-count), 1fr) forces exactly numberOfColumns equal-width tracks, and each column's own grid-column: span var(--col-span) lets a column occupy more than one of those tracks. At the small breakpoint (@include breakpoint(small), from src/styles/core/_breakpoints.scss, lines 129–140, which compiles to a max-width media query), both rules collapse: the row switches to a single column (grid-template-columns: 1fr; grid-auto-flow: row) and every column is forced to grid-column: span 1, i.e. mobile layouts always stack rows regardless of what numberOfColumns/size said. Vertical spacing between stacked/sibling row content comes from the shared space-out-between-siblings() mixin (src/styles/core/_helpers.scss, lines 299–303).

CSS custom properties consumed: --col-count-large, --col-count-medium, --col-count-small (all set inline by Row's style computed property from the columns prop), the derived --col-count, --col-gap (falls back to the Sass constant $article-stacked-margin-small when the optional gap prop is absent — note gap is never populated from RenderNode JSON, only columns is), --spacing-stacked-margin-xlarge for inter-sibling spacing, and, on the column side, --col-span (set from the column's size).

5. Modern CSS-only alternative

Not applicable

Current behavior in play: both Row.vue and Column.vue are stateless presentational wrappers. Neither component holds any reactive data(), computes anything from user interaction, or attaches any event listener; their only JavaScript logic is a one-time computed: { style } mapping from static props (columns, gap, span) to CSS custom properties, evaluated once per render and never mutated in response to clicks, hovers, or other runtime events. All of the actual layout behavior — equal-width columns by default, exact grid-template column counts when specified, responsive collapse to a single stacked column at the small breakpoint — is already implemented with plain CSS Grid (display: grid, grid-template-columns, grid-column: span N) and a Sass breakpoint mixin that compiles to an ordinary max-width media query. There is no interactive/stateful behavior here for a native HTML mechanism (<details>, :target, the Popover API, <dialog>, :has(), container queries, anchor positioning, view transitions) to replace, because nothing is being toggled, shown/hidden, or held as state in the first place — the row kind is a purely declarative, always-visible grid layout container. The only thing a "modern CSS" pass could even discuss is whether container queries could replace the current viewport-width breakpoint mixin with a container-relative one, but that would be a change to an unrelated, orthogonal concern (viewport- vs. container-relative breakpoints), not a replacement of any JS-held state, so it does not change the verdict.