A typography primitiving for displaying inline code snippets with a monospace
font. This component provides all relevant typographic styles such as
font-family, line-height and font-size.
Code
React
Code composes Box so you can use all the style props and add responsive
styles as well.
import { Code } from '@hoverinc/design-system-react-web';
live
<Code>{'const code = () => {}'}</Code>
Size
Code defaults to size 500, pass the size prop to set a custom a size.
Correct Sizing
The size of Code should always be controlled via the size
prop, not by setting fontSize or lineHeight
live
<Stack alignItems="start" spacing="400">
<Code size={600}>Code 600</Code>
<Code size={500}>Code 500</Code>
<Code size={400}>Code 400</Code>
<Code size={300}>Code 300</Code>
<Code size={200}>Code 200</Code>
</Stack>
Text Styles
Body typographic styles can also be applied via textStyles to other elements and in component theming.
If you'd like to truncate the text after a specific number of lines, pass the
noOfLines prop. This will render an ellipsis when the text exceeds the width
of the viewport or maxWidth prop.