Code
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
.
React
Code composes Box
so you can use all the style props and add responsive
styles as well.
import { Code } from '@hover/blueprint';
Size
Code defaults to size 500, pass the size
prop to set a custom a size.
Text Styles
Body typographic styles can also be applied via textStyles
to other elements and in component theming.
Color Schemes
Code is available in all system color schemes.
Color Inheritance
When used within components like Alert and
Blockquote, Code will inherit its colorScheme
.
Alert
Blockquote
Truncation
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.
Semantic Element
The Code component renders a code
tag by default. To override the element
that gets rendered, pass the as
prop.