Skip to content

How to add a variant to Alert component and keep correct TypeScript? #447

Closed Answered by Seigiard
Seigiard asked this question in Q&A
Discussion options

You must be logged in to vote

Okay, I've found it our with help of card component.

Need to update Root types in alert.tsx from

import { alert } from 'styled-system/recipes'
export const Root = withProvider<
  HTMLDivElement,
  Assign<HTMLStyledProps<'div'>, PolymorphicProps>
>(ark.div, 'root')

to

import { type AlertVariantProps, alert } from 'styled-system/recipes'
export const Root = withProvider<
  HTMLDivElement,
  Assign<Assign<HTMLStyledProps<'div'>, PolymorphicProps>, AlertVariantProps> // <- !!!!
>(ark.div, 'root')

Pay attention to added AlertVariantProps — it does all work.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Seigiard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant