Skip to content

How to add onClick to a button? #13

@schystz

Description

@schystz

Hello, I am impressed with this library so I decided to give it a try.

I have the following code below to declare a button:

import { tw } from 'brise'

const Button = tw.button`
  font-bold text-white
  w-full p-2
  bg-primary hover:bg-primary-hover
  active:ring active:ring-purple-300
  rounded
  transition-colors
  md:text-primary md:hover:text-primary-hover
  md:bg-transparent md:hover:bg-transparent
  md:w-auto md:p-0
`

Above works and it displays the intended styles correctly.

However when I try to add an onClick property, I get the following error from Typescript:

Type '{ children: string; onClick: () => void; }' is not assignable to type 'IntrinsicAttributes & { children?: ReactNode; }'.
  Property 'onClick' does not exist on type 'IntrinsicAttributes & { children?: ReactNode; }'.  TS2322

I've looked at the examples & demo but there doesn't seem to be any relevant info.

Can you please advise?

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