clsx icon indicating copy to clipboard operation
clsx copied to clipboard

Feature: clsx.arr() to return class names in array format

Open webJose opened this issue 3 months ago • 0 comments

Motivation

When using it in Svelte attachments that apply classes imperatively using element.classList.add|remove, we need the list of classes in array format. Surely one can do clsx(...).split(' ').filter(x => x.trim().length > 0), but this adds an extra loop that can potentially be avoided.

Proposal

A new function, clsx.arr() or whatever people like best that returns the calculations in array format, with one CSS class per array slot.

I can PR this if approved.

webJose avatar Oct 08 '25 20:10 webJose