In order to make it easier for you to use these components, the rspress/theme package has been aliased inside Rspress, so you can directly use @theme to import these components.
interface BadgeProps { /** * The content to display inside the badge. Can be a string or React nodes. */ children?: React.ReactNode; /** * The type of badge, which determines its color and style. * @default 'tip' */ type?: 'tip' | 'info' | 'warning' | 'danger'; /** * The text content to display inside the badge (for backwards compatibility). */ text?: string; /** * Whether to display the badge with an outline style. * @default false */ outline?: boolean;}
It is generally used to set custom head content in documents (based on unhead). The usage is as follows:
index.tsx
// Below is a custom component, you can import it into your documentimport { Head } from '@rspress/core/runtime';function App() { return ( <Head> <meta property="og:description" content="Out-of-box Rspack build tools" /> </Head> );}
Used to skip the ssr for some components. For example:
import { NoSSR } from '@rspress/core/runtime';const Component = () => { return ( <NoSSR> <div>The content here will only be rendered on the client side</div> </NoSSR> );};
import { Overview } from '@rspress/core/theme';interface GroupItem { text?: string; link?: string; headers?: Header[];}interface Group { name: string; items: GroupItem[];}interface OverviewProps { // content before data rendering content?: React.ReactNode; // data groups?: Group[]; // default title defaultGroupTitle?: string; // headers displayed in the overview page of the file overviewHeaders?: number[];}
type PackageManagerTabProps = ( | { command: string; /** * If true, uses local package execution (npx, yarn, pnpm, bun, deno run). * For locally installed packages in node_modules. */ exec?: boolean; /** * If true, uses remote package execution (npx, yarn dlx, pnpm dlx, bunx, deno run). * For executing packages directly from registry without installing locally. * Takes precedence over exec prop. */ dlx?: boolean; } | { command: { // Used to set commands for different package managers npm?: string; yarn?: string; pnpm?: string; bun?: string; deno?: string; }; exec?: never; dlx?: never; }) & // Used to set additional tabs { additionalTabs?: { // Used to set additional package managers tool: string; // Used to set the icon of the additional package manager icon?: ReactNode; }[]; };
When command is set to a string, it will default to displaying five tabs: npm, yarn, pnpm, bun and deno, and the component will automatically add the corresponding package manager command before the command. If you need to display additional tabs, you can achieve this through additionalTabs.
For the string variant of the command prop, an optional exec prop can be used for presenting binary execution usage (by changing the NPM tab's command prefix to npx).
You can also set different commands for each package manager by using the object form:
In the install command, special processing has been done for yarn, pnpm, bun and deno. If your command is install some-packages, the install will be automatically replaced with add in the yarn/pnpm/bun/deno tab.
In the deno tab, the npm: prefix will be added to the package by default if no source is specified.
interface PrevNextPageProps { // Set the link to the previous page or the next page through type type: 'prev' | 'next'; // Used to set the text of the previous page or the next page text: string; // Used to set the link to the previous page or the next page href: string;}
defaultValue is used to set the tab item selected by default. This value will be compared with the value field of the Tab component props, and if they are equal, the tab will be selected.
groupId is used to sync the selected tab item between multiple Tabs components.The groups with the same groupId will be synchronized.
tabPosition is used to set the position of the tab list, it has two values: left and center, the default is left.
The props types of the Tab component are as follows:
interface TabProps { label: string; // Used to identify the current tab, if not passed, the default label will be used value?: string; children: React.ReactNode;}
The value field is used to identify the current tab, if not passed, the default label will be used.