Skip to content

Button ​

Brief Introduction ​

The button component is a fundamental interactive element for common operations, such as form submission. You can use <MYButton></MYButton> or <MYButton /> to implement a button.

About Color Usage ​

type ​

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

Code Demo
Note: The demo effect has some element magnification. For specific dimensions, please read the About Size description below.
展开代码

colorBg ​

If the above colors do not meet your needs, you can customize the color. Use colorBg to customize the button background color. For example, using a red background here:

Code Demo
If the colorBg API is used, the type attribute will be overridden by the colorBg attribute.
展开代码

colorText ​

The MYButton also supports custom text color. Use colorText to customize the button's text color.

Code Demo
展开代码

colorBorder ​

Customize the button border color. Use colorBorder to customize the button's border color.

Code Demo
展开代码

plain ​

Use the plain attribute to render the button with a transparent style, which can be combined with the custom colors above to achieve unique appearances.

Code Demo
Note: The demo effect has some element magnification. For specific dimensions, please read the About Size description below.
展开代码

About Border Radius ​

round ​

Use round to make the button have rounded corners.

Code Demo
展开代码

circle ​

Use circle to make the button circular.

Code Demo
The circle and round attributes cannot be used simultaneously.
展开代码

About Size ​

size ​

Use the size attribute to adjust the button size.

Code Demo
Note: The demo effect has some element magnification. For specific dimensions, please read the About Size description below.
展开代码

About Disabled ​

disabled ​

Use disabled to disable the button.

Code Demo
展开代码

Insert Icon ​

Use the icon property or the default slot to insert an icon into the button.

Code Demo
展开代码

Finally, combine multiple APIs to create a customized button:

Code Demo
展开代码

API Reference ​

Props ​

ParameterDescriptionTypeOptional ValuesDefault
typeButton typestringprimary / success / warning / danger / info—
sizeButton sizestringsupersmall / small / medium / large / superbigmedium
plainWhether it's a plain buttonboolean—false
roundWhether it's a rounded buttonboolean—false
circleWhether it's a circular buttonboolean—false
disabledWhether disabledboolean—false
colorBgBackground colorstringSupports hex colors or named colors—
colorTextText colorstringSupports hex colors or named colors—
colorBorderBorder colorstringSupports hex colors or named colors—
tagRender tagstringSupports all HTML tagsbutton

Type Definition ​

typescript
interface ButtonProps {
  type?: string;
  size?: string;
  plain?: boolean;
  round?: boolean;
  circle?: boolean;
  disabled?: boolean;
  colorBg?: string;
  colorText?: string;
  colorBorder?: string;
  iconOnly?: boolean;
  tag?: string;
}

Released under the MIT License.