CollectUICollectUI

Using Subpath Imports

When importing components from @heroui-pro/react, use subpath imports to avoid dependency resolution errors.

Problem

When importing components from the main entry point:

import { AreaChart, ChartTooltip } from "@heroui-pro/react";

Vite throws an error, saying it cannot find dependencies like shiki, marked, and react-markdown:

Failed to resolve import "shiki" from "node_modules/.vite/deps/@heroui-pro_react.js"

Cause

The main entry point of @heroui-pro/react (dist/index.js) re-exports all components into a single file. When you import from the main entry point, Vite has to resolve the entire bundle, including dependencies of components you never use (shiki belongs to code-block, marked belongs to markdown, and so on).

Solution

Use subpath imports to only bring in the components you need:

// ✅ Correct — subpath import
import { AreaChart } from "@heroui-pro/react/area-chart";
import { ChartTooltip } from "@heroui-pro/react/chart-tooltip";

All available subpaths are defined in the package's exports field, in the format @heroui-pro/react/<component-name>, for example:

  • @heroui-pro/react/area-chart
  • @heroui-pro/react/bar-chart
  • @heroui-pro/react/chart-tooltip
  • @heroui-pro/react/code-block
  • @heroui-pro/react/markdown
  • @heroui-pro/react/sidebar
  • ……

Subpath List

Below are all currently available subpath imports:

SubpathComponent
action-barActionBar
agendaAgenda
app-layoutAppLayout
area-chartAreaChart
bar-chartBarChart
carouselCarousel
cell-color-pickerCellColorPicker
cell-selectCellSelect
cell-sliderCellSlider
cell-switchCellSwitch
chain-of-thoughtChainOfThought
chart-tooltipChartTooltip
chat-attachmentChatAttachment
chat-conversationChatConversation
chat-list-viewChatListView
chat-loaderChatLoader
chat-messageChatMessage
chat-message-actionsChatMessageActions
chat-sourceChatSource
chat-toolChatTool
checkbox-button-groupCheckboxButtonGroup
code-blockCodeBlock
commandCommand
composed-chartComposedChart
context-menuContextMenu
data-gridDataGrid
drop-zoneDropZone
emoji-pickerEmojiPicker
emoji-reaction-buttonEmojiReactionButton
empty-stateEmptyState
file-treeFileTree
floating-tocFloatingToc
hover-cardHoverCard
inline-selectInlineSelect
item-cardItemCard
item-card-groupItemCardGroup
kanbanKanban
kpiKPI
kpi-groupKPIGroup
line-chartLineChart
list-viewListView
markdownMarkdown
native-selectNativeSelect
navbarNavbar
number-stepperNumberStepper
number-valueNumberValue
pie-chartPieChart
pressable-feedbackPressableFeedback
prompt-inputPromptInput
prompt-suggestionPromptSuggestion
radar-chartRadarChart
radial-chartRadialChart
radio-button-groupRadioButtonGroup
ratingRating
resizableResizable
segmentSegment
sheetSheet
sidebarSidebar
stepperStepper
text-shimmerTextShimmer
trend-chipTrendChip
widgetWidget

How is this guide?

Last updated on

On this page