About CSS variables

The CSS variable system is a two-layer theming system where global variables inform component variables.

Global variables

Global variables define and enforce global style elements (like values for color, spacing, and font size) across the entire system.

Global variables follow this formula:

--pf-global--concept--PropertyCamelCase--modifier--state

Where...

  • A concept is something like a spacer or main-title.
  • A PropertyCamelCase is something like BackgroundColor or FontSize.
  • A modifier is something like sm or lg.
  • A state is something like hover or expanded.

Component variables

Component variables are used to define custom properties at the component-level. Component variables are always defined by global variables.

Component variables follow this formula:

--pf-c-block__element--modifier--state--breakpoint--pseudo-element--PropertyCamelCase

Where...

  • pf-c-block refers to the block, usually the component or layout name, like pf-c-alert.
  • __element refers to the element inside of the block, like __title.
  • modifier is prefixed with -m and refers to a modifier class such as .pf-m-danger.
  • state is something like hover or active.
  • breakpoint is a media query breakpoint such as sm for $pf-global--breakpoint--xs.
  • pseudo-element is either before or after.

Using the variable system

PatternFly 4 styles provide a default starting point. You can use the variable system to make adjustments to that default styling. When you change one or more elements, you should package those values into a new SCSS stylesheet to replace the default styling.

Global CSS variables

--pf-global--BackgroundColor--100global_BackgroundColor_100#fff
--pf-global--BackgroundColor--150global_BackgroundColor_150#f5f5f5
--pf-global--BackgroundColor--200global_BackgroundColor_200#fafafa
--pf-global--BackgroundColor--300global_BackgroundColor_300#ededed
--pf-global--BackgroundColor--dark-100global_BackgroundColor_dark_100#151515
--pf-global--BackgroundColor--dark-200global_BackgroundColor_dark_200#3c3f42
--pf-global--BackgroundColor--dark-300global_BackgroundColor_dark_300#212427
--pf-global--BackgroundColor--dark-400global_BackgroundColor_dark_400#4f5255
--pf-global--BackgroundColor--dark-transparent-100global_BackgroundColor_dark_transparent_100rgba(3,3,3,.62)
--pf-global--BackgroundColor--dark-transparent-200global_BackgroundColor_dark_transparent_200rgba(3,3,3,.32)
--pf-global--BackgroundColor--light-100global_BackgroundColor_light_100#fff
--pf-global--BackgroundColor--light-200global_BackgroundColor_light_200#fafafa
--pf-global--BackgroundColor--light-300global_BackgroundColor_light_300#ededed
--pf-global--BorderColor--100global_BorderColor_100#d2d2d2
--pf-global--BorderColor--200global_BorderColor_200#8a8d90
--pf-global--BorderColor--300global_BorderColor_300#ededed
--pf-global--BorderColor--dark-100global_BorderColor_dark_100#d2d2d2
--pf-global--BorderColor--light-100global_BorderColor_light_100#b8bbbe
--pf-global--BorderRadius--lgglobal_BorderRadius_lg30em
--pf-global--BorderRadius--smglobal_BorderRadius_sm3px
--pf-global--BorderWidth--lgglobal_BorderWidth_lg3px
--pf-global--BorderWidth--mdglobal_BorderWidth_md2px
--pf-global--BorderWidth--smglobal_BorderWidth_sm1px
--pf-global--BoxShadow--insetglobal_BoxShadow_insetinset 0 0 0.625rem 0 rgba(3,3,3,.25)
--pf-global--BoxShadow--lgglobal_BoxShadow_lg0 0.1875rem 0.4375rem 0.1875rem rgba(3,3,3,.13),0 0.6875rem 1.5rem 1rem rgba(3,3,3,.12)
--pf-global--BoxShadow--lg-bottomglobal_BoxShadow_lg_bottom0 0.75rem 0.625rem -0.25rem rgba(3,3,3,.07)
--pf-global--BoxShadow--lg-leftglobal_BoxShadow_lg_left-0.75rem 0 0.625rem -0.25rem rgba(3,3,3,.07)
--pf-global--BoxShadow--lg-rightglobal_BoxShadow_lg_right0.75rem 0 0.625rem -0.25rem rgba(3,3,3,.07)
--pf-global--BoxShadow--lg-topglobal_BoxShadow_lg_top0 -0.75rem 0.625rem -0.25rem rgba(3,3,3,.07)
--pf-global--BoxShadow--mdglobal_BoxShadow_md0 0.0625rem 0.0625rem 0rem rgba(3,3,3,.05),0 0.25rem 0.5rem 0.25rem rgba(3,3,3,.06)
--pf-global--BoxShadow--md-bottomglobal_BoxShadow_md_bottom0 0.3125rem 0.625rem -0.25rem rgba(3,3,3,.25)
--pf-global--BoxShadow--md-leftglobal_BoxShadow_md_left-0.3125rem 0 0.625rem -0.25rem rgba(3,3,3,.25)
--pf-global--BoxShadow--md-rightglobal_BoxShadow_md_right0.3125rem 0 0.625rem -0.25rem rgba(3,3,3,.25)
--pf-global--BoxShadow--md-topglobal_BoxShadow_md_top0 -0.3125rem 0.625rem -0.25rem rgba(3,3,3,.25)
--pf-global--BoxShadow--smglobal_BoxShadow_sm0 0.0625rem 0.125rem 0 rgba(3,3,3,.2)
--pf-global--BoxShadow--sm-bottomglobal_BoxShadow_sm_bottom0 0.25rem 0.625rem -0.25rem rgba(3,3,3,.12)
--pf-global--BoxShadow--sm-leftglobal_BoxShadow_sm_left-0.25rem 0 0.625rem -0.25rem rgba(3,3,3,.12)
--pf-global--BoxShadow--sm-rightglobal_BoxShadow_sm_right0.25rem 0 0.625rem -0.25rem rgba(3,3,3,.12)
--pf-global--BoxShadow--sm-topglobal_BoxShadow_sm_top0 -0.25rem 0.625rem -0.25rem rgba(3,3,3,.12)
--pf-global--Color--100global_Color_100#151515
--pf-global--Color--200global_Color_200#737679
--pf-global--Color--300global_Color_300#3c3f42
--pf-global--Color--400global_Color_400#8a8d90
--pf-global--Color--dark-100global_Color_dark_100#151515
--pf-global--Color--dark-200global_Color_dark_200#737679
--pf-global--Color--light-100global_Color_light_100#fff
--pf-global--Color--light-200global_Color_light_200#ededed
--pf-global--Color--light-300global_Color_light_300#d2d2d2
--pf-global--FontFamily--heading--sans-serifglobal_FontFamily_heading_sans_serifRedHatDisplay,Overpass,overpass,helvetica,arial,sans-serif
--pf-global--FontFamily--monospaceglobal_FontFamily_monospaceoverpass-mono,overpass-mono,SFMono-Regular,menlo,monaco,consolas,Liberation Mono,Courier New,monospace
--pf-global--FontFamily--redhatfont--heading--sans-serifglobal_FontFamily_redhatfont_heading_sans_serifRedHatDisplay,Overpass,overpass,helvetica,arial,sans-serif
--pf-global--FontFamily--redhatfont--sans-serifglobal_FontFamily_redhatfont_sans_serifRedHatText,Overpass,overpass,helvetica,arial,sans-serif
--pf-global--FontFamily--sans-serifglobal_FontFamily_sans_serifRedHatText,Overpass,overpass,helvetica,arial,sans-serif
--pf-global--FontSize--2xlglobal_FontSize_2xl1.5rem
--pf-global--FontSize--3xlglobal_FontSize_3xl1.75rem
--pf-global--FontSize--4xlglobal_FontSize_4xl2.25rem
--pf-global--FontSize--lgglobal_FontSize_lg1.125rem
--pf-global--FontSize--mdglobal_FontSize_md1rem
--pf-global--FontSize--smglobal_FontSize_sm0.875rem
--pf-global--FontSize--xlglobal_FontSize_xl1.25rem
--pf-global--FontSize--xsglobal_FontSize_xs0.75rem
--pf-global--FontWeight--boldglobal_FontWeight_bold700
--pf-global--FontWeight--lightglobal_FontWeight_light300
--pf-global--FontWeight--normalglobal_FontWeight_normal400
--pf-global--FontWeight--redhatfont--boldglobal_FontWeight_redhatfont_bold700
--pf-global--FontWeight--semi-boldglobal_FontWeight_semi_bold700
--pf-global--LineHeight--mdglobal_LineHeight_md1.5
--pf-global--LineHeight--smglobal_LineHeight_sm1.3
--pf-global--ListStyleglobal_ListStyledisc outside
--pf-global--TimingFunctionglobal_TimingFunctioncubic-bezier(0.645,0.045,0.355,1)
--pf-global--Transitionglobal_Transitionall 250ms cubic-bezier(0.42,0,0.58,1)
--pf-global--TransitionDurationglobal_TransitionDuration250ms
--pf-global--ZIndex--2xlglobal_ZIndex_2xl600
--pf-global--ZIndex--lgglobal_ZIndex_lg400
--pf-global--ZIndex--mdglobal_ZIndex_md300
--pf-global--ZIndex--smglobal_ZIndex_sm200
--pf-global--ZIndex--xlglobal_ZIndex_xl500
--pf-global--ZIndex--xsglobal_ZIndex_xs100
--pf-global--active-color--100global_active_color_100#06c
--pf-global--active-color--200global_active_color_200#bee1f4
--pf-global--active-color--300global_active_color_300#73bcf7
--pf-global--active-color--400global_active_color_400#2b9af3
--pf-global--arrow--widthglobal_arrow_width0.9375rem
--pf-global--arrow--width-lgglobal_arrow_width_lg1.5625rem
--pf-global--breakpoint--2xlglobal_breakpoint_2xl1450px
--pf-global--breakpoint--lgglobal_breakpoint_lg992px
--pf-global--breakpoint--mdglobal_breakpoint_md768px
--pf-global--breakpoint--smglobal_breakpoint_sm576px
--pf-global--breakpoint--xlglobal_breakpoint_xl1200px
--pf-global--breakpoint--xsglobal_breakpoint_xs0
--pf-global--danger-color--100global_danger_color_100#c9190b
--pf-global--danger-color--200global_danger_color_200#a30000
--pf-global--danger-color--300global_danger_color_300#470000
--pf-global--default-color--100global_default_color_100#73c5c5
--pf-global--default-color--200global_default_color_200#009596
--pf-global--default-color--300global_default_color_300#003737
--pf-global--disabled-color--100global_disabled_color_100#737679
--pf-global--disabled-color--200global_disabled_color_200#d2d2d2
--pf-global--disabled-color--300global_disabled_color_300#ededed
--pf-global--font-pathglobal_font_path./assets/fonts
--pf-global--fonticon-pathglobal_fonticon_path./assets/pficon
--pf-global--golden-ratioglobal_golden_ratio1.681
--pf-global--gutterglobal_gutter1.5rem
--pf-global--gutter--mdglobal_gutter_md1rem
--pf-global--icon--Color--darkglobal_icon_Color_dark#151515
--pf-global--icon--Color--lightglobal_icon_Color_light#737679
--pf-global--icon--FontSize--lgglobal_icon_FontSize_lg1.5rem
--pf-global--icon--FontSize--mdglobal_icon_FontSize_md1.125rem
--pf-global--icon--FontSize--smglobal_icon_FontSize_sm0.625rem
--pf-global--icon--FontSize--xlglobal_icon_FontSize_xl3.375rem
--pf-global--info-color--100global_info_color_100#73bcf7
--pf-global--info-color--200global_info_color_200#004368
--pf-global--link--Colorglobal_link_Color#06c
--pf-global--link--Color--darkglobal_link_Color_dark#06c
--pf-global--link--Color--dark--hoverglobal_link_Color_dark_hover#004080
--pf-global--link--Color--hoverglobal_link_Color_hover#004080
--pf-global--link--Color--lightglobal_link_Color_light#73bcf7
--pf-global--link--Color--light--hoverglobal_link_Color_light_hover#2b9af3
--pf-global--link--FontWeightglobal_link_FontWeight400
--pf-global--link--TextDecorationglobal_link_TextDecorationunderline
--pf-global--link--TextDecoration--hoverglobal_link_TextDecoration_hoverunderline
--pf-global--primary-color--100global_primary_color_100#06c
--pf-global--primary-color--200global_primary_color_200#004080
--pf-global--primary-color--dark-100global_primary_color_dark_100#06c
--pf-global--primary-color--light-100global_primary_color_light_100#73bcf7
--pf-global--secondary-color--100global_secondary_color_100#737679
--pf-global--spacer--2xlglobal_spacer_2xl3rem
--pf-global--spacer--3xlglobal_spacer_3xl4rem
--pf-global--spacer--form-elementglobal_spacer_form_element0.375rem
--pf-global--spacer--lgglobal_spacer_lg1.5rem
--pf-global--spacer--mdglobal_spacer_md1rem
--pf-global--spacer--smglobal_spacer_sm0.5rem
--pf-global--spacer--xlglobal_spacer_xl2rem
--pf-global--spacer--xsglobal_spacer_xs0.25rem
--pf-global--success-color--100global_success_color_100#92d400
--pf-global--success-color--200global_success_color_200#486b00
--pf-global--target-size--MinHeightglobal_target_size_MinHeight44px
--pf-global--target-size--MinWidthglobal_target_size_MinWidth44px
--pf-global--warning-color--100global_warning_color_100#f0ab00
--pf-global--warning-color--200global_warning_color_200#795600