Skip to content

Surface scoping

A dark band on a light page, or text over a photo, usually means hand-picking text and border colours for that one area. In Shavin you set surface on the container and every component inside switches to the right token set.

Surface contrast scoping

Layout primitives take a surface prop. Inside it, the semantic tokens switch to the light or dark set whatever the page theme is, so text on a dark band or a photo stays readable. Pick a mode below to see it on a light and a dark page.

PropLight pageDark pageUse case
darkdark tokensinverts → lightContrast band against page
lightlight tokensinverts → darkContrast band against page
dark-alwaysdark tokensdark tokensDark media bg — text stays light
light-alwayslight tokenslight tokensLight media bg — text stays dark
light pagesurface="dark-always"

Section title

Content inside the surface scope.

dark pagesurface="dark-always"

Section title

Content inside the surface scope.

surface prop — live preview
<Flex direction="column" gap="3" surface="dark-always"
  bgImage="https://images.unsplash.com/photo-1719841602002-1dcc795bed24"
  bgOverlays="dark-50"
  className="rounded-[var(--radius-panel)] p-6">
  <Heading size="sm">Section title</Heading>
  <Text size="xs" color="subtle">Content inside the surface scope.</Text>
  <Flex direction="row" gap="2">
    <Button size="sm" variant="solid" tone="brand">Action</Button>
    <Button size="sm" variant="outline">Cancel</Button>
  </Flex>
</Flex>
Configure Theme
Theme
Brand Color
Custom
Gray Family
Appearance
Radius
Scaling
Panel Style
Heading Font
Body Font