Snippets

Merge classNames helper

React CSS clsx

Simple version

export const cn = (...classes: (boolean | string)[]) =>
  classes.filter(Boolean).join(' ');

Advanced version with twMerge

import { clsx, type ClassValue } from 'clsx';
import { twMerge } from 'tailwind-merge';

export function cn(...classes: ClassValue[]) {
  return twMerge(clsx(classes));
}