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:
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:
colorText
The MYButton component also supports custom text color using colorText.
colorBorder
Customize the button border color using colorBorder.
plain
Use the plain property to render the button with a transparent style, allowing you to achieve different looks when combined with custom colors.
Rounded Corners
rounded
Use rounded to make the button have rounded corners.
circular
Use circular to make the button circular.
Sizes
size
Use the size property to adjust the button size.
Disabled State
disabled
Use disabled to disable the button.
Adding Icons
Use the icon property to add an icon to the button.
Finally, here's an example combining multiple APIs to create a custom button:
API Reference
Props
| Prop | Description | Type | Options | Default |
|---|---|---|---|---|
| type | Button type | string | primary/success/warning/danger/info | — |
| size | Button size | string | supersmall/small/medium/large/superbig | medium |
| plain | Whether it's a plain button | boolean | — | false |
| rounded | Whether it has rounded corners | boolean | — | false |
| circular | Whether it's circular | boolean | — | false |
| disabled | Whether it's disabled | boolean | — | false |
| colorBackground | Background color | string | Hex or named color | — |
| colorText | Text color | string | Hex or named color | false |
| colorBorder | Border color | string | Hex or named color | — |
| tag | Rendered HTML tag | string | Any HTML tag | button |
Type Definitions
interface ButtonProps {
type?: string;
size?: string;
plain?: boolean;
rounded?: boolean;
circular?: boolean;
disabled?: boolean;
colorBackground?: string;
colorText?: string;
colorBorder?: string;
iconOnly?: boolean;
tag?: string;
}