scrimba
Advanced React
Reusability
Challenge - Button w/ Variants
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

Challenge - Button w/ Variants
AboutCommentsNotes
Challenge - Button w/ Variants
Expand for more info
Button.js
run
preview
console
import React from "react"
import classnames from "classnames"
export default function Button({children, className, size, ...rest}) {
/**
* Challenge:
*
* Accept a `variant` prop and style the Button component
* accordingly. The values can be `success`, `warning`, or `danger`.
* Check the Figma design for the specific colors to be used for each
* variant.
*/
let sizeClass = size ? `button-${size}` : ""
const allClasses = classnames(sizeClass, className)

return (
<button className={allClasses} {...rest}>
{children}
</button>
)
}
Console
/index.html
-4:17