Button code
Import
import { Button } from '@pluralsight/react'
API
Parameters
interface ButtonOptions extends ButtonHTMLAttributes<HTMLButtonElement> { sentiment?: 'default' | 'action' | 'danger' usage?: 'filled' | 'outline' | 'text' size?: 'md' | 'lg' endIcon?: ReactNode startIcon?: ReactNode}
- Any props that can be passed to an HTML button element.
sentiment
- Determines the theme of the button. Defaults toaction
.usage
- Determines the visual style of the button. Defaults tofilled
.size
- Determines the size of the button. Defaults tolg
endIcon
- Determines the icon to display at the end of the button.startIcon
- Determines the icon to display at the start of the button.
Size Mapping
md
: Use in condensed areas where the default size is too large.lg
: Should be used in most, if not all cases.
Customizing
There are 3 ways to customize the Button component: using the button recipe, extending the recipe, or passing a className prop.
Button recipe
Pando makes use of the
There are a number of variants available for the button recipe:
palette:
“action” | “neutral” | “danger”
size:
“md” | “lg”
usage:
“text” | “outline” | “filled”
Extending the Button recipe
Using
import { css, cx } from 'styled-system/css'import { button } from 'styled-system/recipes'
const newClassName = cx(button(), css({ bg: 'Thistle', color: 'black' }))
Passing a className
prop
You can pass a className prop to the Button component to customize the Button. This is useful if your project uses
import customStyles from './customStyles.module.css'
function CustomButton(props) { return <Button className={customStyles.customButton}>{props.children}</Button>}