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:
markup
bash
clike
c
cpp
css
"css-extras"
javascript
jsx
"js-extras"
coffeescript
diff
git
go
graphql
handlebars
json
less
makefile
markdown
objectivec
ocaml
python
reason
sass
scss
sql
stylus
typescript
wasm
yaml
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.base
console.log('hello world')
HighlightedCode.styles.block
console.log('hello world')
HighlightedCode.Pre.styles.base
console.log('hello world')
HighlightedCode.Line.styles.base
console.log('hello world')
HighlightedCode.Token.styles.base
console.log('hello world')
On this page