Skip to content

::before and :hover::before in the same style object #808

Answered by nmn
zaydek asked this question in Q&A
Discussion options

You must be logged in to vote

You're trying to do this.

groupIsNested: {
  "::before": {
    borderColor: "color-mix(in hsl, transparent, white 25%)",
    borderLeftStyle: "solid",
    borderLeftWidth: 1,
    content: "",
    insetBlock: 0,
    insetInlineStart: `calc(${SIDEBAR_ITEM_BLOCK_SIZE}px / 2)`,
    position: "absolute",
  },
  ":hover": {
    '::before': {
      borderColor: "purple",
    }
  },
},

This pattern is very discouraged because you're essentially doing a descendent selector.

We recommend using variables for this:

groupIsNested: {
  [vars.borderColor]: {
    default: "color-mix(in hsl, transparent, white 25%)",
    ":hover": "purple",
  },
  "::before": {
    borderColor: vars.borderColor,
    borde…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@zaydek
Comment options

@zaydek
Comment options

@nmn
Comment options

nmn Dec 16, 2024
Collaborator

Answer selected by zaydek
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants