Building consistent, maintainable code means leveraging existing tools effectively. This guide covers three critical practices: using Lucide React for icons, using shadcn/ui for components, and reusing the CTA type everywhere.
These practices prevent code duplication, ensure consistency, and make global changes trivial.
Three Practices for Consistency
Practice 1: Icons with Lucide React
Rule: Always use Lucide React. Never import SVGs directly.**
Lucide is already in your project. Every icon is consistent, customizable, and type-safe. Building a custom SVG system is wasted effort.
How to Use Lucide
In your types** (store icon as string name):
typescript
exportinterfaceFeature {
icon?: string; // Icon name as string: 'Zap', 'Heart', 'Star'
}
exportinterfaceIndustry {
icon?: string; // Same pattern everywhere
}
In your components** (resolve string to component):
// If Figma shows a blue card with rounded corners and shadow:
<Card className="border-2 border-blue-600 rounded-lg shadow-lg p-6">
<CardTitleclassName="text-xl text-blue-600">Title</CardTitle>
</Card>
// If you need custom spacing:<ButtonclassName="px-8 py-4 text-lg font-bold rounded-xl"style={{backgroundColor: '#0066ff',
borderRadius: '12px',
}}
>
Custom Button
</Button>
// In feature cards:
<CTAButton cta={feature.cta} />
// In hero section:<CTAButtoncta={data.primaryCta}className="text-lg" />// In industry cards:<CTAButtoncta={industry.link}variant="outline" />
One component handles all CTA rendering consistently.
Benefit: One Change Fixes Everything
Update the CTA type or component once. Affects every button in your app.
typescript
// Add tracking to CTAexportinterface CTA {
label?: string;
href?: string;
tracking?: {
event: string;
properties?: Record<string, string>;
};
}
// CTAButton component handles tracking:exportfunctionCTAButton({ cta }: CTAButtonProps) {
consthandleClick = () => {
if (cta?.tracking) {
analytics.track(cta.tracking.event, cta.tracking.properties);
}
};
return (
<ButtononClick={handleClick}><ahref={cta?.href}>{cta?.label}</a></Button>
);
}
// Every button in the app now tracks! No changes needed to component files.
This is the power of reusable types.
Putting It All Together
Here's how these three practices work in a real component: