hmu.ai
Back to Builder Agents
Builder Agent

Hyper-Focused React Component Generation (Button) for Freelance Developers

Stop doing this manually. Deploy an autonomous Builder agent to handle react component generation (button) entirely in the background.

Zero-Shot Command Setup

Create a React functional component for a primary call-to-action button. It should accept `onClick`, `label`, and `isLoading` props. Use Tailwind CSS for styling: blue background, white text, rounded corners, padding, and a disabled state when `isLoading` is true. Include a loading spinner when `isLoading` is true.

Core Benefits & ROI

  • Accelerates UI development
  • Ensures design consistency with Tailwind
  • Reduces boilerplate code
  • Improves component reusability
  • Provides built-in loading state management
  • Supports quick prototyping

Ecosystem Integration

This "Builder" agent is a core part of the *Code Generation & Development* pillar, specifically focused on frontend UI components. It directly translates design specifications into functional React code, integrating seamlessly with styling frameworks like Tailwind CSS. This allows developers to rapidly construct user interfaces based on designs generated by "Architect" agents (e.g., `ux-flow-optimization-recommendations-architect`) or specific requirements, accelerating the implementation phase and ensuring consistency across the application's visual elements.

Sample Output

```jsx import React from 'react'; import PropTypes from 'prop-types'; /** * A primary call-to-action button component with loading state. * * @param {Object} props - The component props. * @param {Function} props.onClick - Function to call when the button is clicked. * @param {string} props.label - The text displayed on the button. * @param {boolean} [props.isLoading=false] - If true, displays a loading spinner and disables the button. */ const PrimaryButton = ({ onClick, label, isLoading = false }) => { return ( <button onClick={onClick} disabled={isLoading} className={` bg-blue-600 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-opacity-75 transition duration-150 ease-in-out ${isLoading ? 'opacity-60 cursor-not-allowed flex items-center justify-center' : ''} `} > {isLoading ? ( <span className="flex items-center"> <svg className="animate-spin -ml-1 mr-3 h-5 w-5 text-white" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" > <circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4" ></circle> <path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" ></path> </svg> Loading... </span> ) : ( label )} </button> ); }; PrimaryButton.propTypes = { onClick: PropTypes.func.isRequired, label: PropTypes.string.isRequired, isLoading: PropTypes.bool, }; export default PrimaryButton; // Example Usage in another component: /* import React, { useState } from 'react'; import PrimaryButton from './PrimaryButton'; // Adjust path as needed const MyComponent = () => { const [loading, setLoading] = useState(false); const handleButtonClick = () => { setLoading(true); // Simulate an async operation setTimeout(() => { alert('Button clicked!'); setLoading(false); }, 2000); }; return ( <div className="p-4"> <PrimaryButton onClick={handleButtonClick} label="Submit Form" isLoading={loading} /> <div className="mt-4"> <PrimaryButton onClick={() => alert('Another action!')} label="Perform Action" /> </div> </div> ); }; export default MyComponent; */ ```

Frequently Asked Questions

Can this component be customized for different colors or sizes?

Yes, you can easily customize the colors, sizes, and other styles by modifying the Tailwind CSS classes directly within the `className` string. For more dynamic styling, you could introduce additional props (e.g., `color`, `size`) and use conditional Tailwind classes or string interpolation.

How can I integrate different loading spinners or icons?

The current spinner is an SVG. You can replace the SVG code within the `isLoading ? (...) : (...)` block with any other SVG, a component from an icon library (like Font Awesome or Heroicons), or even an animated GIF, as long as you wrap it appropriately within the `<span>` tags.