Skip to content

[css-contain-3] Container Variables #12604

@kizu

Description

@kizu

Proposal: Add a new container-var() function for retrieving the values from the closest named container.

container-var() = container-var(<custom-ident>, <custom-property-name>, <declaration-value>?)`
  • <custom-ident> — the name of a container to get the variable value from.
  • <custom-property-name> — the name of the propertly.
  • <declaration-value>? — the variable's fallback.

Basically, the same as var() but with an additional first parameter for the container's name.

This function will get the closest container with the specified name and return the value of the given custom property from it. That's it.

<div style="container-name: --foo; --bar: 1;">
    <div style="--bar: 2;">
        <div style="--baz: container-var(--foo, --bar)"> // 1

Related links

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