[data-reveal]{opacity:1!important;transform:none!important}
AntelopeJS DMS
DocumentationLayout and containers

Layout and containers

Grid, stacks, tabs, guard, placeholder and the page layouts that hold every other component.

Overview

Layout components hold other components. They come in two kinds.

What you want to changeUse
The frame around a page: dashboard, settings, or no navigationA page layout (DefaultLayout, SettingsLayout, EmptyLayout).
The arrangement of blocks inside the pageA container builder (Grid, stacks, or tabs).

See the settings-page screenshot for the frame and the container previews for the blocks inside it. The reference below gives their exact contracts.

Containers are builders: Grid, GridRow, HStack, VStack, Spacer, Tab, Guard and Placeholder return a ComponentBuilder, and you nest components inside them with .child(id, component). They are assigned to a static field of a page class like any other component.

Page layouts are not builders: DefaultLayout, FormPageLayout, SettingsLayout and EmptyLayout return a plain ComponentInfo and are passed as the third argument of PageController, or as the layout option of a page or category (the default of everything declared under it), to say how the page's chrome is drawn.

CustomComponent sits outside both: it names a Vue component from the frontend registry and gives you a builder for it, which is the escape hatch when the vocabulary on this page is not enough.

typescript
import { Grid, GridRow } from "@antelopejs/interface-dms/base/grid";
import { HStack, Spacer, VStack } from "@antelopejs/interface-dms/base/stack";
import { Tab } from "@antelopejs/interface-dms/base/tab";
import { Guard } from "@antelopejs/interface-dms/base/guard";
import { DefaultLayout, EmptyLayout, FormPageLayout, SettingsLayout } from "@antelopejs/interface-dms/base/layouts";
import { Placeholder } from "@antelopejs/interface-dms/base/placeholder";
import { CustomComponent } from "@antelopejs/interface-dms/base/custom";

Grid, GridRow, HStack, VStack, Spacer, Tab, Guard, Placeholder, DefaultLayout, FormPageLayout, SettingsLayout and EmptyLayout are also exported from the base barrel. CustomComponent is only exported from @antelopejs/interface-dms/base/custom.

Grid

Grid is a container whose direct children are GridRows. The number of columns follows the widest row.

typescript
import { Grid, GridRow } from "@antelopejs/interface-dms/base/grid";
import { KpiCard } from "@antelopejs/interface-dms/base";

static kpis = Grid({ gap: "1rem" }).child(
  "kpiRow",
  GridRow()
    .child("proposed", KpiCard({ title: "Proposed", fetchUrl: "/metrics/proposed" }))
    .child("approved", KpiCard({ title: "Approved", fetchUrl: "/metrics/approved" }))
    .child("denied", KpiCard({ title: "Denied", fetchUrl: "/metrics/denied" })),
);

GridOptions:

OptionTypeDescription
gapstringGap between rows and columns, as a CSS length. Defaults to "1rem".
minColumnWidthstringWidth below which a column is dropped rather than squeezed. Defaults to "240px".

GridRow() takes no options. Its children are laid out horizontally within the row.

.child() accepts a third argument of extra metadata, which is carried verbatim onto the serialized child alongside its id. That is how a child declares that it spans more than one column:

typescript
GridRow().child("chart", chartCard, { colSpan: 2 }).child("list", topListCard);

Stacks

HStack and VStack arrange their children along one axis; Spacer fills the leftover space between them.

typescript
import { HStack, Spacer } from "@antelopejs/interface-dms/base/stack";

static toolbar = HStack({ alignment: "center", distribution: "space-between", spacing: "16px" })
  .child("title", titleComponent)
  .child("gap", Spacer())
  .child("actions", actionsComponent);

StackAlignment is "start" | "center" | "end" | "stretch" and StackDistribution is "start" | "center" | "end" | "space-between" | "space-around" | "space-evenly".

HStackOptions

OptionTypeDescription
alignmentStackAlignmentVertical alignment of children. Defaults to "center".
distributionStackDistributionHorizontal distribution of children. Defaults to "start".
spacingstringSpace between children, as a CSS length. Defaults to "8px".
wrapbooleanWrap children onto the next line when the row runs out of space. Defaults to false.
grownumberShare of the parent stack's free space this stack takes, against its siblings. Unset, a stack nested in an HStack shares the row equally with its sibling stacks, or keeps its content width when the row has a Spacer.

VStackOptions

OptionTypeDescription
alignmentStackAlignmentHorizontal alignment of children. Defaults to "center".
distributionStackDistributionVertical distribution of children. Defaults to "start".
spacingstringSpace between children, as a CSS length. Defaults to "8px".
grownumberShare of the parent stack's free space this stack takes, against its siblings. Unset, a stack nested in an HStack shares the row equally with its sibling stacks, or keeps its content width when the row has a Spacer.

SpacerOptions

OptionTypeDescription
minSizestringMinimum size, as a CSS length. No minimum by default.
maxSizestringMaximum size, as a CSS length. No maximum by default.
grownumberFlex grow factor. Defaults to 1.

The three builders apply their defaults into the options they carry, so a Spacer() with no arguments still ships { grow: 1 }.

Tabs

Tab declares a tab bar. Each TabItem names a slot, and the component that belongs in a tab is attached as a child with that slot.

typescript
import { Tab, TabVariant } from "@antelopejs/interface-dms/base/tab";
import { Color, Size } from "@antelopejs/interface-dms/base/types";

static tabs = Tab({
  items: [
    { label: "Overview", slot: "overview", icon: "i-ph-gauge" },
    { label: "Members", slot: "members", icon: "i-ph-users", badge: 12 },
  ],
  variant: TabVariant.pill,
  color: Color.primary,
  size: Size.medium,
  persistState: true,
  stateKey: "tenant-tabs",
})
  .child("overview", overviewComponent, { slot: "overview" })
  .child("members", membersTable, { slot: "members" });

TabProps

TabProps extends BaseComponentProps.

OptionTypeDescription
itemsTabItem[]The tabs. Required.
colorColorColour of the active tab.
sizeSizeControl size.
variantTabVariantTabVariant.pill or TabVariant.link.
orientationAxeOrientationDirection of the tab bar.
fitbooleanA horizontal pill list as wide as its tabs instead of the full width; a link list already sizes its tabs to their labels. Defaults to false.
unmountOnHidebooleanDiscard a tab's content when it is not active.
persistStatebooleanKeep the active tab in the URL by its slot (?<stateKey>=<slot>); an index (?tab=2) is still read.
stateKeystringKey the state is stored under.

TabItem

FieldTypeDescription
labelstringTab label. Required.
slotstringSlot name the tab's content is attached to. Required.
iconstringLeading icon.
badgeBlockText | number | BadgePropsBadge on the tab; a $ key, a ComposedText and a BadgeProps label are translated.
disabledbooleanMake the tab unselectable.
shortcutstringKeyboard shortcut.
avatar{ src?: string; alt?: string; size?: Size }Leading avatar.

BadgeProps is { label?: string | number; color?: string; variant?: "solid" | "outline" | "soft" | "subtle"; size?: Size }. Note that its variant union is its own, narrower than ButtonVariant.

TabEvents.TAB_CHANGE is "DmsComponent.Tab.Change".

Guard

Guard is a container that renders its children unchanged unless a route says there is nothing for them; then it renders one EmptyState, its fallback, in their place. Several children stack with the spacing the page puts between its blocks.

typescript
import { Guard } from "@antelopejs/interface-dms/base/guard";

static statistics = Guard({
  fetchUrl: "/api/routes/activity?route={{query.route}}", // { calls: 0 }
  periodScope: "api",
  field: "calls",
  fallback: {
    title: "$api.routes.statistics.idle_title",
    actions: [{ label: "$api.routes.test", to: "/modules/api/routes?tab=tester" }],
  },
}).child("charts", statisticsGrid);

GuardOptions:

OptionTypeDescription
fetchUrlstringThe route read. It takes the {{params.X}} / {{query.X}} tokens of a block's fetchUrl; nothing is requested while one has no value.
fetchUrlMethodHttpMethodMethod of the request.
periodScopestringId of the PeriodSelector the route is read with, again on each change.
realtimeTopicstring | string[]Topics whose events make the guard read the route again.
whenGuardCondition"empty" (the default): the value at field is absent, null, false, 0, "" or []. "notFound": the route answers 404.
fieldstringDot path of the value "empty" checks; the whole answer without it.
fallbackGuardFallbackAn EmptyState's options without watchActions, all optional. The title defaults to "Nothing to show yet", or "Not found" for "notFound", in the reader's language; for "notFound" the description defaults to the 404 body's message, as for a block.

An emptyState object in the answer, or in the body of the 404, is laid over fallback. The children show while the route loads, after any failure other than the condition, and whenever the value is set. The guide is Layout & containers.

Placeholder

Placeholder renders a labelled box. It exists so a layout can be assembled and reviewed before the real components are written. It takes PlaceholderOptions:

typescript
import { Placeholder } from "@antelopejs/interface-dms/base/placeholder";

static preview = Placeholder({ label: "Chart goes here", height: "200px" });
OptionTypeDescription
labelstringText shown in the box.
heightstringCSS height. Defaults to "120px".
widthstringCSS width. Auto by default.

CustomComponent

CustomComponent(componentName) returns a bare ComponentBuilder for a frontend component resolved by name. Nothing else in the base domain is involved: the options you pass with .options() are handed to that component as-is, and the component itself comes from a frontend module registered with AddFrontendModule.

typescript
import { CustomComponent } from "@antelopejs/interface-dms/base/custom";

static changes = CustomComponent("DmsAssistantChangesView").meta({
  name: "Changes",
  icon: "i-ph-git-diff",
});

Since the return value is an ordinary builder, .options(), .child(), .meta(), .watch(), .onCreated() and .onFilter() all apply, and the component can hold base components as children.

CustomComponent is also how a table view's formContainer.pages.*.customPage option is used: you register your own page carrying a custom component at the slug the table view would otherwise generate. Declare that slug as the entry's urlSlug, which is taken relative to the page as it stands. See Tables.

Next steps

  • Page layouts: The layouts a page renders in, its header actions, and pages that fill the panel.