Code

The code component can be used to format a piece of text or entire text block as code.

Default

Use BpkCode for inline code blocks.

Storybook failed to load.

Alternate

Use the alternate prop for displaying on dark backgrounds.

Storybook failed to load.

Block

For a block of code, use BpkCodeBlock.

Storybook failed to load.

Block alternate

Use the alternate prop for displaying on dark backgrounds.

Storybook failed to load.

bpk-component-code

Backpack code component.

Installation

Check the main Readme for a complete installation guide.

Usage


                                                
                                                import { BpkCode, BpkCodeBlock } from '@skyscanner/backpack-web/bpk-component-code';
                                                import BpkText from '@skyscanner/backpack-web/bpk-component-text';
                                                
                                                const codeBlock = `import React from 'react';
                                                import ReactDOM from 'react-dom';
                                                
                                                ReactDOM.render(<App />, ...);`;
                                                
                                                export default () => (
                                                  <div>
                                                    <BpkText tagName='p'>
                                                      We recommend using React from npm with a bundler like webpack. You can use
                                                      the <BpkCode>react</BpkCode> and <BpkCode>react-dom</BpkCode> packages. After installing it
                                                      using <BpkCode>npm install --save react react-dom</BpkCode>, you can use:
                                                    </BpkText>
                                                    <BpkCodeBlock>{codeBlock}</BpkCodeBlock>
                                                  </div>
                                                );

Props

Check out the full list of props on Skyscanner's design system documentation website.

Props

Storybook failed to load.