Next.js Discord

Discord Forum

why clsx is used?

Answered
Mrigal carp posted this in #help-forum
Open in Discord
Avatar
Mrigal carpOP
isn't clsx an extra thing to import
import clsx from 'clsx';
<div className={clsx(status === 'active' ? styles.active : styles.inactive)} />

while i can do the same thing
<div className={(status === 'active') ? styles.active : styles.inactive} />
Answered by Great-tailed Grackle
to do something like this:
<div
  className={clsx(
    'sticky top-0 z-50 shadow-sm',
    condition && 'bg-background/80 backdrop blur-md'
  )}
/>
View full answer

1 Reply

Avatar
Great-tailed Grackle
to do something like this:
<div
  className={clsx(
    'sticky top-0 z-50 shadow-sm',
    condition && 'bg-background/80 backdrop blur-md'
  )}
/>
Answer