console.log()
<.code>console.log()</.code>
API Reference
This component is based on the code element.
| Prop | Type | Default | Description |
|---|---|---|---|
as_child
|
boolean
|
false
|
Composes the component into its immediate child instead of rendering its own HTML element. |
class
|
string
|
nil
|
|
color
|
string
|
—
|
Color utility class string. One of: gray, gold, bronze, brown, yellow, amber, orange, tomato, red, ruby, crimson, pink, plum, purple, violet, iris, indigo, blue, cyan, teal, jade, green, grass, lime, mint, sky. |
high_contrast
|
boolean
|
—
|
Whether to increase color contrast with the background. |
size
|
any
|
—
|
Code size from 1 to 9. Controls font size, line height, and letter spacing. Can be "1" or %{xs: "1", sm: "2", md: "3", lg: "4", xl: "5"}. |
style
|
string
|
""
|
|
truncate
|
boolean
|
—
|
Whether to truncate text with ellipsis when it overflows. |
variant
|
string
|
"soft"
|
Visual style variant. One of 'solid', 'soft', 'outline', or 'ghost'. Defaults to 'soft'. |
weight
|
string
|
—
|
Font weight: one of light, regular, medium, bold. |
wrap
|
string
|
—
|
Text wrapping: one of wrap, nowrap, pretty, balance. |
as_child
Composes the component into its immediate child instead of rendering its own HTML element.
Type
boolean
Default
false
class
Type
string
Default
nil
color
Color utility class string. One of: gray, gold, bronze, brown, yellow, amber, orange, tomato, red, ruby, crimson, pink, plum, purple, violet, iris, indigo, blue, cyan, teal, jade, green, grass, lime, mint, sky.
Type
string
Default
—
high_contrast
Whether to increase color contrast with the background.
Type
boolean
Default
—
size
Code size from 1 to 9. Controls font size, line height, and letter spacing. Can be "1" or %{xs: "1", sm: "2", md: "3", lg: "4", xl: "5"}.
Type
any
Default
—
style
Type
string
Default
""
truncate
Whether to truncate text with ellipsis when it overflows.
Type
boolean
Default
—
variant
Visual style variant. One of 'solid', 'soft', 'outline', or 'ghost'. Defaults to 'soft'.
Type
string
Default
"soft"
weight
Font weight: one of light, regular, medium, bold.
Type
string
Default
—
wrap
Text wrapping: one of wrap, nowrap, pretty, balance.
Type
string
Default
—
Examples
Size
Use the size prop to control text size. This prop also provides correct line height and corrective letter spacing—as text size increases, the relative line height and letter spacing decrease.
console.log()
console.log()
console.log()
console.log()
console.log()
console.log()
console.log()
console.log()
console.log()
<.flex direction="column" gap="3" align="start">
<.code size="1">console.log()</.code>
<.code size="2">console.log()</.code>
<.code size="3">console.log()</.code>
<.code size="4">console.log()</.code>
<.code size="5">console.log()</.code>
<.code size="6">console.log()</.code>
<.code size="7">console.log()</.code>
<.code size="8">console.log()</.code>
<.code size="9">console.log()</.code>
</.flex>
Variant
Use the variant prop to control the visual style.
console.log()
console.log()
console.log()
console.log()
<.flex direction="column" align="start" gap="2">
<.code variant="solid">console.log()</.code>
<.code variant="soft">console.log()</.code>
<.code variant="outline">console.log()</.code>
<.code variant="ghost">console.log()</.code>
</.flex>
Color
Use the color prop to assign a specific color.
console.log()
console.log()
console.log()
console.log()
<.flex direction="column" align="start" gap="2">
<.code color="indigo">console.log()</.code>
<.code color="crimson">console.log()</.code>
<.code color="cyan">console.log()</.code>
<.code color="orange">console.log()</.code>
</.flex>
High-contrast
Use the high_contrast prop to increase color contrast with the background.
console.log()
console.log()
console.log()
console.log()
console.log()
console.log()
console.log()
console.log()
<.flex gap="3">
<.flex direction="column" align="start" gap="2">
<.code color="gray" variant="solid">console.log()</.code>
<.code color="gray" variant="soft">console.log()</.code>
<.code color="gray" variant="outline">console.log()</.code>
<.code color="gray" variant="ghost">console.log()</.code>
</.flex>
<.flex direction="column" align="start" gap="2">
<.code color="gray" variant="solid" high_contrast>console.log()</.code>
<.code color="gray" variant="soft" high_contrast>console.log()</.code>
<.code color="gray" variant="outline" high_contrast>console.log()</.code>
<.code color="gray" variant="ghost" high_contrast>console.log()</.code>
</.flex>
</.flex>
Weight
Use the weight prop to set the text weight.
console.log()
console.log()
<.flex direction="column" gap="2" align="start">
<.code weight="regular">console.log()</.code>
<.code weight="bold">console.log()</.code>
</.flex>
Truncate
Use the truncate prop to truncate text with an ellipsis when it overflows its container.
linear-gradient(red, orange, yellow, green, blue);
<.flex max_width="200px">
<.code truncate>linear-gradient(red, orange, yellow, green, blue);</.code>
</.flex>