Skip to content
Components

Button

A clickable element which communicates that users can trigger an action.

First, import the component.

import {Button} from '@pleo-io/telescope'

Then use it, like so:

Information:

Use the forwardedAs prop instead of the as prop if using styled-components to add styles to your Button.

The component accepts the following props.

PropTypeDefault
as
any
destructive
boolean
disabled
boolean
forwardedAs
any
fullWidth
boolean
IconLeft
React.ComponentType
IconRight
React.ComponentType
inherit
boolean
loading
boolean
loadingText
string
skeleton
boolean
false
to
string
tooltipProps
Omit<TooltipProps, "children">
variant*
enum

To use the button as an hyperlink, use the href prop. This will semantically render an <a>.

<Button href="https://pleo.io">Go home</Button>

To use the button component with a routing Library like React Router, simply pass the Link from react-router as the as prop.

import {Link} from 'react-router'

export default () => (
    <Button as={Link} to="/home">
        Router link button
    </Button>
)

If you add custom styles to the Button component using styled-components (i.e. styled(Button) or css={{}}), use the forwardedAs prop instead of the as prop. Otherwise, the Button styles from Telescope will not be applied to your component.

import {Link} from 'react-router'

const StyledButton = styled(Button)`
    margin-left: $tokens.spacing12;
`

export default () => (
    <StyledButton forwardedAs={Link} to="/expenses">
        Go to expenses
    </StyledButton>
)
import {Link} from 'react-router'

export default () => (
    <Button
        css={{margin-left: $tokens.spacing12}}
        forwardedAs={Link}
        to="/expenses"
    >
        Go to expenses
    </Button>
)

We provide a NakedButton where all the styles of the button have been stripped away while the functionality, semantics and accessibility are still provided.

We often use icons in relation to interactive elements in the UI. Dropping an icon into a NakedButton will result in the following.