الطباعة
عائلات خط Geist وأساسيات الطباعة.
تشحن Flow UI عائلتَي خطوط — Geist Sans و Geist Mono — ومجموعة صغيرة من مكوّنات React الطباعية التي تغلّف أكثر أدوار النص شيوعًا.
الخطوط
كلاهما يُستضاف ذاتيًا — ملفات woff2 مُضمَّنة داخل الحزمة (src/styles/fonts/) ومُسجَّلة عبر fonts.css، فيحزمها المستهلكون مباشرةً دون أي طلب خط خارجي. تُحمَّل بـ font-display: swap (FOUT لا FOIT) بحيث يظهر النص فورًا.
Geist Sans
خط متغيّر، أوزان 100–900، مع محور مائل. استخدمه لأي شيء ليس دوره monospace.
font-family: var(--font-sans);Geist Mono
متغيّر، أوزان 100–900، مع مائل. استخدمه للكود، مفاتيح لوحة المفاتيح، مخرجات الطرفية، وأي سياق يهمّ فيه محاذاة الأحرف.
font-family: var(--font-mono);سُلّم أحجام النص
كل حجم يقع على متغيّر CSS. أدوات Tailwind من text-xs إلى text-9xl تُعيَّن إلى هذه التوكنات.
راجع التوكنات ← سُلّم الأحجام للقائمة الكاملة.
المكوّنات
استورد من @flow-industries/ui/components/typography. الصادرات: Title، Subtitle، Overline، Paragraph، Mono.
الاستخدام:
import { Title, Subtitle, Overline, Paragraph, Mono } from "@flow-industries/ui/components/typography";
<Title size="lg">مرحبًا بك في Flow</Title>
<Subtitle size="lg">منصّة لا مركزيّة.</Subtitle>
<Overline variant="brand">Now shipping</Overline>
<Paragraph>نصّ متنيّ يمتدّ لعدّة كلمات وأسطر.</Paragraph>
<Mono>bun add @flow-industries/ui</Mono>أحجام Title تُعيَّن إلى وسوم HTML: sm → <h3>، default → <h2>، md → <h2>، lg → <h1> — أو مرِّر level (1–6) لضبط وسم العنوان مباشرةً (<h1>–<h6>)، مع الإبقاء على الحجم المرئي وبقاء بنية المستند صحيحة. يُتيح Subtitle الأحجام الأربعة نفسها. يدعم Overline الخيارَين default و brand. ويقبل Paragraph الحجم size — "xs" | "sm" | "default" | "lg" — وقيمته الافتراضية "sm" وليست "default".
المصدر:
import { cn } from "../../utils/cn";
const titleStyles = {
sm: "text-sm font-semibold",
default: "text-base font-bold tracking-tighter",
md: "text-2xl font-bold tracking-tighter",
lg: "text-3xl font-bold tracking-tighter",
} as const;
const titleTags = { sm: "h3", default: "h2", md: "h2", lg: "h1" } as const;
const headingTags = {
1: "h1",
2: "h2",
3: "h3",
4: "h4",
5: "h5",
6: "h6",
} as const;
function Title({
className,
size = "default",
level,
...props
}: React.ComponentProps<"h1"> & {
size?: "sm" | "default" | "md" | "lg";
level?: 1 | 2 | 3 | 4 | 5 | 6;
}) {
const Tag = level ? headingTags[level] : titleTags[size];
return (
<Tag
data-slot="title"
className={cn(titleStyles[size], className)}
{...props}
/>
);
}
const subtitleStyles = {
sm: "text-xs font-medium text-muted-foreground",
default: "text-sm font-medium text-muted-foreground",
md: "text-base font-medium text-muted-foreground",
lg: "text-lg font-medium text-muted-foreground",
} as const;
function Subtitle({
className,
size = "default",
...props
}: React.ComponentProps<"p"> & { size?: "sm" | "default" | "md" | "lg" }) {
return (
<p
data-slot="subtitle"
className={cn(subtitleStyles[size], className)}
{...props}
/>
);
}
function Overline({
className,
variant = "default",
...props
}: React.ComponentProps<"span"> & { variant?: "default" | "brand" }) {
return (
<span
data-slot="overline"
className={cn(
"text-sm font-[550] tracking-wide",
variant === "brand" ? "text-brand-text" : "text-muted-foreground",
className,
)}
{...props}
/>
);
}
const paragraphVariants = {
xs: "text-xs",
sm: "text-sm",
default: "text-base",
lg: "text-lg",
} as const;
function Paragraph({
className,
size = "sm",
...props
}: React.ComponentProps<"p"> & { size?: "xs" | "sm" | "default" | "lg" }) {
return (
<p
data-slot="paragraph"
className={cn(
"font-[450] leading-[150%] tracking-wide text-foreground/80",
paragraphVariants[size],
className,
)}
{...props}
/>
);
}
function Mono({ className, ...props }: React.ComponentProps<"code">) {
return (
<code
data-slot="mono"
className={cn(
"text-sm font-mono tracking-normal text-muted-foreground",
className,
)}
{...props}
/>
);
}
export { Mono, Overline, Paragraph, Subtitle, Title };الاستخدام المباشر لـ Tailwind
لا شيء يمنعك من كتابة classes مباشرة — كل مكوّنات Flow تقبل className وتدمجها عبر cn():
<h1 className="font-sans text-6xl font-bold tracking-tight">Hello</h1>
<code className="font-mono text-sm">example</code>استخدم المكوّنات حين تريد افتراضات مُعتمَدة من نظام التصميم؛ وarrastre classes خامًا حين تحتاج شيئًا مُفصَّلًا.