Skip to main content
Elastic UI
Elastic UI
Getting startedComponentsPatternsContentData visualization
EUI ChangelogGitHubFigma
  • Setup
  • Theming
    • Theme provider
    • Tokens
      • Borders
      • Breakpoints
      • Colors
      • Sizing
      • Typography
    • Color mode
    • High contrast mode
    • Utilities
  • Accessibility
  • Testing
  • Utilities
  • EUI
  • Theming
  • Tokens
  • Breakpoints

Breakpoints


For most of your usages we recommend using the

responsive utilities instead of consuming the theme values directly.

Default values

If you want to align your custom responsive styles with EUI's breakpoints, or when using components that accept our named breakpoints, you'll want to utilize the following default values and provided hooks.

useCurrentEuiBreakpoint() hook

This hook returns the named breakpoint size of the current browser window width, responsively updating whenever the window is resized.

The hook automatically inherits breakpoint sizes from the current EUI theme and any theme overrides.

Current breakpoint:

โœ„๐˜—
tsx code block:
โœ„๐˜—const currentBreakpoint = useCurrentEuiBreakpoint()

useIsWithinBreakpoints(sizes[], isResponsive?) hook

This hook returns true or false if the current browser window width is within the passed breakpoint sizes. The isResponsive parameter allows it to easily be turned on/off from within your component.

You can also use useIsWithinMaxBreakpoint(size) and useIsWithinMinBreakpoint(size). The min/max hooks return true or false if the current browser window width is above or below the passed breakpoint size respectively.

These hooks automatically inherits breakpoint sizes from the current EUI theme and any theme overrides.

Targeting large devices only:

Targeting medium devices and below:

Targeting small devices and above:

โœ„๐˜—
tsx code block:
โœ„๐˜—useIsWithinBreakpoints(['l', 'xl']) useIsWithinMaxBreakpoint('m') useIsWithinMinBreakpoint('s')

useEuiBreakpoint(sizes[]) hook

Given an array of screen sizes, this hook generates a CSS media query string based on the minimum and maximum screen sizes provided.

This text is bold on small to large screens, red on small and below screens, yellow on medium screens, and green on large and above screens.

โœ„๐˜—
tsx code block:
โœ„๐˜—${useEuiBreakpoint(['s', 'l'])} { font-weight: bold; } ${useEuiBreakpoint(['xs', 's'])} { color: red; } ${useEuiBreakpoint(['m'])} { color: yellow; } ${useEuiBreakpoint(['l', 'xl'])} { color: green; }

useEuiMaxBreakpoint(size) and useEuiMinBreakpoint(size) hook

Given a single breakpoint key, these hooks generate a min or max CSS media query string based on the single breakpoint dimension returned.

This text is red on screens below the medium breakpoint, and green on screens above.

โœ„๐˜—
tsx code block:
โœ„๐˜—css` ${useEuiMaxBreakpoint('m')} { color: red; } ${useEuiMinBreakpoint('m')} { color: green; } `
๐˜‚๐˜‚
โœ„๐˜—โœ„๐˜—
Sample
โ†ฆ
Token
โ†ฆ
Value
โ†ต
ย breakpoint.xs
โ†ฆ
breakpoint.xs
โ†ฆ
Value
0
โ†ต
ย breakpoint.s
โ†ฆ
breakpoint.s
โ†ฆ
Value
575
โ†ต
ย breakpoint.m
โ†ฆ
breakpoint.m
โ†ฆ
Value
768
โ†ต
ย breakpoint.l
โ†ฆ
breakpoint.l
โ†ฆ
Value
992
โ†ต
ย breakpoint.xl
โ†ฆ
breakpoint.xl
โ†ฆ
Value
1200
โ†ต
๐˜‚๐˜‚

Custom values

EUI's theme breakpoints can be overridden and extended. However, the default sizes (xl through xs) will always be present and cannot be removed.

EuiProvider theme

Theme breakpoints can be overridden or added via EuiProvider's or EuiThemeProvider's modify prop.

Excluding a default breakpoint key in your breakpoint override will use the EUI default value for that size as a fallback.

Current custom breakpoint:
โœ„๐˜—
tsx code block:
โœ„๐˜—<EuiThemeProvider modify={{ breakpoint: { xxs: 0, xs: 250, s: 500, m: 1000, l: 1500, xl: 2000, xxl: 2500, }, }} > <App /> </EuiThemeProvider>
๐˜‚๐˜‚
โœ„๐˜—โœ„๐˜—
Sample
โ†ฆ
Token
โ†ฆ
Value
โ†ต
ย breakpoint.xxs
โ†ฆ
breakpoint.xxs
โ†ฆ
Value
0
โ†ต
ย breakpoint.xs
โ†ฆ
breakpoint.xs
โ†ฆ
Value
250
โ†ต
ย breakpoint.s
โ†ฆ
breakpoint.s
โ†ฆ
Value
500
โ†ต
ย breakpoint.m
โ†ฆ
breakpoint.m
โ†ฆ
Value
1000
โ†ต
ย breakpoint.l
โ†ฆ
breakpoint.l
โ†ฆ
Value
1500
โ†ต
ย breakpoint.xl
โ†ฆ
breakpoint.xl
โ†ฆ
Value
2000
โ†ต
ย breakpoint.xxl
โ†ฆ
breakpoint.xxl
โ†ฆ
Value
2500
โ†ต
๐˜‚๐˜‚
Edit this page

Previous
Borders
Next
Colors
  • Default values
    • useCurrentEuiBreakpoint() hook
    • useIsWithinBreakpoints(sizes[], isResponsive?) hook
    • useEuiBreakpoint(sizes[]) hook
    • useEuiMaxBreakpoint(size) and useEuiMinBreakpoint(size) hook
  • Custom values
    • EuiProvider theme
EUI is dual-licensed under Elastic License 2.0 and Server Side Public License, v 1 | Crafted with โค by Elastic