Button

The Button component extends the button HTML element. Use Button to handle events and navigate users.

Usage

Import the Button component from @avocado-ui/react and render like so

Variants

The Button comes in 4 major variants - primary, success. warning, error. Show the most appropriate with the variant prop.

Shape

Button can be in one of 3 shapes - round, curve and square. Use the shape prop to specified the desired border shape.

Size

Button comes in 3 sizes - sm, md and lg respectively. Set the desired size with the size prop.

Button Type

You can set the type of the Button with the buttonType prop. Set it to unstyled, solid or outline to get the desired Button.

Button With Icon

It's very common to pair the Button component with icons. You can do this with the prefixIcon and suffixIcon prop. You'll have to set this to a React.ReactNode component, but it's more advisable to use an icon. Here's it working with feather icons.

Trimmed Text

Button texts can be unnecessarily long and you might want to trim them. You can do this by passing an int specifying the length of characters you want to show to the trim prop.

Loading Button

Loading Buttons shouldn't respond to user's actions anymore. avocado handles this by default. Set the Button to loading state with the loading prop.

Props Table

propertydescriptiontypedefault
sizesize of buttonsm, md,lgmd
shapeshape of buttonround, curve,squarecurve
prefixIconComponent by the left of the buttonnone
suffixIconComponent by the right of the buttonnone
trimtrim text longer than a certain lengthnumber
variantvariant of the buttonprimary, secondary, warning, error,
loadingset button state to loadingbooleanfalse
disabledset button state to loadingbooleanfalse