Skip to main content
Elastic UI
Elastic UI
ComponentsPatternsContentData visualization
EUI ChangelogGitHubFigma
  • Guidelines
    • Getting started
    • Accessibility
    • Writing
    • Testing
  • Theming
    • Theme provider
    • Color mode
    • High contrast mode
    • Borders
    • Breakpoints
    • Colors
    • Sizing
    • Typography
      • Font scale
      • Font weight
      • Font settings
      • Utilities
  • Templates
    • Page template
    • Sitewide search
  • Layout
    • Accordion
    • Bottom bar
    • Flex
    • Flyout
    • Header
    • Horizontal rule
    • Modal
    • Page components
    • Page header
    • Panel
    • Popover
    • Resizable container
    • Spacer
  • Navigation
    • Breadcrumbs
    • Buttons
    • Collapsible nav
    • Context menu
    • Facet
    • Key pad menu
    • Link
    • Pagination
    • Side nav
    • Steps
    • Tabs
    • Tree view
  • Display
    • Aspect ratio
    • Avatar
    • Badge
    • Callout
    • Card
    • Comment list
    • Description list
    • Drag and drop
    • Empty prompt
    • Health
    • Icons
    • Image
    • List group
    • Loading
    • Progress
    • Skeleton
    • Stat
    • Text
    • Timeline
    • Title
    • Toast
    • Tooltip
    • Tour
  • Forms
    • Form controls
    • Form layouts
    • Form validation
    • Text controls
    • Numeric controls
    • Selection controls
    • Search and filter controls
    • Date and time controls
    • Other controls
  • Tabular content
    • Tables
    • Data grid
  • Editors & Syntax
    • Code
    • Markdown
  • Utilities
    • Accessibility
    • Auto sizer
    • Beacon
    • Color palettes
    • Copy
    • CSS utility classes
    • Delay
    • Error boundary
    • Focus trap
    • Highlight and mark
    • HTML ID generator
    • I18n
    • Inner text
    • Mutation observer
    • Outside click detector
    • Overlay mask
    • Portal
    • Pretty duration
    • Provider
    • Resize observer
    • Scroll
    • Text diff
    • Text truncation
    • Window events
  • EUI
  • Theming
  • Typography
  • Font scale

Font scale

The typographic scale is loosely based on the Major Third (1.250) typographic scale.

While these functions and hooks exist to get precise font sizing and associated line-height, we still highly recommend using the

EuiText and EuiTitle components as wrappers of your content instead.

useEuiFontSize() hook

Font sizing is provided through this React hook (or function version) and not the global theme. It returns both the font-size and line-height for the provided scale.

The quick brown fox jumped over the blue moon to catch a snail

โœ„๐˜—
tsx code block:
โœ„๐˜—css` ${useEuiFontSize('l')} `

useEuiFontSize().fontSize

To use precisely only the font-size value, you will still use the same hook (or function) to grab the individual property via the returned object.

The quick brown fox jumped over the blue moon to catch a snail

โœ„๐˜—
tsx code block:
โœ„๐˜—css` font-size: ${useEuiFontSize('xs').fontSize}; `

We strongly recommend using relative (rem or em) units instead of px when possible

Relative font units respect configured browser default font sizes, which some users may set to larger than than the 16px default due to, e.g. visual impairment, monitor size, or personal preference. Read more on accessible text resizing.

Font units

The font sizing function also supports three main units for font size and line height: rem | px | em, with rem being default for all EUI components.

Value unit to show in table
๐˜‚๐˜‚
โœ„๐˜—โœ„๐˜—
Sample
โ†ฆ
Function
โ†ฆ
Font size
โ†ฆ
Line height
โ†ต
Sample
The quick brown fox jumped over the blue moon to catch a snail
โ†ฆ
Function
โœ„๐˜—
js code block:
โœ„๐˜—useEuiFontSize('xxxs')
โ†ฆ
Font size
0.6429rem
โ†ฆ
Line height
1.1429rem
โ†ต
Sample
The quick brown fox jumped over the blue moon to catch a snail
โ†ฆ
Function
โœ„๐˜—
js code block:
โœ„๐˜—useEuiFontSize('xxs')
โ†ฆ
Font size
0.7857rem
โ†ฆ
Line height
1.1429rem
โ†ต
Sample
The quick brown fox jumped over the blue moon to catch a snail
โ†ฆ
Function
โœ„๐˜—
js code block:
โœ„๐˜—useEuiFontSize('xs')
โ†ฆ
Font size
0.8571rem
โ†ฆ
Line height
1.4286rem
โ†ต
Sample
The quick brown fox jumped over the blue moon to catch a snail
โ†ฆ
Function
โœ„๐˜—
js code block:
โœ„๐˜—useEuiFontSize('s')
โ†ฆ
Font size
1.0000rem
โ†ฆ
Line height
1.7143rem
โ†ต
Sample
The quick brown fox jumped over the blue moon to catch a snail
โ†ฆ
Function
โœ„๐˜—
js code block:
โœ„๐˜—useEuiFontSize('m')
โ†ฆ
Font size
1.1429rem
โ†ฆ
Line height
2.0000rem
โ†ต
Sample
The quick brown fox jumped over the blue moon to catch a snail
โ†ฆ
Function
โœ„๐˜—
js code block:
โœ„๐˜—useEuiFontSize('l')
โ†ฆ
Font size
1.4286rem
โ†ฆ
Line height
2.0000rem
โ†ต
Sample
The quick brown fox jumped over the blue moon to catch a snail
โ†ฆ
Function
โœ„๐˜—
js code block:
โœ„๐˜—useEuiFontSize('xl')
โ†ฆ
Font size
1.7143rem
โ†ฆ
Line height
2.2857rem
โ†ต
Sample
The quick brown fox jumped over the blue moon to catch a snail
โ†ฆ
Function
โœ„๐˜—
js code block:
โœ„๐˜—useEuiFontSize('xxl')
โ†ฆ
Font size
2.1429rem
โ†ฆ
Line height
3.1429rem
โ†ต
๐˜‚๐˜‚
Edit this page

Previous
Typography
Next
Font weight
  • useEuiFontSize() hook
  • useEuiFontSize().fontSize
EUI is dual-licensed under Elastic License 2.0 and Server Side Public License, v 1 | Crafted with โค by Elastic