Skip to content
DocsComponentsTemplatesThemesPlayground
Search
Switch to dark mode
Community
GitHub
Get started
Type to search
↑↓Navigate↵SelectEscClose
Components
Overview
App Shell
App Shell
useAppShellMobile
Aspect Ratio
Avatar
Avatar
Avatar Group
Avatar Group Overflow
Avatar Status Dot
Badge
Banner
Blockquote
Breadcrumbs
Breadcrumb Item
Breadcrumbs
Button
Button
Button Group
Icon Button
Toggle Button
Toggle Button Group
Calendar
Card
Card
Clickable Card
Selectable Card
Carousel
Chat
Chat Composer
Chat Composer Drawer
Chat Composer Input
Chat Composer Token Element
Chat Dictation Button
Chat Layout
Chat Layout Scroll Button
Chat Message
Chat Message Bubble
Chat Message List
Chat Message Metadata
Chat Send Button
Chat System Message
Chat Tokenized Text
Chat Tool Calls
Checkbox
Checkbox Input
Checkbox List
Checkbox List Item
Citation
Code
Code Block
Collapsible
Collapsible
Collapsible Group
useCollapsible
Command Palette
Command Palette
Command Palette Empty
Command Palette Footer
Command Palette Group
Command Palette Input
Command Palette Item
Command Palette List
Context Menu
Context Menu
Context Menu Item
Date Input
Date Input
Date Range Input
Date Time Input
Dialog
Alert Dialog
Dialog
Dialog Header
useImperativeAlertDialog
useImperativeDialog
Divider
Dropdown Menu
Dropdown Menu
Dropdown Menu Item
Empty State
Field
Field
Field Label
Field Status
Input Group
Input Group Text
File Input
Heading
Hover Card
Hover Card
useHoverCard
Icon
Item
Kbd
Layout
Center
Form Layout
Grid
Grid Span
H Stack
Layout
Layout Content
Layout Footer
Layout Header
Layout Panel
Section
Stack Item
V Stack
Lightbox
Link
List
List
List Item
Markdown
Metadata List
Metadata List
Metadata List Item
More Menu
Navigation
Mobile Nav
Mobile Nav Toggle
Nav Heading Menu
Nav Icon
Side Nav
Side Nav Collapse Button
Side Nav Heading
Side Nav Item
Side Nav Section
Top Nav
Top Nav Heading
Top Nav Item
Top Nav Mega Menu
Top Nav Mega Menu Featured Card
Top Nav Mega Menu Item
Top Nav Menu
Number Input
Outline
Overflow List
Overlay
Pagination
Popover
Popover
usePopover
Power Search
Progress Bar
Radio
Radio List
Radio List Item
Resizable
Resize Handle
useResizable
Segmented Control
Segmented Control
Segmented Control Item
Selector
Multi Selector
Selector
Selector Option
Skeleton
Slider
Spinner
Status Dot
Switch
Table
Table
Table Cell
Table Header Cell
Table Row
useTableColumnSettings
useTableFiltering
useTableFilterState
useTablePagination
useTableSelection
useTableSelectionState
useTableSortable
Tabs
Tab
Tab List
Tab Menu
Text
Text Area
Text Input
Thumbnail
Time Input
Timestamp
Toast
Toast
useToast
Token
Tokenizer
Toolbar
Tooltip
Tooltip
useTooltip
Tree List
Typeahead
Base Typeahead
Typeahead
Typeahead Item
Utilities
Layer Provider
Link Provider
Media Theme
Syntax Theme
Theme
useClickableContainer
useEntryAnimation
useFocusTrap
useGridFocus
useImageMode
useInputContainer
useLayer
useListFocus
useMediaQuery
useOverflow
useScrollLock
useScrollOverflow
useStreamingText
useTheme
DocsChangelogCommunityBlogComponentsTemplatesThemesPlayground
GitHub
Facebook
Instagram
Threads
X
Terms of usePrivacy policy
©2026 Meta Platforms, Inc.
Code Block@astryxdesign/core v0.0.15 · CodeBlock

Usage

CodeBlock renders syntax-highlighted code with line numbers, a copy button, and optional collapsible sections. Use CodeBlock for multi-line snippets like source files, terminal commands, and configuration examples. Use Code for inline references to function names, variables, or CLI flags within body text.
ts
import {CodeBlock} from '@astryxdesign/core/CodeBlock'

Best practices

GuidancePractices
DoSet the language prop to match the code content so syntax highlighting is accurate. Use "plaintext" when the language is unknown.
DoAdd a title when the code represents a file. It gives readers context and appears in the header bar alongside the copy button.
DoUse Code for short inline references like function names or CLI flags, and CodeBlock for standalone multi-line snippets.
Don'tEnable line numbers on short snippets (under 5 lines) where they add clutter without helping navigation.
Don'tNest a code block inside a scrollable container. Use the maxHeight prop instead, which handles overflow natively.

Examples

Common configurations, variations, and states.
Code — Snippet
Short terminal commands with a copy button and no line numbers. Use for install instructions or one-liner commands that readers will paste directly.
Code — Highlighted
TypeScript code with specific lines highlighted to draw attention to a key section. Use highlightLines to call out new or important code in tutorials and changelogs.
Code — Config
A JSON configuration file with a title bar and line numbers. The title prop adds a filename label in the header so readers know which file the code belongs to.
Code — Scrollable
A long code block with a max height that enables vertical scrolling. Use maxHeight to keep the block from dominating the page when displaying large files.