Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.
This repository was archived by the owner on May 22, 2025. It is now read-only.

How to use css properties (needed for Spacing, Text Styles, etc) in Typescript? #821

@flyingnobita

Description

@flyingnobita

In my Landing.tsx file:

import { Main, textStyle } from "@aragon/ui";
import React from "react";

const Landing = () => {
  return (
    <Main>
      <div
        css={`
          ${textStyle("title1")};
        `}
      >
        Title 1
      </div>
    </Main>
  );
};
export default Landing;

I get the error:

Property 'css' does not exist on type 'DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>'.ts(2322)

I tried to add the type declaration in my .d.ts file (taken from here):

import { CSSProp } from "styled-components";
declare module "styled-components" {
  export interface DefaultTheme {}
}

declare module "react" {
  interface Attributes {
    css?: CSSProp;
  }
}

This suppressed the error but my text was still not formatted.

Perhaps a separate issue, I noticed that even if my file was renamed to Landing.js, the text was still not formated. Perhaps this is related to something else... 🤔 (I haven't encountered problems with other components TextInput, Field, yet though)

For context, I'm using aragin UI in a vanilla create-eth-app.

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