Skip to content

[Theme] Allow Theme component to provide custom styles #1496

@stanvladut

Description

@stanvladut

In order for our application to scale properly, we would need the same sp-theme functionality not with Spectrum CSS variables, since the sp-theme component already provides them, but with our custom variables that we use across our components, that might or might not depend on some Spectrum CSS variables.

Expected Behaviour

The expected behavior is to have a possibility to provide some application related styles via sp-theme component, not only Spectrum CSS styles.

For example:
Locally, for our app, depending on the scale & color combination, we compute a list of local variables to be used across our app like this:

.app-container[scale="medium"] {
       --label-size: 0.75rem;
       --spacing-unit: 0.5rem;
       --header-height: calc(2.5rem + 1px);
}
.app-container[color="light"] {
      --label-color: var(--spectrum-alias-label-text-color);
}       

This CSS has to be attached to a child of the <sp-theme> in the DOM hierarchy to be able to also reference Spectrum variables.
What we would need is a way to have this local computed CSSResult provided by the sp-theme in order for us not to create a new local provider for the app's theme.

Actual Behaviour

The actual behavior only allows us to send a combination of color and scale attributes depending on which the sp-theme provides the Spectrum CSS variables to be used in the app.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions