Install
openclaw skills install building-componentsReact component building and composition best practices. Use when creating, reviewing, or refactoring React components. Covers component structure, props patterns, composition techniques, and reusability guidelines.
openclaw skills install building-componentsBest practices for building reusable, maintainable React components.
Reference these guidelines when:
Each component should do one thing well. Split large components into smaller, focused pieces.
Prefer composing components together rather than complex inheritance hierarchies.
// ✅ Good: Composition
function Page() {
return (
<Layout>
<Header />
<Main>
<Article />
</Main>
<Footer />
</Layout>
);
}
// ❌ Avoid: Deep nesting
function Page() {
return <LayoutWithHeaderAndFooter><MainContent /></LayoutWithHeaderAndFooter>;
}
// ✅ Recommended structure
import { FC } from 'react';
interface Props {
title: string;
children?: React.ReactNode;
}
export const Card: FC<Props> = ({ title, children }) => {
return (
<div className="card">
<h2>{title}</h2>
{children}
</div>
);
};
For flexible APIs like Select/Option, Tabs/TabList/Tab/TabPanel.
For sharing behavior while keeping rendering control.
For sharing stateful logic across components.