Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Card title tag not changing #1531

Closed
ewe-sro opened this issue Dec 3, 2024 · 3 comments
Closed

Card title tag not changing #1531

ewe-sro opened this issue Dec 3, 2024 · 3 comments

Comments

@ewe-sro
Copy link

ewe-sro commented Dec 3, 2024

Describe the bug

I can't change the tag of the Card.Title. I'm getting a TypeScript error:

Object literal may only specify known properties, and '"tag"' does not exist in type 'HTMLAttributes<HTMLDivElement> & { ref?: HTMLElement | null | undefined; } & { level?: 1 | 2 | 3 | 4 | 5 | 6 | undefined; }'.ts(2353)

In Svelte 4 this worked flawlessly, but in Svelte 5 (and shadcn-svelte@next) the tag prop is not even being suggested by the IDE. Only relevant prop I have available is 'level'

Also in the docs I see this: By default, the <Card.Title> component renders an <h3> element.
This is not true for me, the title is using this element: <div role="heading" aria-level="3">

Reproduction

Simply install the card component with npx shadcn-svelte@next add card

Logs

No response

System Info

Not relevant, I think

Severity

annoyance

@ieedan
Copy link
Contributor

ieedan commented Dec 3, 2024

So the shadcn-svelte docs are incorrect here.

The behavior is consistent with the original library the original library doesn't have a level prop I assume because they allow you to supply the aria-level on your own. But the level here is a nice shorthand for that.

Shadcn

const CardTitle = React.forwardRef<
  HTMLDivElement,
  React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
  <div
    ref={ref}
    className={cn(
      "text-2xl font-semibold leading-none tracking-tight",
      className
    )}
    {...props}
  />
))
CardTitle.displayName = "CardTitle"

There is a change for this in the original library moving from h3 -> div https://ui.shadcn.com/docs/components/card#changelog

I think the docs just need to be corrected here.

@ewe-sro
Copy link
Author

ewe-sro commented Dec 5, 2024

I see, I was just confused because of the docs. It should be corrected, agreed.
Thanks.

@huntabyte
Copy link
Owner

Closed by #1543

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants