Skip to content

Using url() css function from prop value is considered as comment and removed from styles #5637

Closed

Description

@ntltd

Using url('https://${prop.$url}') with prop is considered as comment since [email protected] and removed from generated styles in some cases.

Example:

The following code:

const ImagePlaceholder = styled.div`
  background-image: ${({ $placeHolderUrl }) => `url(${$placeHolderUrl})`};
  background-repeat: no-repeat;
  background-size: 100% 100%;
  width: 750px;
  height: 750px;
`

<ImagePlaceholder $placeHolderUrl="https://static.jowugc.com/750x750/placeholders/plate.png" />

Results in:
Image

Activity

  1. ntltd commented on Jan 12, 2026

    @ntltd
    Author

    It was working perfectly in [email protected], so I suspect this commit: 7ff7002

  2. ntltd commented on Jan 12, 2026

    @ntltd
    Author

    I ended up wrapping my URLs in quotes. Maybe not a bug, but it seems like a regression since the syntax without quotes worked before the last release.

    Here's the helper I use now:

    const formatCssUrl = (url) => {
      return `url('${encodeURI(url)}')`
    }
    
    export { formatCssUrl }
  3. laurenskling commented on Jan 12, 2026

    @laurenskling

    Came here to report this :)

    it also breaks all following css lines, because the url parentheses is never closed

  4. quantizor commented on Jan 13, 2026

    @quantizor
    Contributor

    Thanks for reporting, looking into it.

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

Metadata

Metadata

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