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.
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.
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.
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.
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 overriden 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.
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 |