Skip to content

Font Size for DNB

For details about what values Typographic elements use, have a look at the Fonts & Typography documentation.

Default font-size rem table

PixelTypeRemCSS variable / propertyCSS ClassnameInfo
14pxx-small0.875rem--font-size-x-small.dnb-t__size--x-smallDo not use for texts
16pxsmall1rem--font-size-small.dnb-t__size--smallFallback
18pxbasis1.125rem--font-size-basis.dnb-t__size--basisDefault size
20pxmedium1.25rem--font-size-medium.dnb-t__size--medium
26pxlarge1.625rem--font-size-large.dnb-t__size--large
34pxx-large2.125rem--font-size-x-large.dnb-t__size--x-large
48pxxx-large3rem--font-size-xx-large.dnb-t__size--xx-large

Responsive typography (BETA)

NB: This feature is in beta and may be subject to change.

Wrap a section of your UI in <Typography.Context responsive> to enable typography that adapts automatically across breakpoints. Typography components inside the wrapper, like H2, Span, P, Heading, will start using the responsive variables in the table below.

You can turn it off for a section using <Typography.Context responsive={false}>.

CSS Variable← smallsmall → mediummedium →
--responsive-font-size-x-small0.8125rem0.875rem0.875rem
--responsive-font-size-small0.875rem1rem1rem
--responsive-font-size-basis1rem1.125rem1.125rem
--responsive-font-size-medium1.125rem1.25rem1.25rem
--responsive-font-size-large1.25rem1.625rem1.625rem
--responsive-font-size-x-large1.625rem2.125rem2.125rem
--responsive-font-size-xx-large2.125rem3rem3rem

All --responsive-font-size-* CSS variables are scoped to typography components (P, Heading, Span, Lead, H1, H2, etc.) as of now. If you need to use them elsewhere use the .dnb-t class.

Code Editor Extensions

You may be interested in installing an Eufemia code editor extension that allows you to quickly auto complete the correct font-size.

Additional font-size em table

PixelTypeEmCustom PropertyInfo
16pxbasis--em1em--font-size-basis--em

How to use the sizes (CSS)

/* I have a default size */
.dnb-p {
font-size: var(--font-size-basis); /* 1.125rem = 18px (in Ui theme) */
}

Fallback font-size

If no specific font-size is defined, we still use 1rem as the basis. This is because we use the basis font-size for many other layout related purposes.