Inference Logoinference.sh

Box

Flexible container for layout and surface styling with full control.

Preview

code
12  Inside a box       3  with padding       4  and background     5

Usage

go
1node := models.WidgetNode{2    Type:       models.WidgetNodeTypeBox,3    Padding:    4,4    Background: "surface-secondary",5    Radius:     "md",6    Children: []models.WidgetNode{7        {Type: models.WidgetNodeTypeText, Value: "Content"},8    },9}

Props

NameTypeDescriptionDefault
type"box"Node typerequired
childrenWidgetNode[]Child components-
direction"row" | "col"Flex direction"col"
alignstringCross-axis alignment: start, center, end, baseline, stretch-
justifystringMain-axis distribution: start, center, end, between, around, evenly-
wrapstringWrap behavior: nowrap, wrap, wrap-reverse-
flexstring | numberFlex grow/shrink factor-
gapnumber | stringGap between children-
paddingnumber | string | objectInner padding-
marginnumber | string | objectOuter margin-
bordernumber | objectBorder styling-
backgroundstring | ThemeColorBackground color-
radiusstringBorder radius token-
heightnumber | stringExplicit height-
widthnumber | stringExplicit width-
minHeightnumber | stringMinimum height-
maxWidthnumber | stringMaximum width-
aspectRationumber | stringAspect ratio (e.g., 16/9)-

Background Tokens

Surface colors:

  • surface - Default background
  • surface-secondary - Slightly offset
  • surface-tertiary - More offset
  • surface-elevated - Raised appearance
  • surface-elevated-secondary - Raised + offset

Primitive colors:

  • red-100 through red-900
  • blue-100 through blue-900
  • gray-100 through gray-900
  • etc.

Radius Tokens

2xs, xs, sm, md, lg, xl, 2xl, 3xl, 4xl, full, none

Examples

Card-like Container

go
1{2    Type:       models.WidgetNodeTypeBox,3    Padding:    4,4    Background: "surface-secondary",5    Radius:     "lg",6    Border:     1,7    Children: []models.WidgetNode{8        {Type: models.WidgetNodeTypeTitle, Value: "Card Title"},9        {Type: models.WidgetNodeTypeText, Value: "Card content goes here"},10    },11}

Centered Content

go
1{2    Type:    models.WidgetNodeTypeBox,3    Align:   "center",4    Justify: "center",5    Height:  200,6    Children: []models.WidgetNode{7        {Type: models.WidgetNodeTypeText, Value: "Centered!"},8    },9}

With Border

go
1{2    Type:    models.WidgetNodeTypeBox,3    Padding: 3,4    Border: map[string]interface{}{5        "size":  1,6        "color": "subtle",7        "style": "dashed",8    },9    Radius: "md",10    Children: []models.WidgetNode{11        {Type: models.WidgetNodeTypeText, Value: "Dashed border"},12    },13}

Horizontal with Spacing

go
1{2    Type:      models.WidgetNodeTypeBox,3    Direction: "row",4    Gap:       4,5    Align:     "center",6    Justify:   "between",7    Children: []models.WidgetNode{8        {Type: models.WidgetNodeTypeText, Value: "Left"},9        {Type: models.WidgetNodeTypeText, Value: "Right"},10    },11}

Box vs Row vs Col

Use...When...
BoxNeed full layout control (background, border, sizing)
RowSimple horizontal layout
ColSimple vertical layout

TypeScript

typescript
1const node: WidgetNode = {2  type: "box",3  padding: 4,4  background: "surface-secondary",5  radius: "md",6  children: [7    { type: "text", value: "Content" },8  ],9}

Best Practices

  1. Use for styled containers - When you need background/border/radius
  2. Use Row/Col for simple layouts - Less verbose
  3. Be mindful of nesting - Deep box nesting hurts readability
  4. Use semantic backgrounds - Surface tokens adapt to themes

we use cookies

we use cookies to ensure you get the best experience on our website. for more information on how we use cookies, please see our cookie policy.

by clicking "accept", you agree to our use of cookies.
learn more.