
React
- 1.6k installs
- 81.3k repo stars
- Updated August 5, 2026
- lobehub/lobe-chat
This is a copy of react by lobehub - installs and ranking accrue to the original listing.
react is a frontend layout skill that teaches developers how to build consistent responsive React layouts using Flexbox and Center components from the @lobehub/ui package.
About
react is a Skillselion skill from lobehub/lobe-chat that documents @lobehub/ui layout primitives for React applications. The guide covers Flexbox, the most common layout component mirroring CSS display flex, plus Center for alignment tasks. Developers learn default vertical stacks, horizontal rows, and prop controls including horizontal, flex, gap, and align values such as center and flex-start. Reach for this skill when building Lobe Chat or other React apps that standardize on @lobehub/ui instead of hand-rolling flex CSS for every screen.
- Provides Flexbox and Center components for flexible layouts
- Supports horizontal and vertical direction with a single boolean prop
- Exposes 12+ common props including gap, align, justify, padding, flex, and dimensions
- Enables classic three-column and sidebar-main-footer layouts in under 15 lines
- Works seamlessly inside Cursor, Claude Code, and other React agent workflows
React by the numbers
- 1,610 all-time installs (skills.sh)
- +82 installs in the week ending Aug 5, 2026 (Skillselion tracking)
- Security screen: LOW risk (skills.sh audit)
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/lobehub/lobe-chat --skill reactAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 1.6k |
|---|---|
| repo stars | ★ 81.3k |
| Security audit | 3 / 3 scanners passed |
| Last updated | August 5, 2026 |
| Repository | lobehub/lobe-chat ↗ |
How do you lay out React UI with @lobehub/ui?
Quickly create consistent, responsive layouts with Flexbox and Center components from @lobehub/ui.
Who is it for?
React developers using @lobehub/ui who want standardized Flexbox and Center layout patterns instead of repeating raw CSS flex rules.
Skip if: Teams not using @lobehub/ui who need generic CSS Grid or Tailwind-only layout guidance.
When should I use this skill?
The user builds React UI with @lobehub/ui and needs Flexbox or Center layout patterns, spacing, or alignment help.
What you get
Flexbox and Center component layouts with consistent spacing, alignment, and responsive direction control.
- Flexbox layout components
- Centered UI sections
Files
React Component Writing Guide
Styling
| Scenario | Approach |
|---|---|
| Most cases | createStaticStyles + cssVar.* (zero-runtime, module-level) |
| Simple one-off | Inline style attribute |
Truly dynamic (JS color fns like readableColor/chroma) | createStyles + token — last resort |
Component Priority
1. `src/components` — project-specific reusable components 2. `@lobehub/ui/base-ui` — headless primitives. If the component lives here, use it. Do NOT import the same-named root export. 3. `@lobehub/ui` — higher-level / antd-wrapping components (only when no base-ui equivalent) 4. antd — only when neither base-ui nor @lobehub/ui root provides it 5. Custom implementation — true last resort
If unsure about available components, search existing code or check node_modules/@lobehub/ui/es/index.mjs and node_modules/@lobehub/ui/es/base-ui/.
@lobehub/ui/base-ui — always prefer for these
| Component | Import |
|---|---|
Select (+ SelectProps, SelectOption) | import { Select } from '@lobehub/ui/base-ui'; |
Modal (imperative API) | import { createModal, confirmModal, useModalContext, type ModalInstance } from '@lobehub/ui/base-ui'; |
DropdownMenu | import { DropdownMenu } from '@lobehub/ui/base-ui'; |
ContextMenu | import { ContextMenu } from '@lobehub/ui/base-ui'; |
Popover | import { Popover } from '@lobehub/ui/base-ui'; |
ScrollArea | import { ScrollArea } from '@lobehub/ui/base-ui'; |
Switch | import { Switch } from '@lobehub/ui/base-ui'; |
Toast | import { Toast } from '@lobehub/ui/base-ui'; |
FloatingSheet | import { FloatingSheet } from '@lobehub/ui/base-ui'; |
For Modal specifically, see the dedicated modal skill — use the imperative createModal({ content: … }) pattern over the legacy <Modal open … /> declarative pattern. base-ui has its own ModalHost already mounted in SPAGlobalProvider.
Common slip:import { Select } from '@lobehub/ui'looks fine but it's the antd-backed Select. Use base-ui Select. Same forModal,DropdownMenu, etc.
@lobehub/ui root — use when base-ui has no equivalent
| Category | Components |
|---|---|
| General | ActionIcon, ActionIconGroup, Block, Button, Icon |
| Data Display | Avatar, Collapse, Empty, Highlighter, Markdown, Tag, Tooltip |
| Data Entry | CodeEditor, CopyButton, EditableText, Form, Input, InputPassword, SearchBar, TextArea |
| Feedback | Alert, Drawer |
| Layout | Center, DraggablePanel, Flexbox, Grid, Header, MaskShadow |
| Navigation | Burger, Menu, SideNav, Tabs |
Loading indicators
Do NOT use antd `Spin` / `<Spin />`. Use a project loader (NeuralNetworkLoading, DotsLoading, …) — see the ux skill ("Loading visuals") for the component table and when to use each.
State
When a feature component manages more than 3 pieces of state (useState/useReducer/derived state), extract the logic into a custom hook (e.g. useXxx). Keep the component focused on rendering — the hook holds state and handlers, so logic can be unit-tested without rendering the component.
Layout
Use Flexbox and Center from @lobehub/ui. See references/layout-kit.md for full props and examples.
- Use
gapinstead ofmarginfor spacing between flex children - Use
flex={1}to fill available space - Nest Flexbox for complex layouts; set
overflow: 'auto'for scrollable regions
Navigation
For SPA pages, use `react-router-dom`, NOT `next/link`.
// ❌ Wrong
import Link from 'next/link';
// ✅ Correct
import { Link, useNavigate } from 'react-router-dom';Access navigate from stores: useGlobalStore.getState().navigate?.('/settings');
Desktop File Sync Rule
Files with a .desktop.ts(x) variant must be edited in sync. Drift causes blank pages in Electron.
| Base file (web) | Desktop file (Electron) |
|---|---|
desktopRouter.config.tsx | desktopRouter.config.desktop.tsx |
componentMap.ts | componentMap.desktop.ts |
After editing any `.ts`/`.tsx`: glob for <filename>.desktop.{ts,tsx} in the same directory. If found, apply the equivalent sync-import change.
Routing Architecture
| Route Type | Use Case | Implementation |
|---|---|---|
| Next.js App Router | Auth pages | src/app/[variants]/(auth)/ |
| React Router DOM | Main SPA | desktopRouter.config.tsx + .desktop.tsx (pair) |
Router utilities:
import { dynamicElement, redirectElement, ErrorBoundary } from '@/utils/router';
element: dynamicElement(() => import('./chat'), 'Desktop > Chat');
element: redirectElement('/settings/profile');
errorElement: <ErrorBoundary />;Common Mistakes
| Mistake | Fix |
|---|---|
Using next/link in SPA | Use react-router-dom Link |
| Using antd directly | Use @lobehub/ui/base-ui first, then @lobehub/ui |
antd Spin / <Spin /> for loading | Use NeuralNetworkLoading / project loaders (see the ux skill) |
import { Select } from '@lobehub/ui' | import { Select } from '@lobehub/ui/base-ui' |
import { Modal } from '@lobehub/ui' + <Modal open> declarative | createModal / confirmModal from @lobehub/ui/base-ui (see modal skill) |
import { DropdownMenu/Popover/Switch } from '@lobehub/ui' | Import same name from @lobehub/ui/base-ui instead |
createStyles for static styles | Use createStaticStyles + cssVar |
Editing only desktopRouter.config.tsx | Must edit both .tsx and .desktop.tsx |
Using margin for flex spacing | Use gap prop on Flexbox |
| Accessing zustand store without selector | Use selectors to access store data (see zustand skill) |
Text or icon-text actions built with Flexbox/Text + onClick | Use Button type={'text'} size={'small'} with icon when needed |
Flexbox Layout Components Guide
@lobehub/ui provides Flexbox and Center components for creating flexible layouts.
Flexbox Component
Flexbox is the most commonly used layout component, similar to CSS display: flex.
Basic Usage
import { Flexbox } from '@lobehub/ui';
// Default vertical layout
<Flexbox>
<div>Child 1</div>
<div>Child 2</div>
</Flexbox>
// Horizontal layout
<Flexbox horizontal>
<div>Left</div>
<div>Right</div>
</Flexbox>Common Props
horizontal: Boolean, set horizontal direction layoutflex: Number or string, controls flex propertygap: Number, spacing between childrenalign: Alignment like 'center', 'flex-start', etc.justify: Main axis alignment like 'space-between', 'center', etc.padding: Padding valuepaddingInline: Horizontal paddingpaddingBlock: Vertical paddingwidth/height: Set dimensions, typically '100%' or specific pixelsstyle: Custom style object
Layout Example
// Classic three-column layout
<Flexbox horizontal height={'100%'} width={'100%'}>
{/* Left sidebar */}
<Flexbox
width={260}
style={{
borderRight: `1px solid ${theme.colorBorderSecondary}`,
height: '100%',
overflowY: 'auto',
}}
>
<SidebarContent />
</Flexbox>
{/* Center content */}
<Flexbox flex={1} style={{ height: '100%' }}>
<Flexbox flex={1} padding={24} style={{ overflowY: 'auto' }}>
<MainContent />
</Flexbox>
{/* Footer */}
<Flexbox
style={{
borderTop: `1px solid ${theme.colorBorderSecondary}`,
padding: '16px 24px',
}}
>
<Footer />
</Flexbox>
</Flexbox>
</Flexbox>Center Component
Center wraps Flexbox with horizontal and vertical centering.
import { Center } from '@lobehub/ui';
<Center width={'100%'} height={'100%'}>
<Content />
</Center>
// Icon centered
<Center className={styles.icon} flex={'none'} height={40} width={40}>
<Icon icon={icon} size={24} />
</Center>Best Practices
- Use
flex={1}to fill available space - Use
gapinstead of margin for spacing - Nest Flexbox for complex layouts
- Set
overflow: 'auto'for scrollable content - Use
horizontalfor horizontal layout (default is vertical) - Combine with
useThemehook for theme-responsive layouts
Related skills
FAQ
What components does the react skill cover?
The react skill documents @lobehub/ui Flexbox and Center components, including horizontal direction, gap spacing, flex sizing, and alignment props for responsive React layouts.
When should I use the react skill?
Use the react skill when building React interfaces with @lobehub/ui and you need consistent Flexbox or Center layout patterns instead of writing custom CSS flex rules for each screen.
Is React safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.