Button

Trigger for actions or commands

Live code

Storybook

Usage

Button

This is React implementation of the Button.

Basic Example Usage


                                                
                                                import { Button } from '@lmc-eu/spirit-web-react';

                                                
                                                  <Button color="primary">Click me</Button>
                                                  <Button color="secondary">Click me</Button>
                                                  <Button color="tertiary">Click me</Button>
                                                  <Button color="plain">Click me</Button>
                                                  <Button color="success">Click me</Button>
                                                  <Button color="informative">Click me</Button>
                                                  <Button color="warning">Click me</Button>
                                                  <Button color="danger">Click me</Button>

Example Usage with Third-Party Component

So if you use a third-party component, the Button will take on all of its proper attributes.


                                                
                                                import { RouterLink } from 'react-router-dom';
                                                
                                                <Button elementType={RouterLink} to="/">
                                                  Link to home
                                                </Button>;

How to Make a Fluid Button

To span a Button to the full width of its parent, you can use display utility classes or Grid to achieve the desired layout.


                                                
                                                <div className="d-grid">
                                                  <Button>Primary block-level Button</Button>
                                                </div>
                                                <div className="d-grid d-tablet-block">
                                                  <Button>Primary responsive block-level Button</Button>
                                                </div>
                                                <Grid
                                                  cols={{ mobile: 1, tablet: 2 }}
                                                  spacing="space-1100"
                                                >
                                                  <Button>Primary responsive block-level Button</Button>
                                                  <Button color="secondary">Secondary responsive block-level Button</Button>
                                                </Grid>

DEPRECATION NOTICE

Property isBlock is deprecated and will be removed in the next major release.

For more information, please read the section How to Make a Fluid Button.

API

Name Type Default Required Description
children ReactNode null Content of the Button
color ComponentButtonColorType, EmotionColorType primary Color variant
elementType ElementType button Type of element
isBlock bool false DEPRECATED Span the element to the full width of its parent, see How to Make a Fluid Button section
isDisabled bool false If true, Button is disabled
isLoading bool false If true, Button is in a loading state, disabled and the Spinner is visible
isSymmetrical bool false If true, Button has symmetrical dimensions, usually only with an Icon
name string For use a button as a form data reference
onClick string null JS function to call on click
ref ForwardedRef<HTMLButtonElement> Button element reference
size Size dictionary medium Size variant
type string button Type of the Button

For more information see Button component. Button also contain all the appropriate attributes according to the type of element. The default element type for Button is <button>.

On top of the API options, the components accept additional attributes. If you need more control over the styling of a component, you can use style props and escape hatches.

Icons

This component uses the Icon component internally. To ensure correct rendering, please refer to the Icon component documentation for setup instructions.

Icon sizes differ based on button size. You can always set your desired size of an icon with boxSize prop.

Button and Icon Sizes

Button Size Icon Size
small 20px
medium 20px
large 24px

You can always set your desired size of an icon with the boxSize prop.