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
  • 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
  • Theme provider

Theme provider

While

EuiProvider should not be wrapped around your application root more than once, you may use multiple nested EuiThemeProviders to customize section-specific or component-specific color modes or theme overrides.

EuiThemeProvider

The context layer that enables theming (including the default theme styles) comes from

EuiThemeProvider. EuiThemeProvider accepts four main props (all of which have default values and are therefore optional):

  • theme: Raw theme values. Calculated values are acceptable.
  • modify: Accepts an object of overrides for theme values.
    • For examples of this prop, see Simple instance overrides below.
  • colorMode: Accepts 'light', 'dark', or 'inverse'.
    • For usage, see the Color mode page.
  • highContrastMode: Accepts a true/false boolean.
    • For usage, see the High contrast mode page.

To use the default EUI theme, no configuration is required.

EUI_THEME_BOREALIS
colorMode:LIGHT
highContrastMode:false

Consuming with the React hook

Using the React hook useEuiTheme() makes it very easy to consume the EUI static and computed variables like colors and sizing. It simply passes back an object of the current theme which includes:

  • euiTheme: All the calculated keys including any modifications
  • modifications: Only the modification keys
  • colorMode: Either 'LIGHT' or 'DARK'
  • highContrastMode: Either 'forced', 'preferred', or false

When consuming the theme's keys like euiTheme.colors.primary, you'll want to pass them via the css property to take advantage of Emotion's compilation.

Loading...

Consuming with the React HOC

When using inside of a React Component, you can wrap your exported component with withEuiTheme().

Loading...

Consuming with Emotion's theming

EuiThemeProvider by default sets an Emotion theme context with the results of useEuiTheme(). This is a syntactical sugar convenience that allows you to take advantage of Emotion's styled syntax, or use a function in the css prop.

If you prefer to use or access your own custom Emotion theme, you can completely override EUI's passed theme at any time with your own ThemeProvider.

Loading...

Simple instance overrides

Usually, you won't need to actually override an EUI theme variable at the instance level. Instead, you'd just create a new variable local to that component. However, if you cannot alter the component that is using the EUI variable then you can wrap that component with the EuiThemeProvider and pass your custom object to modify.

Loading...

Creating custom keys

Because of the computed values and possible cascade effects, it may not be advisable to locally override any EUI specific theme variables. Instead, you should append custom keys to the theme.

Loading...
Edit this page

Previous
Recommendations
Next
Color mode
  • EuiThemeProvider
  • Consuming with the React hook
  • Consuming with the React HOC
  • Consuming with Emotion's theming
  • Simple instance overrides
  • Creating custom keys
EUI is dual-licensed under Elastic License 2.0 and Server Side Public License, v 1 | Crafted with ❤ by Elastic