Skip to content

Build UI / Layout / Inset

Inset ​

Cancels a padded ancestor's padding on the sides you name, using a negative margin, so its content bleeds to that ancestor's edges — the full-width image at the top of a padded card. It's the escape hatch for one child, not a layout for many: it flexes its content, clips the overflow, and rounds the corners that stay inside.

preview
Code
html
<kb-card>
  <kb-inset side="top">
    <kb-cover
      src="https://picsum.photos/id/1084/640/360"
      alt="A dog running on a beach"
    ></kb-cover>
  </kb-inset>
  <kb-text size="xs" weight="bold">Edge to edge</kb-text>
  <kb-text size="xxxs" color="master">The image touches the card's edges; this text doesn't.</kb-text>
</kb-card>

Usage ​

html
<kb-inset side="top">
  <img src="/banner.png" alt="" />
</kb-inset>

When to use ​

  • A media band inside a padded surface — a cover image or map that should touch the card's edges while the text around it stays inset.
  • A divider or tinted strip that spans the full surface — a section break inside a <kb-card> that would otherwise stop short of both edges.
  • A bottom action bar inside a padded container — side="bottom" keeps the top corners square against the content above and rounds the two meeting the container's edge.

When not to use ​

  • Spacing siblings — that's <kb-stack>. An inset removes space; it doesn't distribute it.
  • Centering page content — <kb-main> already caps the width and centers the column.
  • When the parent has no padding. The negative margin then pulls content outside the parent instead of to its edge. The bleed distance is fixed, not measured from the parent.
  • Rounding an image on its own — a border-radius on the image is simpler. Reach for this only when the bleed is the point.

Composition ​

  • Can contain: anything — the shadow root is a single unnamed <slot>. Media is the common case, and overflow: hidden means an image larger than the box is clipped by the rounded corners rather than escaping them. One or more <kb-on> children add arcs beyond the single on attribute.
  • Can be a child of: a padded container whose padding matches the bleed. <kb-card> is the intended parent; the default bleed (16px) is exactly the card's own inset, which is why the two line up without configuration.

The host is itself a flex container, so direction arranges multiple children the way <kb-stack> would — but keep it to what belongs in the bleed.

Which side ​

side picks which edges bleed. The value also drives the corner rounding, so the corners meeting the parent's edge stay round and the ones meeting the content go square.

preview
Code
html
<kb-card>
  <kb-inset side="bottom">
    <kb-cover
      src="https://picsum.photos/id/1069/640/360"
      alt="Bleeding to the bottom edge"
    ></kb-cover>
  </kb-inset>
</kb-card>
sideBleedsRounds
all (default)every edgeall four corners
toptop, left, rightthe two top corners
bottombottom, left, rightthe two bottom corners
left / rightthat edge plus top and bottomthe two corners on that edge
xleft and right onlynothing — the band is open on both sides
ytop and bottom onlynothing

A value outside the set is ignored: the attribute change never reaches the property, which keeps its last valid value (all until you set one). The same holds for direction.

Attributes ​

AttributeTypeDefaultDescription
sideall | top | bottom | left | right | x | yallWhich edges receive the negative margin, and which corners stay rounded.
directionrow | columncolumnFlex direction of the slotted content.
widthhug | fill | lengthautoHost width, normalized to a closed set of size shapes.
heighthug | fill | lengthautoHost height, normalized the same way.
hiddenbooleanfalseRemoves the element and its content from layout and the accessibility tree.
altstring''Accessible name. Rarely meaningful — the host is presentational.
onarc string—Echo wiring, source/event:type/sink — lets another element drive an attribute of this inset.

This element dispatches no events; on only ever receives.

Styling ​

Custom propertyDefaultControls
--inset-space-bleedvar(--spacing_inset-xs) (16px)How far the content pulls out on each named side. Applied as a negative margin.
--inset-border-radiusvar(--border-radius-sm) (8px)Rounding of the corners that stay at the parent's edge.

Match the bleed to the parent's padding — that's the whole contract. A container padded with --spacing_inset-md needs the same value here, or the content stops short of the edge or spills past it:

preview
Code
html
<div style="--card-space-inset: 32px;">
  <kb-card>
    <kb-inset side="top" style="--inset-space-bleed: 32px; --inset-border-radius: 16px;">
      <kb-cover
        src="https://picsum.photos/id/1025/640/360"
        alt="Bleed matched to a roomier card"
      ></kb-cover>
    </kb-inset>
    <kb-text size="xxs">Bleed and padding both at 32px.</kb-text>
  </kb-card>
</div>

!> The margin is declared !important so it survives a parent that sets margins on its children. You can't override the bleed with a plain margin from outside — change the custom property instead.

States and accessibility ​

  • hidden adds the hidden custom state and display: none, removing the element and its content from layout and the accessibility tree.
  • The host is declared presentational — it's a visual container. Content inside keeps its own semantics, and the negative margin doesn't change reading or focus order.
  • overflow: hidden clips, it doesn't scroll. Content taller than a fixed height is silently cut, so leave the height automatic unless you intend the crop.

Do's and don'ts ​

DoDon't
Match --inset-space-bleed to the parent's paddingLeave the default bleed inside a container padded differently
Use side to bleed only the edges that touch the parentUse all and then fight the rounding on the inner edges
Put one media block or band inside itTreat it as a general layout container — that's <kb-stack>
Let the height follow the contentSet a fixed height and rely on overflow: hidden to crop silently