diff --git a/.changeset/font-family-mono-variable.md b/.changeset/font-family-mono-variable.md new file mode 100644 index 00000000000..6d940688c5b --- /dev/null +++ b/.changeset/font-family-mono-variable.md @@ -0,0 +1,5 @@ +--- +'@clerk/ui': minor +--- + +Add `fontFamilyMono` appearance variable for customizing the monospace font used in Clerk components. Defaults to `ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace` and is exposed as the `--clerk-font-family-mono` CSS variable. diff --git a/packages/ui/src/customizables/parseVariables.ts b/packages/ui/src/customizables/parseVariables.ts index d14d7fe8ec2..2de4e89b5dd 100644 --- a/packages/ui/src/customizables/parseVariables.ts +++ b/packages/ui/src/customizables/parseVariables.ts @@ -177,8 +177,8 @@ export const createFontWeightScale = (theme: Theme): Partial { - const { fontFamily, fontFamilyButtons } = theme.variables || {}; - return removeUndefinedProps({ main: fontFamily, buttons: fontFamilyButtons }); + const { fontFamily, fontFamilyButtons, fontFamilyMono } = theme.variables || {}; + return removeUndefinedProps({ main: fontFamily, buttons: fontFamilyButtons, mono: fontFamilyMono }); }; export const createShadowsUnits = (theme: Theme) => { diff --git a/packages/ui/src/foundations/typography.ts b/packages/ui/src/foundations/typography.ts index 162bffd77d7..8c162a7780e 100644 --- a/packages/ui/src/foundations/typography.ts +++ b/packages/ui/src/foundations/typography.ts @@ -45,6 +45,7 @@ const fontStyles = Object.freeze({ const fonts = Object.freeze({ main: clerkCssVar('font-family', 'inherit'), buttons: clerkCssVar('font-family-buttons', clerkCssVar('font-family', 'inherit')), + mono: clerkCssVar('font-family-mono', 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace'), } as const); export { fontSizes, fontWeights, letterSpacings, lineHeights, fonts, fontStyles }; diff --git a/packages/ui/src/internal/appearance.ts b/packages/ui/src/internal/appearance.ts index 0c4f546d50c..2bd013e5056 100644 --- a/packages/ui/src/internal/appearance.ts +++ b/packages/ui/src/internal/appearance.ts @@ -824,6 +824,13 @@ export type Variables = { * @default 'inherit' */ fontFamilyButtons?: FontFamily; + /** + * The default monospace font that will be used for monospaced text (e.g. code, OTP inputs). + * See {@link Variables.fontFamily} for details on accepted values. + * + * @default 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace' + */ + fontFamilyMono?: FontFamily; /** * The value will be used as the base `md` to calculate all the other scale values (`xs`, `sm`, `lg` and `xl`). * By default, this value is relative to the root fontSize of the html element.