Create a reusable button component with different variants (primary, secondary).

Code Playground
JavaScript (V8)
Loading...
Console Output
// Output will appear here...
// For React: ReactDOM.createRoot(rootElement).render(<App />);
Recommended Answer
import React from 'react';

function Button({ children, variant = 'primary', ...props }) {
  const baseStyles = "px-4 py-2 rounded ";
  const styles = {
    primary: "bg-blue-500 text-white",
    secondary: "bg-gray-500 text-white",
  };
  
  return (
    <button className={`${baseStyles} ${styles[variant]}`} {...props}>
      {children}
    </button>
  );
}

export default Button;