Skip to content

using refs in css #693

@shancarter

Description

@shancarter

When I use a ref, I most often also want to get a handle to it with css, which leads to slightly annoying, duplicative markup.

<style>
  .container {
    color: red
  }
</style>
<div class="container" ref:container></div>

The only solutions I can think of to mitigate this are untenable, but thought I raise this if others see something better.

  • Make nodes with ids available as refs, like polymer's static node map
  • Make svelte refs available as synthetic css selectors
  • Make a syntax shortcut for declaring refs as classes, e.g. <div ref:class:container ></div>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions