Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[css-backgrounds][css-text-decor] Keywords for predefined shadows #11234

Open
Crissov opened this issue Nov 18, 2024 · 1 comment
Open

[css-backgrounds][css-text-decor] Keywords for predefined shadows #11234

Crissov opened this issue Nov 18, 2024 · 1 comment

Comments

@Crissov
Copy link
Contributor

Crissov commented Nov 18, 2024

box-shadow and text-shadow now share a value definition <shadow>, while filter: drop-shadow() slightly differs.

Frameworks and Design Systems provide some presets for them (e.g. Tailwind), which are mostly very basic, often defaulting to a very transparent black.
Since drop shadow are cast by the light obstructed by elements and the light source is often directly above the element, it usually has zero horizontal offset and some positive vertical offset. The blur rasius is often one to three tiems the offset.

Material Design notes:

Shadow size reflects elevation. Surfaces at higher elevations have larger shadows, while those at lower elevations have smaller shadows.

Other Design systems, e.g. Fluent Design, also describe the use of shadows to emulate physical characteristics like elevation and material. Overall, key shadows are sharp, directional shadows used to define edges and ambient shadows are soft, diffused shadows used to imply distance.

This feels like it should be possible to define some simple presets available as keywords in the shadow properties (and perhaps even the filter), so graphics-illiterate people like myself can get some decent defaults and readable source code in vanilla CSS without the use of external presets. I have no concrete idea how many of these should exist and what they would look like, but maybe start with something like this:

  • low-elevation, medium-elevation, high-elevation or
  • elevated, raised, floating, embossed

I am also not sure whether CSS should prescribe the actual values for those keywords or leave it up to implementations, but since CSS3 the trend has been to be rather prescriptive. I think there's even an open issue to normatively specify border-style keywords like groove and ridge.

@schenney-chromium
Copy link
Contributor

It's an interesting idea. I wonder if it could be tied to z-depth, as users might find it incongruous to have stacking order saying one thing and shadows implying another. Using independent keywords for a physical kind of thing like this is also brittle to DOM manipulation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants