Surface
Importing
Add rh-surface to your page with this import statement:
<script type="module">
import '@rhds/elements/rh-surface/rh-surface.js';
</script>
Copy to Clipboard
Copied!
Wrap lines
Overflow lines
To learn more about installing RHDS elements on your site using an import map read our getting started docs.
Usage
<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>
<style>
#surface {
display: grid;
grid-auto-columns: 1fr;
grid-auto-flow: column;
justify-items: center;
align-items: center;
padding: var(--rh-space-xl);
}
</style>
<script type="module">
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';
</script>
Copy to Clipboard
Copied!
Wrap lines
Overflow lines
rh-surface
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.
Slots
1
| Slot Name | Summary | Description |
|---|---|---|
[default]
|
Accepts any content. |
Attributes
1
| Attribute | DOM Property | Description | Type | Default |
|---|---|---|---|---|
color-palette
|
colorPalette |
Sets the color palette, which controls the element's background color
and propagates accessible text and interactive colors to descendants.
Accepted values are |
|
|
Methods
0
None
Events
0
None
CSS Shadow Parts
0
None
CSS Custom Properties
0
None
Design Tokens
2
| Token | Description | Copy |
|---|---|---|
--rh-color-text-primary
|
Primary text color |
|
--rh-color-surface
|
Surface background color |
|
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.