Skip to content

Instantly share code, notes, and snippets.

@jacksonblankenship
Created March 8, 2024 14:11
Show Gist options
  • Save jacksonblankenship/cb7a6f4039a7b313d9421d0da0d0db72 to your computer and use it in GitHub Desktop.
Save jacksonblankenship/cb7a6f4039a7b313d9421d0da0d0db72 to your computer and use it in GitHub Desktop.
Random Component
import { VariantProps, cva } from 'class-variance-authority';
import { ComponentPropsWithoutRef, forwardRef } from 'react';
import clsx from 'clsx';
import styles from './EnvLabel.module.scss';
export const envLabelCva = cva(styles.root, {
variants: {
environment: {
dev: styles.dev,
test: styles.test,
prod: styles.prod,
},
},
defaultVariants: {},
});
interface EnvLabelProps extends ComponentPropsWithoutRef<'span'>, VariantProps<typeof envLabelCva> {}
export const EnvLabel = forwardRef<HTMLSpanElement, EnvLabelProps>(({ className, environment, ...props }, ref) => (
<span
{...props}
className={clsx(envLabelCva({ environment }), className)}
ref={ref}>
{environment}
</span>
));
EnvLabel.displayName = 'EnvLabel';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment