In the practical application of mobile web, the use of large theme color buttons is relatively high, because of its prominence and brand attributes, it is very suitable for guiding users to operate. Therefore, STDF does not follow the gray border button of the mainstream component library as the default style, but uses a large theme color to fill the button, which should reduce the amount of writing code when using it. The rest of the styles are basically in accordance with Tailwind's style rules, but some options are classified and limited, and the incoming optional values will be processed according to the default values.
Fill modes include:
base: Solid fill button (default), background color follows state colorline: Linear button (ghost button), colorless border, black/white textlineLight: Linear light button, light borderlineState: Linear state button, border and text color follow state colortext: Plain text button, colorless texttextState: Text state button, text color follows state colorcolorLight: Light background button, light background + state color textAmong them, base, lineState, textState, and colorLight will change color following the state parameter, while line, lineLight, and text are colorless modes, not affected by state.
The status color corresponds to the four functional colors of success, warning, error, and information of the STDF color system. Please make sure that the corresponding color values have been configured in the Tailwind configuration file tailwind.config.js. Of course, you can also configure it flexibly according to your project.
The button size is full and big for block-level elements, md, sm, and xs for inline elements. When auto, the button width is determined by the width of the inner element.
The border style will only take effect if the fill mode (fill) is line, lineLight, or lineState.
Through the injClass parameter, you can inject CSS names (not limited to Tailwind CSS) to the button element inside the component, which will allow more customization possibilities for component styles. In the example, injClass implements custom colors.
If the injected class does not take effect, please add "!" before the injected class name, please refer to Tailwind Important modifier.
The button group feature has been extracted to the ButtonGroup component, which supports two ways of use: items array or children customization.
Through the icon parameter, you can inject an icon into the content area of the Button component, the parameter is the Props of the Icon component; through the loading parameter, you can inject a loading into the content area of the Button component, the parameter is the Props of the Loading component. When loading is passed in, the button is disabled by default, which can be controlled by the disabledLoading parameter. Please refer to the example.