Widgets

/

interact

Link

Navigates to a page or URL.

To a page, or away

Link navigates. to names a Page of your app (it opens without a reload), href a URL; external: true opens it in a new tab. A Link holds text (label) or any object, so a whole card can be a link.

LAYROpen in playground
Page(
  .name(Home)
  .route('/')
  Scaffold(
    .config(color: canvas)
    .body(
      Column(
        .config(
          gap: 14
          padding: all(24)
        )
        Link(
          .config(
            label: 'Read about the studio'
            to: About
          )
        )
        Link(
          .config(
            external: true
            href: 'https://github.com/nishanbhuinya/layr'
            label: 'LAYR on GitHub'
          )
        )
        Link(
          .config(
            to: About
            underline: false
          )
          .obj(
            Container(
              .config(
                w: 280
                color: panel
                cornerRadius: 12
                padding: all(16)
                .border(
                  color: line
                  width: 1
                )
              )
              .obj(
                Column(
                  .config(gap: 4)
                  Text(
                    .config(weight: semibold)
                    .obj('Room B')
                  )
                  Text(
                    .config(
                      size: 13
                      color: muted
                    )
                    .obj('The whole card is the link.')
                  )
                )
              )
            )
          )
        )
      )
    )
  )
)

Page(
  .name(About)
  .route('/about')
  Scaffold(
    .config(color: canvas)
    .body(
      Column(
        .config(
          gap: 12
          padding: all(24)
        )
        Text('About the studio')
        Link(
          .config(
            label: '← Back'
            to: Home
          )
        )
      )
    )
  )
)

Config keys

KeyTypeDefaultMeaning
w (width)len | fill | hugWidth: a length, fill (share the remaining space) or hug (fit content, default).
h (height)len | fill | hugHeight: a length, fill or hug (default).
size (s)sizeWidth and height together: size: 200 or size: (200, 120).
minW (minWidth)lenMinimum width.
maxW (maxWidth)lenMaximum width.
minH (minHeight)lenMinimum height.
maxH (maxHeight)lenMaximum height.
aspect (aspectRatio)numAspect ratio (width / height), e.g. 16/9.
color (bg, background, colorBG)paintBackground paint: a colour or gradient. Text inside reads on it: dark ink on light paint, light ink on dark, unless the text or textColor sets a colour.
textColor (fg, foreground)colorThe colour of text inside, where a Text sets none of its own. Without it, text picks the readable ink for this object's color.
padding (pad)insetsSpace inside the object.
cornerRadius (radius, borderRadius, corner)radiusCorner radius: one length or only(topLeft: 8, …).
borderWidthlenBorder width.
borderColorcolorBorder colour.
borderAlignin | mid | outinWhere the border sits relative to the edge: in, mid or out.
borderStylesolid | dashed | dottedsolidBorder line style.
borderSidesall | top | bottom | left | right | x | yallWhich sides draw the border (inside the box).
shadowshadowDrop shadow(s): shadow(y: 4, blur: 12, color: black.alpha(20%)).
clipboolClip children to the object's bounds (and corner radius).
zintStacking order among siblings.
margininsetsSpace outside the object: all(8), sym(x: 8, y: 4), only(top: 8).
opacitynumOpacity from 0 to 1.
hide (hidden)boolRemoves the object from layout and the accessibility tree.
shrinknum1Shrink priority when space runs out. Lower shrinks first; 0 never shrinks.
flexnum1Share of remaining space for fill sizes.
cursorauto | pointer | text | grab | grabbing | move | notAllowed | crosshair | nonePointer cursor.
className (class)txtExtra CSS class names: styling hooks for your own stylesheet (hover rules, third-party CSS).
topagePage to open, e.g. DemoPage.
hreftxtExternal URL.
labeltxtLink text (when there is no object).
externalboolOpen in a new tab.
downloadboolThe link is a file to save (href: '/download/app.zip'), not a page to open.
underlineboolUnderline the link (browsers underline links by default).
objAlign (align, alignment, contentAlign)aligntopLeftWhere the object's content sits inside it.

Group .border(align, color, width, style, sides): Border settings grouped: .border(align: in, color: #0d0d0d, width: 2).

Slots

  • .obj: one object, the default slot

Events

.fnc runs on press. .on(...) accepts tap, press, hover, hoverEnd, focus, blur, key, drag, swipe, mount, unmount, visible.

Privacy

Cookies

Terms

Contact & grievances