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-variables] define custom property based on parent's (inherited) value #1962

Open
dubrowsky opened this issue Nov 8, 2017 · 1 comment

Comments

@dubrowsky
Copy link

According to the Resolving Dependency Cycles section of the spec it's not possible to use var(--property) while defining the --property itself.

Here's an illustration of the problem I'd like to solve:

.table {
    width: 60vw;
    --width: 60vw;
}

.column {
    width: 25%;
   // should be (60vw / 4) = 15vw
    --width: calc( var(--width) / 4);
}

.something-inside-the-column {
     // should be (60vw / 4) * 0.1 = 6vw
     font-size: calc( var(--width) * 0.1 ); 
}

So I'd like to use the inherited value if the own is not yet defined. If this behavior is hard to implement, maybe the specification can introduce another function to use inherited values explicitly, something like this:

    --width: calc( inherited-var(--width) * 0.1 );

The solution suggested here (just use two different props) is not the answer, because I want my components to be "context-agnostic". Please tell me if my case is not clear enough, I'll try to provide some better example then. Thank you!

@LeaVerou
Copy link
Member

I have definitely needed this too. I'd support a parent-var() (or similar) function, though it's possible to have a more general form that works for any property (see #2864).

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

No branches or pull requests

3 participants