Skip to content

Expose ClassValue #15033

@PuruVJ

Description

@PuruVJ

Describe the problem

Right now, if I have a component with class prop:

<script>
  const { class: className }: {class: string} = $props()
</script>

Usage:

<Comp class="py-2 sm-6" />

This works beautifully. However, with the new clsx-style classes, we should be able to type the class prop as ClassValue, basically everything that clsx supports

Describe the proposed solution

Export the ClassValue: export type ClassValue = clsx.ClassValue in svelte module, used as

import type { ClassValue } from 'svelte';

const {class: className}: { class: ClassValue[] } = $props();

Listed here: https://github.com/lukeed/clsx/blob/master/clsx.d.ts#L2

Importance

nice to have

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