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.
| Prop | Light page | Dark page | Use case |
|---|---|---|---|
dark | dark tokens | inverts → light | Contrast band against page |
light | light tokens | inverts → dark | Contrast band against page |
dark-always | dark tokens | dark tokens | Dark media bg — text stays light |
light-always | light tokens | light tokens | Light media bg — text stays dark |
light page
surface="dark-always"Section title
Content inside the surface scope.
dark page
surface="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>