Skip to content

Button ​

Brief Introduction ​

The Button component is a classic interactive element, commonly used as an action button for form submission and other purposes. You can use <MYButton></MYButton> or <MYButton /> to implement a button.

Using Colors ​

type ​

Using type in MYButton allows you to define button colors. These colors are the basic color definitions provided by mengyue-components. For example, use type to achieve the color definitions below. If type is not specified, the default is a transparent color:

Code Demo
Note: The demo elements are slightly enlarged. Please refer to the Size section below for specific dimensions.
展开代码

colorBackground ​

Of course, if the above colors don't meet your needs, you can customize the button background color using colorBackground. For example, using a red background:

Code Demo
If you use the colorBackground API, the type property will be overridden by the colorBackground property.
展开代码

colorText ​

The MYButton component also supports custom text color using colorText.

Code Demo
展开代码

colorBorder ​

Customize the button border color using colorBorder.

Code Demo
展开代码

plain ​

Use the plain property to render the button with a transparent style, allowing you to achieve different looks when combined with custom colors.

Code Demo
Note: The demo elements are slightly enlarged. Please refer to the Size section below for specific dimensions.
展开代码

Rounded Corners ​

rounded ​

Use rounded to make the button have rounded corners.

Code Demo
展开代码

circular ​

Use circular to make the button circular.

Code Demo
The circular and rounded properties cannot be used simultaneously.
展开代码

Sizes ​

size ​

Use the size property to adjust the button size.

Code Demo
Note: The demo elements are slightly enlarged. Please refer to the Size section above for specific dimensions.
展开代码

Disabled State ​

disabled ​

Use disabled to disable the button.

Code Demo
展开代码

Adding Icons ​

Use the icon property to add an icon to the button.

Code Demo
展开代码

Finally, here's an example combining multiple APIs to create a custom button:

Code Demo
展开代码

API Reference ​

Props ​

PropDescriptionTypeOptionsDefault
typeButton typestringprimary/success/warning/danger/info—
sizeButton sizestringsupersmall/small/medium/large/superbigmedium
plainWhether it's a plain buttonboolean—false
roundedWhether it has rounded cornersboolean—false
circularWhether it's circularboolean—false
disabledWhether it's disabledboolean—false
colorBackgroundBackground colorstringHex or named color—
colorTextText colorstringHex or named colorfalse
colorBorderBorder colorstringHex or named color—
tagRendered HTML tagstringAny HTML tagbutton

Type Definitions ​

typescript
interface ButtonProps {
  type?: string;
  size?: string;
  plain?: boolean;
  rounded?: boolean;
  circular?: boolean;
  disabled?: boolean;
  colorBackground?: string;
  colorText?: string;
  colorBorder?: string;
  iconOnly?: boolean;
  tag?: string;
}

Released under the MIT License.