Skip to content

Commit ed76cd7

Browse files
feat(ui): Add fontFamilyMono variable (#8546)
1 parent 1a4d7d1 commit ed76cd7

4 files changed

Lines changed: 15 additions & 2 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/ui': minor
3+
---
4+
5+
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.

packages/ui/src/customizables/parseVariables.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ export const createFontWeightScale = (theme: Theme): Partial<Record<keyof typeof
177177
};
178178

179179
export const createFonts = (theme: Theme) => {
180-
const { fontFamily, fontFamilyButtons } = theme.variables || {};
181-
return removeUndefinedProps({ main: fontFamily, buttons: fontFamilyButtons });
180+
const { fontFamily, fontFamilyButtons, fontFamilyMono } = theme.variables || {};
181+
return removeUndefinedProps({ main: fontFamily, buttons: fontFamilyButtons, mono: fontFamilyMono });
182182
};
183183

184184
export const createShadowsUnits = (theme: Theme) => {

packages/ui/src/foundations/typography.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ const fontStyles = Object.freeze({
4545
const fonts = Object.freeze({
4646
main: clerkCssVar('font-family', 'inherit'),
4747
buttons: clerkCssVar('font-family-buttons', clerkCssVar('font-family', 'inherit')),
48+
mono: clerkCssVar('font-family-mono', 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace'),
4849
} as const);
4950

5051
export { fontSizes, fontWeights, letterSpacings, lineHeights, fonts, fontStyles };

packages/ui/src/internal/appearance.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,13 @@ export type Variables = {
824824
* @default 'inherit'
825825
*/
826826
fontFamilyButtons?: FontFamily;
827+
/**
828+
* The default monospace font that will be used for monospaced text (e.g. code, OTP inputs).
829+
* See {@link Variables.fontFamily} for details on accepted values.
830+
*
831+
* @default 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace'
832+
*/
833+
fontFamilyMono?: FontFamily;
827834
/**
828835
* The value will be used as the base `md` to calculate all the other scale values (`xs`, `sm`, `lg` and `xl`).
829836
* By default, this value is relative to the root fontSize of the html element.

0 commit comments

Comments
 (0)