Skip to content

Request for a "checked-within" pseudo class #3027

@omzy

Description

@omzy

Similar to the focus-within (https://developer.mozilla.org/en-US/docs/Web/CSS/:focus-within) pseudo class, can we have a checked-within pseudo class?

Basically would allow a parent element of a checked checkbox or radio to be targeted. Sample usage:

HTML:

<div class="option">
    <div class="title">
        <input type="radio" id="basic" name="package" value="basic">
        <label for="basic">Basic</label>
    <div>

    <div class="content">
        <!-- some content -->
    </div>
</div>

CSS:

.option {
    background-color: white;
}

.option:checked-within {
    background-color: green;
}

Currently we have to use JS to detect a change event on the radio button in order to apply a class on a parent element (or conditionally apply a class on the server side for rendered pages).

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