Skip to content

How to use with styled components #14

@danvim

Description

@danvim

Not strictly an issue of this library but a question about integrating with styled-components.

I have the following piece of code and styled-components is unable to deduce h1 attributes of StyledHeading. With only as={} suggested when creating a StyledHeading tag and any other attributes being any. Upon checking the typing from my IDE, I see that StyledHeading has type StyledComponent<PolymorphicForwardRefExoticComponent<P, any>, ...>.

import styled from 'styled-components'

export const Heading: PolymorphicForwardRefExoticComponent<
  HeadingOwnProps,
  typeof HeadingDefaultElement
>(...) => {...}

const StyledHeading = styled(Heading).attrs({
  forwardedAs: 'h1' // or as: 'h1'
})``

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions