Theming

All Backpack components have full theming support through through the theme provider component. In the render tree, all themeable components will have access to the provided theme, even when they are multiple levels deep.

About

Theming is based on CSS Variables and is not supported in some older browsers.

In these cases, Backpack components will gracefully degrade to the default Skyscanner theme. To check browser support, see caniuse.com.

bpk-theming

Backpack theming utilities.

Installation

Check the main Readme for a complete installation guide.

Usage


                                                
                                                import BpkThemeProvider from '@skyscanner/backpack-web/bpk-theming';
                                                
                                                import BpkLink, { themeAttributes as linkThemeAttributes } from '@skyscanner/backpack-web/bpk-component-link';
                                                
                                                const theme = {
                                                  linkColor: '#c00',
                                                  linkHoverColor: '#d00',
                                                  linkActiveColor: '#a00',
                                                  linkVisitedColor: '#800',
                                                };
                                                
                                                export default class App extends Component {
                                                  render() {
                                                    return (
                                                      <BpkThemeProvider theme={theme} themeAttributes={[...linkThemeAttributes]}>
                                                        <BpkLink onClick={() => {}}>Book flight</BpkLink>
                                                      </BpkThemeProvider>
                                                    );
                                                  }
                                                }

Props

Property PropType Required Default Value
children node true -
themeAttributes arrayOf(string) true -
component elementType false div
theme object false null