name | type | description |
---|---|---|
name john | type data: Object | description Lorem ipsum dolor sit amet, consectetur adipiscing elit. |
name foo | type isVisible: boolean | description Integer sed faucibus nunc. |
name buz | type disabled: boolean | description Integer sed faucibus nunc. Nulla odio enim, molestie id mauris in, efficitur placerat ex. |
- Item 1
- One more item
- Some other item with very long text. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer sed faucibus nunc. Nulla odio enim, molestie id mauris in, efficitur placerat ex. Nam eget finibus ex.
If you pass this prop, ensure that the index or defaultIndex prop is an array.If you set foo as true, and you will have foo=true; After this text you will see a divider
- About the default value: The ch unit is a relative unit defined by the rendered typeface's "0" character width. This width varies by the shape and style of the font.
- If you are curious about the reason for this default value of 60 characters, consider this explanation about line length from Better Web Type.
There is 2023 now that generated by template string Codeblocks supports many languages and you can see the example below
example.sh
some code string;
And there is an example of jsx code with highlighting
Accordion.tsx
1import React from 'react';2import BaseHighlight, { Language, PrismTheme, defaultProps } from 'prism-react-renderer';3import { EDITOR_LIVE_STYLES } from '@/features/Mdx/constants';4import { calculateLinesToHighlight } from '@/features/Mdx/utils';56interface CodeStaticProps {7 code: string;8 language: Language;9 theme: PrismTheme;10 meta?: string;11 showLines?: boolean;12}1314const CodeStatic: React.FC<CodeStaticProps> = ({ code, language, meta, showLines, ...props }) => {15 const shouldHighlightLine = calculateLinesToHighlight(meta);1617 return (18 <BaseHighlight {...defaultProps} code={code} language={language} {...props}>19 {({ className, style, tokens, getLineProps, getTokenProps }): JSX.Element => (20 <div style={EDITOR_LIVE_STYLES} data-language={language}>21 <pre className={className} style={style}>22 {tokens.map((line, index) => {2324 const lineProps = getLineProps({ line, key: index });25 return (26 <div27 key={`line-${index.toString()}`}28 // px="5"29 // bg={shouldHighlightLine(i) ? 'whiteAlpha.200' : undefined}30 {...lineProps}31 >32 {showLines && (33 <span className={styles.line}>{index + 1}</span>34 )}35 {line.map((token, key) => (36 <span key={`key-${key.toString()}`} {...getTokenProps({ token, key })} />37 ))}38 </div>39 );40 })}41 </pre>42 </div>43 )}44 </BaseHighlight>45 );46};4748export default CodeStatic;
Also supports styles highlighting
example.scss
@import "helpers";// $code-background: #19243c;// $header-background: #0c162d;// $border-color: #31363C;$code-background: $dark-100;$header-background: $dark-200;$border-color: $dark-300;.container {display: flex;flex-direction: column;width: 100%;overflow: auto;border-radius: 12px;background: $code-background;border: 1px solid $border-color;margin: rem(16px) 0;}.header {position: relative;display: flex;height: rem(45px);padding: rem(8px);padding-bottom: 0;background: $header-background;color: $dark-700;border-bottom: 1px solid $border-color;}
Even bash
example.bash
npm install @chakra-ui/react
And plain jsx
example.jsx
<Accordion allowToggle><AccordionItem><h2><AccordionButton><Box flex='1' textAlign='left'>Section 1 title</Box><AccordionIcon /></AccordionButton></h2><AccordionPanel pb={4}>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmodtempor incididunt ut labore et dolore magna aliqua. Ut enim ad minimveniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex eacommodo consequat.</AccordionPanel></AccordionItem><AccordionItem><h2><AccordionButton><Box flex='1' textAlign='left'>Section 2 title</Box><AccordionIcon /></AccordionButton></h2><AccordionPanel pb={4}>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmodtempor incididunt ut labore et dolore magna aliqua. Ut enim ad minimveniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex eacommodo consequat.</AccordionPanel></AccordionItem></Accordion>
example.jsx
<div><h1>Title</h1><span style={{color:'red'}}>subtitle</span></div>
- to do
- done