Button

The Button element in web development is an HTML element used to create interactive buttons that users can click or tap to trigger specific actions or functions on a web page. The <button> element is an essential part of web forms, user interfaces, and general interactivity.

Installation

Ensure that have the @zyxui library installed in your project:

If you haven't install and setup @zyxui before please follow the installation guide

Basic Button

To create a basic button, simply use the Button component without passing any props. It will inherit the primary color as the default.

Customization

The Button component is highly customizable, allowing you to fine-tune its appearance and behavior to align with your project's unique requirements. Explore the following customization options:

Colors

Our Button component offers a color palette with options such as default, error, warning, and success. To customize these default colors to align with your project's aesthetics, consult How to customize themes in @@zyxui/button.

Variants

Modify Button styles effortlessly using the variant prop, with options like solid, bordered, light, ghost, flat, and shadow.

Sizes

Resize your buttons effortlessly with the size prop. Choose from sm (Small), md (Medium), or lg (Large) to control the button dimensions.

Radiuses

Easily customize the border-radius of your button using the radius prop, with options like sm,md, lg, circle, or none.

Start Content

The startContent prop allows you to seamlessly incorporate ReactNode elements at the beginning of a button's child. For instance, you can employ this feature to place an icon at the start of a button.

End Content

The endContent prop enables the addition of ReactNode elements at the end of a button's child. For instance, this feature is ideal for appending an icon to the button's end.

Start & End Content

Here are more examples to show you that startContent & endContent can be used together!

Icon Only

Create icon-only buttons with ease using the iconOnly prop. Use icons from libraries or custom SVGs to design your unique buttons.

API Reference

For an in-depth exploration of available props and advanced usage, consult the Button component's API reference:

PropertyDescriptionTypeDefault
classNameAdding custom class names to your button.stringundefined
colorCustomize button color styles.default | error | warning | successdefault
variantChange button hover and base styles.solid | bordered | light | ghost | flat | shadowsolid
sizeAdjust button size to your specifications.sm | md | lgmd
radiusChange button border radius style.sm | md | lg | circle | nonemd
iconOnlyCraft buttons with exclusive focus on icons.booleanfalse
startContentEnrich buttons with content at the start see example.ReactNode | undefinedundefined
endContentElevate buttons with content at the end. see exampleReactNode | undefinedundefined