callstack / callstack/react-native-paper

Surface: first-class semantic container color API independent of elevation

Open
#5,119 0 comments 0 reactions 1 assignee Claimed by @hristototov View on GitHub
feature request v6
Dominant language
TypeScript
Stars
14.5k
Forks
2.2k
Avg merge
5d 23h
Merged PRs (30d)
12

Description

**Is your feature request related to a problem? Please describe.**

`Surface` derives its background color directly from the numeric `elevation` prop (`theme.colors.elevation.levelN`), including in `mode="flat"` and during animated elevation changes. A component cannot express "this container is `surfaceContainerLow`, and elevation only controls the shadow". The only escape hatch is passing a raw color via `backgroundColor`, which loses the semantic intent and doesn't track the theme role. As components are modernized to MD3 (e.g. Menu in #5037, which the spec fills with `surfaceContainer`), each one has to invent its own workaround.

**Describe the solution you'd like**

A `container` prop on `Surface` accepting a semantic surface-family color role (`surface`, `surfaceDim`, `surfaceBright`, `surfaceVariant`, `surfaceContainerLowest`–`surfaceContainerHighest`, `inverseSurface`), resolved from the theme:

```tsx

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.