Surface
On this page
Overview
A surface provides color context to descendants via color-palette.
Authors must set a color-palette and should use surface only when
containers like rh-card are not appropriate. Each palette provides
WCAG-compliant contrast when using the default theme. Surface is
non-interactive: Tab and focus pass through to focusable children.
Users of AT perceive no additional semantics from this element.
Edit element properties
#surface {
display: grid;
grid-auto-columns: 1fr;
grid-auto-flow: column;
justify-items: center;
align-items: center;
padding: var(--rh-space-xl);
}
import '@rhds/elements/rh-surface/rh-surface.js';
import '@rhds/elements/rh-blockquote/rh-blockquote.js';
import '@rhds/elements/rh-spinner/rh-spinner.js';
import '@rhds/elements/rh-tag/rh-tag.js';
<rh-surface id="surface" color-palette="darkest">
<rh-blockquote align="inline-start" size="default">
<p>Surface is used to provide a theme to children</p>
</rh-blockquote>
<rh-spinner size="lg">Loading...</rh-spinner>
<rh-tag color="green">Sold</rh-tag>
</rh-surface>
import { Blockquote } from "@rhds/elements/react/rh-blockquote/rh-blockquote.js";
import { Spinner } from "@rhds/elements/react/rh-spinner/rh-spinner.js";
import { Surface } from "@rhds/elements/react/rh-surface/rh-surface.js";
import { Tag } from "@rhds/elements/react/rh-tag/rh-tag.js";
// NOTE: React 19+ does not require these wrapper imports.
// You can use the custom elements directly as-is.
export const Demo = () => (
<Surface id="surface" color-palette="darkest">
<Blockquote align="inline-start" size="default">
<p>Surface is used to provide a theme to children</p>
</Blockquote>
<Spinner size="lg">Loading...</Spinner>
<Tag color="green">Sold</Tag>
</Surface>
);
Sets the color palette, which controls the element's background color
and propagates accessible text and interactive colors to descendants.
Accepted values are lightest, lighter, light, dark, darker,
and darkest. Surface always overrides the parent's color context.
Your theme will influence these colors so check there first if you
are seeing inconsistencies.
See CSS Custom Properties for default values.
Status
- Figma library:
-
Ready - RH Elements:
-
Ready - RH Shared Libs:
-
Ready
When to use
- When you want a styled background that fits well into RHDS' theming system.
- When you want to provide theming tokens to elements without using a styled container.
Status checklist
| Property | Status | Meaning |
|---|---|---|
| Figma library |
|
Component is available in the Figma library |
| RH Elements |
|
Component is available in RH Elements |
| RH Shared Libs |
|
Component is available in RH Shared Libs |
Other libraries
To learn more about our other libraries, visit this page.
Feedback
To give feedback about anything on this page, contact us.
Other libraries
To learn more about our other libraries, visit the getting started page.