ui icon indicating copy to clipboard operation
ui copied to clipboard

Accordion `items` type does not allow custom content

Open TheAlexLichter opened this issue 1 year ago • 1 comments

Environment

Stackblitz

Version

2.17.0

Reproduction

  1. Open the StackBlitz
  2. Run npx nuxi typecheck
  3. See error.

image

Description

When using custom content for the accordion, the types throw an error because content is only allowed to be a string

https://github.com/nuxt/ui/blob/53003fcd07d67d13ada0759ff6c5cd3635fba0e3/src/runtime/types/accordion.d.ts#L6

Additional context

Ideally, AccordionItem would have a generic for content, defaulting to string so we could have autocomplete for the types.

Logs

No response

TheAlexLichter avatar Jul 12 '24 17:07 TheAlexLichter

We can't do much about it in this version unfortunately but we've implemented everything with generics in v3 already: https://github.com/benjamincanac/ui3/blob/9420a686bbcf2aae854915a114fcaa6e4e808021/src/runtime/components/Accordion.vue#L51

benjamincanac avatar Jul 16 '24 09:07 benjamincanac

@benjamincanac just to understand... i would also like to have a custom accordionitem type and display body default etc slots with custom code... how can i change the items type?

simonmaass avatar Mar 25 '25 18:03 simonmaass

@TheAlexLichter did u find any workaround?

simonmaass avatar Jul 08 '25 11:07 simonmaass

@simonmaass I think I just switched to v3 eventually.

TheAlexLichter avatar Jul 08 '25 12:07 TheAlexLichter

@TheAlexLichter i am also using v3... but not sure how to do it... any help would be greatly appreciated :)

Image

simonmaass avatar Jul 08 '25 12:07 simonmaass

@simonmaass This issue if for v2, would you mind opening a new issue with a reproduction so we can help?

benjamincanac avatar Jul 08 '25 14:07 benjamincanac

@benjamincanac the issue had the label "v3" - that confused me. sorry

simonmaass avatar Jul 09 '25 16:07 simonmaass