HighlightedCode#
The <HighlightedCode> component uses Prism React Renderer under the hood.
Install#
yarn add bumbag-addon-highlighted-code// or npmnpm install bumbag-addon-highlighted-code
Import#
import HighlightedCode from 'bumbag-addon-highlighted-code'
Usage#
console.log('Hello world')<Box><Text color="primary">Hello world</Text></Box>
Editable example
The following languages are supported:
markupbashclikeccppcss"css-extras"javascriptjsx"js-extras"coffeescriptdiffgitgographqlhandlebarsjsonlessmakefilemarkdownobjectivecocamlpythonreasonsassscsssqlstylustypescriptwasmyaml
HighlightedCode Props#
code string
The code to be placed into the highlighted code area.
language string
Language of the code.
isBlock boolean
Should the code appear as a block?
preProps Object
lineProps Object
tokenProps Object
wrapperProps Object
Inherits Box props
use
string
| (ComponentClass<any, any> & { useProps: any; })
| (FunctionComponent<any> & { useProps: any; })className string
children
string
| number
| boolean
| {}
| ReactElement<any, string
| ((props: any) => ReactElement<any, string
| ...
| (new (props: any) => Component<any, any, any>)>)
| (new (props: any) => Component<...>)>
| ReactNodeArray
| ReactPortal
| ((props: BoxProps) => ReactNode)alignX "right" | "left" | "center"
alignY "top" | "bottom" | "center"
variant string
colorMode string
disabled boolean
overrides
{
useCSSVariables?: boolean;
altitudes?: AltitudesThemeConfig;
borders?: BordersThemeConfig;
borderRadii?: BorderRadiiThemeConfig;
... 95 more ...;
Template?: TemplateThemeConfig;
}elementRef ((instance: any) => void) | RefObject<any>
themeKey string
Theming#
HighlightedCode.styles.baseconsole.log('hello world')HighlightedCode.styles.blockconsole.log('hello world')
HighlightedCode.Pre.styles.baseconsole.log('hello world')
HighlightedCode.Line.styles.baseconsole.log('hello world')
HighlightedCode.Token.styles.baseconsole.log('hello world')
On this page
