Files
DataStack/components/ui/Text.tsx
T

39 lines
1.3 KiB
TypeScript
Raw Normal View History

2026-10-23 11:43:49 -05:00
import { cn } from '@/lib/utils';
2026-10-23 19:56:38 -07:00
import React from 'react';
2026-10-23 11:43:49 -05:00
interface TextProps extends React.HTMLAttributes<HTMLElement> {
as?: 'h1' | 'h2' | 'h3' | 'h4' | 'p' | 'span' | 'label' | 'code' | 'div';
variant?: 'h1' | 'h2' | 'h3' | 'body' | 'muted' | 'dim' | 'label' | 'code' | 'badge';
children: React.ReactNode;
}
export const Text: React.FC<TextProps> = ({
as: Component = 'p',
variant = 'body',
className,
children,
...props
}) => {
const variantStyles = {
h1: 'text-[16px] font-medium tracking-tight text-[var(--text)]',
h2: 'text-[14px] font-medium tracking-tight text-[var(--text)]',
h3: 'text-[12.5px] font-medium text-[var(--text)]',
body: 'text-[13px] font-normal text-[var(--text)]',
muted: 'text-[12px] font-normal text-[var(--text-muted)]',
dim: 'text-[11px] font-normal text-[var(--text-dim)]',
label: 'text-[10.5px] font-medium uppercase tracking-wider text-[var(--text-muted)]',
code: 'text-[11.5px] font-mono text-[var(--accent)] bg-[var(--bg-hover)] px-1.5 py-0.5 border border-[var(--border)]',
badge: 'text-[10.5px] font-medium px-1.5 py-0.5 border border-[var(--border)] text-[var(--text-muted)] inline-flex items-center gap-1',
2026-10-23 11:43:49 -05:00
};
return (
<Component
className={cn(variantStyles[variant], className)}
{...props}
>
{children}
</Component>
);
};
export default Text;