Skip to content

styled-components support  #643

Closed
Closed

Description

@adrian-gierakowski

I'm considering switching from prettier do dprint on a frontend react project, but one thing is stopping me: pettier formats code in tagged templates for styled-components but dprint doesn't

for example, the following:

import styled from 'styled-components'

const Header = styled.div`
  height: 40px;  padding: 0 15px;
  display: flex;          align-items: center;
  border-top-left-radius: 5px;
  border-top-right-radius: 5px;
`

gets formatted by prettier as follows:

const Header = styled.div`
  height: 40px;
  padding: 0 15px;
  display: flex;
  align-items: center;
  border-top-left-radius: 5px;
  border-top-right-radius: 5px;
`;

but not by dprint

Is there every any chance for dprint-plugin-typescript to add support for this? Thanks!

Activity

  1. added
    enhancement
    on Jul 29, 2024
  2. adrian-gierakowski commented on Aug 22, 2024

    @adrian-gierakowski
    ContributorAuthor

    I wonder if it would be possible to delegate formatting of these to prettier (or any other pluggin) while using dprint for everything else? If something like this could be done in a general and configurable way it would help fill in missing functionality until it’s added to dprint itself

  3. dsherret commented on Nov 4, 2026

    @dsherret
    Member

    Warning

    This comment was written by AI. If this is a mistake, please comment on this issue.

    Implemented in #792 and #838. styled-components templates (ex. styled.div, styled(X), .attrs()) are now detected and their CSS is formatted by the CSS plugin in your dprint config (ex. malva). See the taggedTemplate.formatEmbedded and taggedTemplate.embeddedLanguages options.

    This is on main but isn't released yet, so it will be in the next release after 0.96.1.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions