Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

useFontFamily.ts

15 lines481 Bytes

1import { useCSSVariable } from "uniwind";
2​
3const FONT_FAMILY_VARIABLES = {
4 regular: "--font-sans",
5 medium: "--font-medium",
6 bold: "--font-bold",
7} as const;
8​
9/**
10 * Resolves a font family for APIs that require a style object or native prop.
11 * Prefer Uniwind font classes when the target component accepts `className`.
12 */
13export function useFontFamily(weight: keyof typeof FONT_FAMILY_VARIABLES): string {
14 return useCSSVariable(FONT_FAMILY_VARIABLES[weight]) as string;