<CH.Code>
With <CH.Code>
you can show code files in tabs or panels. You can also pass props to override configuration or customize styling.
Tabs
When you include more than one code blocks inside a <CH.Code>
, Code Hike will show them as tabs.
Panels
You can also show two files at the same time in two panels. Use a divider ---
to separate the top tabs from the bottom tabs.
Override configuration
You can override some of the configuration options by passing props to <CH.Code>
.
Styling props
Then there are the style
and className
props. You can use them to customize the styles of the component.
Height
By default, <CH.Code>
will take the height needed to fit all the lines of the given code. As we saw in the previous example, you can use CSS to set a fixed height.
Instead of setting the height with CSS, you can also use the rows
prop. You pass the number of lines you want to show, and Code Hike will set the height accordingly.
In addition to the number of lines, you can also pass "focus"
, then the height of the code will match the height of the focused lines.