### Start Development Server Command
Source: https://ui.lobehub.com/~demos/src-markdown-demo-codeblocks
Use this command to start the development server.
```bash
npm run dev
```
--------------------------------
### Bash Command Example
Source: https://ui.lobehub.com/components/code-editor
A common bash command for installing dependencies using pnpm. This is useful for setting up projects or managing packages.
```bash
$ pnpm install
```
--------------------------------
### Install Dependencies Command
Source: https://ui.lobehub.com/~demos/src-markdown-demo-codeblocks
Use this command to install project dependencies.
```bash
npm install
```
--------------------------------
### Hotkey Support Example
Source: https://ui.lobehub.com/components/tooltip
Example demonstrating how to use the `hotkey` prop to display keyboard shortcuts within a tooltip.
```APIDOC
## Hotkey Support
The Tooltip component includes special integration with the Hotkey component. When you provide a `hotkey` prop, the tooltip will display the specified keyboard shortcut alongside the tooltip text. This is useful for displaying shortcuts for actions.
### Example
```jsx
import { Tooltip, Hotkey } from '@lobehub/ui';
```
This will display "Search" along with the keyboard shortcut in the tooltip.
```
--------------------------------
### Default Drawer Example
Source: https://ui.lobehub.com/components/drawer
A basic example of the Drawer component with content. This demonstrates the default appearance and behavior.
```javascript
import { Drawer } from '@lobehub/ui';
// Example Usage:
content
content
content
content
content
content
content
content
content
content
content
content
content
content
content
content
content
content
content
content
content
content
content
content
content
content
content
content
content
content
content
content
content
content
content
content
content
content
content
content
content
content
content
content
content
content
content
content
```
--------------------------------
### Default Tabs Example
Source: https://ui.lobehub.com/components/tabs
A basic example demonstrating the default appearance and functionality of the Tabs component.
```javascript
import { Tabs } from '@lobehub/ui';
const App = () => {
const items = [
{
key: '1',
label: 'Home',
children: 'Content of Tab Pane 1',
},
{
key: '2',
label: 'Components',
children: 'Content of Tab Pane 2',
},
{
key: '3',
label: 'Color',
children: 'Content of Tab Pane 3',
},
{
key: '4',
label: 'Changelog',
children: 'Content of Tab Pane 4',
},
];
return ;
};
```
--------------------------------
### Default Collapse Example
Source: https://ui.lobehub.com/components/collapse
A basic example of the Collapse component with default panel headers and content.
```javascript
const App = () => (
This is a description
This is panel header 2
This is panel header 3
);
```
--------------------------------
### Default Select Example
Source: https://ui.lobehub.com/components/base-ui/select
A basic example of the Select component with predefined options. This demonstrates the default appearance and functionality.
```javascript
```
--------------------------------
### Install Lobe UI Kit
Source: https://ui.lobehub.com/
Install the Lobe UI Kit using bun. This command adds the necessary package to your project.
```bash
$ bun add @lobehub/ui
```
--------------------------------
### LaTeX Math with Quaternions Example
Source: https://ui.lobehub.com/components/code-editor
An example of using LaTeX to represent quaternion multiplication.
```latex
$$ q_1 q_2 = (w_1 w_2 - \vec{v}_1^T \vec{v}_2, \, w_1 \vec{v}_2 + w_2 \vec{v}_1 + \vec{v}_1 \times \vec{v}_2) $$
```
--------------------------------
### Display LaTeX Math Example
Source: https://ui.lobehub.com/components/code-editor
Shows how to render standalone LaTeX mathematical formulas using Markdown.
```latex
$$ f(x) = a_0 + \sum_{n=1}^{\infty} \left( a_n \cos(nx) + b_n \sin(nx) \right) $$
```
--------------------------------
### Install @lobehub/ui Snippet
Source: https://ui.lobehub.com/components/snippet
Install the @lobehub/ui package to use the Snippet component. This command is for pnpm users.
```bash
$ pnpm install @lobehub/ui
```
--------------------------------
### LaTeX Taylor Series Example
Source: https://ui.lobehub.com/components/code-editor
A comprehensive example of a Taylor series expansion using LaTeX, including equation numbering.
```latex
$$ \begin{equation} f(x) = f(a) + f'(a)(x - a) + \frac{f''(a)}{2!}(x - a)^2 + \frac{f'''(a)}{3!}(x - a)^3 + \cdots + \frac{f^{(n)}(a)}{n!}(x - a)^n + R_n(x) \end{equation} $$
```
--------------------------------
### Install Dependencies with pnpm
Source: https://ui.lobehub.com/components/code-editor
Use this command to install project dependencies using the pnpm package manager.
```bash
$ pnpm install
```
--------------------------------
### Default GuideCard Example
Source: https://ui.lobehub.com/components/guide-card
A basic GuideCard with a title and description. This is useful for displaying simple informational content.
```javascript
```
--------------------------------
### LaTeX Math with Integral Example
Source: https://ui.lobehub.com/components/code-editor
Illustrates the use of LaTeX for mathematical formulas involving integrals.
```latex
$$ a_0 = \frac{1}{2\pi} \int_{-\pi}^{\pi} f(x) \, dx $$
```
```latex
$$ a_n = \frac{1}{\pi} \int_{-\pi}^{\pi} f(x) \cos(nx) \, dx \quad \text{for} \quad n \geq 1 $$
```
```latex
$$ b_n = \frac{1}{\pi} \int_{-\pi}^{\pi} f(x) \sin(nx) \, dx \quad \text{for} \quad n \geq 1 $$
```
--------------------------------
### Inline LaTeX Taylor Series Example
Source: https://ui.lobehub.com/components/code-editor
Demonstrates rendering a Taylor series formula inline using LaTeX.
```latex
$ f(x) = f(a) + f'(a)(x - a) + \frac{f''(a)}{2!}(x - a)^2 + \frac{f'''(a)}{3!}(x - a)^3 + \cdots + \frac{f^{(n)}(a)}{n!}(x - a)^n + R_n(x) $
```
--------------------------------
### Collapse with Icons and Descriptions
Source: https://ui.lobehub.com/components/collapse
Example showcasing collapse panels with custom icons and descriptions in their headers.
```javascript
import { Icon } from '@lobehub/ui';
const App = () => (
,
children:
,
},
]}
/>
);
```
--------------------------------
### Using dayjs fromNow
Source: https://ui.lobehub.com/components/chat/chat-list
Demonstrates how to use the `fromNow` function from the dayjs library to display relative time. Ensure dayjs is installed and imported.
```javascript
dayjs().fromNow(); // 获取当前时间的相对时间
dayjs('2021-05-01').fromNow(); // 获取给定时间的相对时间
```
--------------------------------
### Code Editor Configuration Example
Source: https://ui.lobehub.com/components/code-editor
Illustrates the basic properties for configuring the Code Editor component, such as language, value, and placeholder.
```javascript
language: 'markdown',
value: 'Current value of the editor',
defaultValue: '',
onValueChange: '(value: string) => void',
placeholder: 'Placeholder text when no value is provided',
```
--------------------------------
### Basic Lobe UI Kit Setup
Source: https://ui.lobehub.com/
Set up the basic Lobe UI components with ThemeProvider and I18nProvider. Ensure you import necessary components and resources.
```tsx
import { ThemeProvider, Button, I18nProvider } from '@lobehub/ui'
import allResources from '@lobehub/ui/i18n/resources/all'
export default () => (
)
```
--------------------------------
### LaTeX Math with Tag Example
Source: https://ui.lobehub.com/components/code-editor
Shows how to add a tag or number to a LaTeX mathematical equation.
```latex
$$ q = a + bi + cj + dk \tag{1} $$
```
--------------------------------
### Inline LaTeX Math Example
Source: https://ui.lobehub.com/components/code-editor
Demonstrates how to embed inline LaTeX mathematical expressions within Markdown text.
```latex
$E=mc^2$
```
--------------------------------
### Simple Accordion Example
Source: https://ui.lobehub.com/components/accordion
A simplified Accordion with two panels.
```javascript
import { Accordion } from '@lobehub/ui';
const App = () => (
This is the content of panel 1.
You can put any React component here.
This is the content of panel 2.
);
```
--------------------------------
### Nested Modals Example
Source: https://ui.lobehub.com/components/base-ui/modal
Illustrates how to stack modals, ensuring correct overlay order. This is useful for multi-step processes or complex workflows.
```typescript
import { Modal, createModal } from '@lobehub/ui/base-ui';
const confirmModal = createModal(Modal, {
title: 'Confirm Action',
content: 'Are you sure you want to proceed?',
});
const verifyModal = createModal(Modal, {
title: 'Verify Action',
content: 'Please verify the details.',
});
// To trigger nested modals:
// createModal(Modal, {
// title: 'Outer Modal',
// content: (
//
//
//
//
// )
// });
```
--------------------------------
### Code Editor Styling and Variants Example
Source: https://ui.lobehub.com/components/code-editor
Demonstrates how to customize the appearance of the Code Editor using variant styles and size properties.
```javascript
variant: "filled" | "outlined" | "borderless",
width: 'string | number',
height: 'string | number',
classNames: { highlight?: string; textarea?: string },
styles: { highlight?: CSSProperties; textarea?: CSSProperties }
```
--------------------------------
### LaTeX Math Examples
Source: https://ui.lobehub.com/components/code-editor
Demonstrates inline and display modes for LaTeX math equations, including basic formulas, integrals, fractions, superscripts, subscripts, and tagged equations. This is useful for rendering mathematical content.
```latex
我是一个行内公式:$E=mc^2$
我是一个独立的傅里叶公式:
$$
f(x) = a_0 + \sum_{n=1}^{\infty} \left( a_n \cos(nx) + b_n \sin(nx) \right)
$$
其中,带有积分符号的项:
$$
a_0 = \frac{1}{2\pi} \int_{-\pi}^{\pi} f(x) \, dx
$$
$$ a_n = \frac{1}{\pi} \int_{-\pi}^{\pi} f(x) \cos(nx) \, dx \quad \text{for} \quad n \geq 1
$$
$$ b_n = \frac{1}{\pi} \int_{-\pi}^{\pi} f(x) \sin(nx) \, dx \quad \text{for} \quad n \geq 1
$$
我是一个带有分式、测试长度超长的泰勒公式:
$$
\begin{equation}
f(x) = f(a) + f'(a)(x - a) + \frac{f''(a)}{2!}(x - a)^2 + \frac{f'''(a)}{3!}(x - a)^3 + \cdots + \frac{f^{(n)}(a)}{n!}(x - a)^n + R_n(x)
\end{equation}
$$
我是上面公式的行内版本,看看我会不会折行:$ f(x) = f(a) + f'(a)(x - a) + \frac{f''(a)}{2!}(x - a)^2 + \frac{f'''(a)}{3!}(x - a)^3 + \cdots + \frac{f^{(n)}(a)}{n!}(x - a)^n + R_n(x) $
我是一个带有上下标的公式:
$$
q_1 q_2 = (w_1 w_2 - \vec{v}_1^T \vec{v}_2, \, w_1 \vec{v}_2 + w_2 \vec{v}_1 + \vec{v}_1 \times \vec{v}_2)
$$
我是一个带有 tag 的公式:
$$
q = a + bi + cj + dk \tag{1}
$$
```
--------------------------------
### JavaScript Code Block Example
Source: https://ui.lobehub.com/components/chat/editable-message
This snippet demonstrates a simple JavaScript function for greeting a user, including console logging.
```javascript
function greet(name) {
console.log(`Hello, ${name}!`);
}
```
--------------------------------
### Inline Code Example
Source: https://ui.lobehub.com/~demos/src-markdown-demo-code
Use backticks to format text as inline code.
```markdown
`backticks`
```
--------------------------------
### Default Modal Usage
Source: https://ui.lobehub.com/components/base-ui/modal
A basic example of how to render a modal with default settings. This is useful for simple confirmations or information display.
```typescript
import { Modal } from '@lobehub/ui/base-ui';
{}} onOk={() => {}}>
This is the content of the modal.
```
--------------------------------
### Streaming Mode: Defer
Source: https://ui.lobehub.com/components/html-preview
The 'defer' streaming mode always waits for the closing `