Skip to content
bref / ui

Svelte components, simply.

Star

Surface

A semantic flex container with theme tints, opt-in glass, shared spacing, corner rounding and optional scrolling.

Usage

Details

Content inside the surface.

Svelte
<script>
	import { Surface } from 'bref-ui';
</script>

<Surface as="section" variant="soft" spacing="medium" radius="small">
	<h2>Details</h2>
	<p>Content inside the surface.</p>
</Surface>

Render Theme once to load the shared paint recipes. The typed surface helper applies the same recipes to native HTML; pass glass: true for translucent material. Component styles supply padding, radius and layout.

Svelte
<script>
	import { Theme, surface } from 'bref-ui';
</script>

<Theme />
<button class={surface({ variant: 'filled', color: 'primary', shadow: 'small', hover: 'medium' })}>
	Save
</button>

Playground

Explore paint and layout together. The preview has a fixed height for fill and scrolling.

Live preview

Surface Long content stays readable and wraps within narrow layouts. Change the controls to explore the container.

Settings

Paint
Layout
View generated code
Svelte
<Surface
	as="div"
	variant="soft"
	color="background"
	glass={false}
	spacing={'medium'}
	orientation="vertical"
	width="fill"
	height="fit"
	radius={'small'}
	shadow={false}
	hover={undefined}
	scroll={false}
>
	<strong>Surface</strong>
	<span
		>Long content stays readable and wraps within narrow layouts. Change the controls to explore the
		container.</span
	>
</Surface>

Colors and variants

Switch the shared theme control to compare light and dark. Filled uses a strong opaque color; background-tinted panels retain the foreground text color.

background neutral
background soft
background filled
foreground neutral
foreground soft
foreground filled
primary neutral
primary soft
primary filled
secondary neutral
secondary soft
secondary filled
muted neutral
muted soft
muted filled
info neutral
info soft
info filled
success neutral
success soft
success filled
warning neutral
warning soft
warning filled
error neutral
error soft
error filled

Contextual glass

Soft surfaces use an opaque tint. Add the glass prop when a panel sits above visual content; transparency and blur then belong to that panel alone. Keep controls inside it opaque to avoid nested blur. Reduced transparency, increased contrast and unsupported backdrop filtering use a solid fill.

flat
Base neutral
Base soft
Base filled
Glass neutral
Glass soft
Glass filled
Success glass neutral
Success glass soft
Success glass filled
mesh
Base neutral
Base soft
Base filled
Glass neutral
Glass soft
Glass filled
Success glass neutral
Success glass soft
Success glass filled
shapes
Base neutral
Base soft
Base filled
Glass neutral
Glass soft
Glass filled
Success glass neutral
Success glass soft
Success glass filled
Standalone panel

The same helper also composes with native panel styling.

Svelte
<Surface glass variant="soft" spacing="medium" radius="small">Panel content</Surface>

<button class={surface({ variant: 'soft', color: 'primary', hover: 'medium', glass: true })}>
	Save
</button>

Spacing, dimensions and radius

x-small Padding and gap share a scale.
small Padding and gap share a scale.
medium Padding and gap share a scale.
large Padding and gap share a scale.
x-large Padding and gap share a scale.
Defaults Lightly tinted, square, with no spacing.
Span
Explicit rem radius and shadow
Full parent height
  • Design
  • Development
Loading

Saved 0 times.

Scrolling and composition

Surface forwards native attributes and events to its root. Pass class, style, ARIA attributes and event handlers directly; content uses a Svelte children snippet. Explicit tabindex overrides the scroll focus default.

Focused 0 times.

Svelte
<Surface
	as="section"
	id="details"
	class="custom-surface"
	style="font-style: italic;"
	aria-label="Details"
	tabindex={0}
	onfocus={onFocus}
>
	<p>Content inside the surface.</p>
</Surface>

Give the parent a fixed height and use height="fill" to constrain scrolling. A scrollable Surface can receive keyboard focus; use arrow keys to scroll.

Scrollable content, row 1.

Scrollable content, row 2.

Scrollable content, row 3.

Scrollable content, row 4.

Scrollable content, row 5.

Scrollable content, row 6.

Scrollable content, row 7.

Scrollable content, row 8.

Scrollable content, row 9.

Scrollable content, row 10.

Scrollable content, row 11.

Scrollable content, row 12.

Svelte
<div style="height: 12rem;">
	<Surface scroll height="fill">Content</Surface>
</div>

Props

Component props
PropTypeRequiredDefaultDescription
as'div' | 'section' | 'span'NodivNative root element.
childrenSnippetNoOmittedContent rendered directly inside the root.
colorColorNobackgroundTheme color; the shared recipe supplies content color.
variantVariantNoneutralLightly tinted neutral, opaque tinted soft, or opaque filled panel.
spacingSizeNoOmittedShared padding and gap; omitted means zero.
orientationOrientationNoverticalColumn, or row with centered cross-axis alignment.
widthDimensionNofillfill uses 100%; fit hugs content.
heightDimensionNofitfit uses natural height; fill uses 100% of a sized parent.
radiusSize | `${number}rem` | `${number}%`NoOmitted (0)Named corner scale or an explicit rem/percentage radius.
shadowBaseSize | booleanNofalseShadow strength; true selects medium.
hoverBaseSizeNoOmittedOptional hover/focus treatment; does not make the root interactive.
scrollbooleanNofalsetrue sets overflow to auto; otherwise overflow stays visible.
glassbooleanNofalseEnable translucent paint and backdrop blur.

Migration: pass native attributes directly to Surface; hover replaces hoverEffect. Replace capsule with a named size, a rem value, or a percentage radius. Use scroll for automatic overflow.