New to Claude Skills? Learn how to install them →

lobehub on GitHub

LobeHub React

Free

Guidelines for writing React components with LobeHub.

by lobehub81.5k stars on lobehub/lobehub
2 views
Updated Aug 1, 2026
Get this skill

Free · Opens the source repo

What LobeHub React does

The LobeHub React skill provides a comprehensive guide for developers working with React components in TypeScript (TSX). It outlines best practices for styling, component selection, and state management, ensuring that developers adhere to the conventions set by LobeHub. The skill emphasizes the use of specific component libraries such as @lobehub/ui/base-ui, which should be prioritized over others for consistency and maintainability in projects.

When styling components, the skill recommends using createStaticStyles for most cases, while suggesting inline styles for simple, one-off scenarios. For dynamic styles, it advises using createStyles as a last resort. The component priority list helps developers choose the right component for their needs, starting with project-specific components and moving down to custom implementations only when necessary. This structured approach minimizes redundancy and promotes the reuse of well-defined components.

Additionally, the skill emphasizes the importance of managing component state effectively. It suggests extracting complex state logic into custom hooks to keep components focused on rendering. This practice not only enhances code readability but also facilitates unit testing. For layout design, developers are encouraged to utilize Flexbox and the Center component from @lobehub/ui, ensuring responsive and organized layouts.

Overall, this skill is ideal for developers looking to streamline their React component development process within the LobeHub ecosystem. By following these guidelines, they can create maintainable, efficient, and visually consistent user interfaces.

When to use it

Use this skill when developing or editing React components in a TypeScript environment, particularly within the LobeHub framework.

When not to use it

This skill may not be suitable for projects that do not utilize LobeHub or for developers unfamiliar with React and TypeScript.

What you can build with it

Creating a New Component

When starting a new component, refer to the component priority list to ensure you are using the most appropriate base component from LobeHub.

Styling an Existing Component

For styling, follow the recommended approaches in the skill to maintain consistency and avoid runtime overhead.

Managing Complex State Logic

If your component has complex state management, extract the logic into a custom hook to keep your component clean and focused on rendering.

How to install LobeHub React

View source

1. Install with the skills CLI

npx skills add lobehub/lobehub/react --agent claude-code

2. Or install it manually

Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.

Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs

Inside SKILL.md

Written by lobehub

React Component Writing Guide

Styling

ScenarioApproach
Most casescreateStaticStyles + cssVar.* (zero-runtime, module-level)
Simple one-offInline style attribute
Truly dynamic (JS color fns like readableColor/chroma)createStyles + tokenlast 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

ComponentImport
Select (+ SelectProps, SelectOption)import { Select } from '@lobehub/ui/base-ui';
Modal (imperative API)import { createModal, confirmModal, useModalContext, type ModalInstance } from '@lobehub/ui/base-ui';
DropdownMenuimport { DropdownMenu } from '@lobehub/ui/base-ui';
ContextMenuimport { ContextMenu } from '@lobehub/ui/base-ui';
Popoverimport { Popover } from '@lobehub/ui/base-ui';
ScrollAreaimport { ScrollArea } from '@lobehub/ui/base-ui';
Switchimport { Switch } from '@lobehub/ui/base-ui';
Toastimport { Toast } from '@lobehub/ui/base-ui';
FloatingSheetimport { 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 for Modal, DropdownMenu, etc.

@lobehub/ui root — use when base-ui has no equivalent

CategoryComponents
GeneralActionIcon, ActionIconGroup, Block, Button, Icon
Data DisplayAvatar, Collapse, Empty, Highlighter, Markdown, Tag, Tooltip
Data EntryCodeEditor, CopyButton, EditableText, Form, Input, InputPassword, SearchBar, TextArea
FeedbackAlert, Drawer
LayoutCenter, DraggablePanel, Flexbox, Grid, Header, MaskShadow
NavigationBurger, 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 gap instead of margin for 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.tsxdesktopRouter.config.desktop.tsx
componentMap.tscomponentMap.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 TypeUse CaseImplementation
Next.js App RouterAuth shellsrc/app/spa-auth/ (HTML shell; see spa-routes)
React Router DOMAuth pagessrc/routes/auth/ (signin, signup, oauth, …)
React Router DOMMain SPAdesktopRouter.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

MistakeFix
Using next/link in SPAUse react-router-dom Link
Using antd directlyUse @lobehub/ui/base-ui first, then @lobehub/ui
antd Spin / <Spin /> for loadingUse 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> declarativecreateModal / 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 stylesUse createStaticStyles + cssVar
Editing only desktopRouter.config.tsxMust edit both .tsx and .desktop.tsx
Using margin for flex spacingUse gap prop on Flexbox
Accessing zustand store without selectorUse selectors to access store data (see zustand skill)
Text or icon-text actions built with Flexbox/Text + onClickUse Button type={'text'} size={'small'} with icon when needed

Frequently asked questions about LobeHub React

Similar skills