Skip to main content

Button

A clickable element used to trigger an action.

Usage

import { Button } from '@easy-ui-react/easy-ui-react'

export function Example() {
return <Button color="primary">Click me</Button>
}
Live Editor
<Button color="primary">Click me</Button>
Result
Loading...

Variants

VariantDescription
solidFilled background, default variant
outlinedBorder only, transparent background
flatTinted background, darker text
lightNo background, colored text, tinted on hover
Live Editor
<Button variant="solid">Solid</Button>
Result
Loading...

Colors

  • default
  • primary
  • secondary
  • success
  • warning
  • error
Live Editor
<Button color="primary">Primary</Button>
Result
Loading...

Each color maps to a set of --easyui-color-* CSS variables that can be overridden globally, see the theming guide.

Sizes

  • sm
  • md
  • lg
Live Editor
<Button size="sm">Small</Button>
Result
Loading...

Radius

  • none
  • sm
  • md
  • lg
  • full
Live Editor
<Button radius="sm">Rounded</Button>
Result
Loading...

sm, md and lg map to --easyui-radius-* CSS variables, see the theming guide.

Content

Add an icon (or any node) before/after the label with startContent / endContent. By default, they sit inside the button. set the startContentPlacement / endContentPlacement to outside to render them outside the clickable area.

Live Editor
<Button
  startContent={<ArrowLeft/>}
  startContentPlacement={"outside"}
  endContent={<ArrowRight/>}
  endContentPlacement={"outside"}
>
  Click me
</Button>
Result
Loading...

States

Loading

Set loading to replace the content with a spinner and mark the button as aria-busy. The button is automatically disabled while loading.

Live Editor
<Button loading>Saving…</Button>
Result
Loading...

Disabled

Set disabled to mark the button as disabled.

Live Editor
<Button disabled>Disabled</Button>
Result
Loading...

Full width

Live Editor
<Button fullWidth>Submit</Button>
Result
Loading...

Label & description

Add a field label above the button and a helper text. Both are optional.

Live Editor
<Button label="Account" description="This action cannot be undone.">
  Delete account
</Button>
Result
Loading...

Use descriptionPlacement to render the description below the label instead of below the button itself:

Live Editor
<Button label="Account" description="This action cannot be undone." descriptionPlacement="label">
  Delete account
</Button>
Result
Loading...

Slots

Customize individual parts via classNames:

SlotDescription
baseThe root <button> element
startContentWrapper around startContent
endContentWrapper around endContent
textWrapper around the children/text
spinnerThe loading spinner
labelThe field label element
descriptionThe description/helper text element
Live Editor
<Button classNames={{ base: 'shadow-md', text: 'tracking-wide' }}>
  Click me
</Button>
Result
Loading...

These slots can also be styled globally for every Button in your app, see the global configuration guide.

Props

PropTypeDefaultDescription
variant'solid' | 'outlined' | 'flat' | 'light''solid'Visual style
color'default' | 'primary' | 'secondary' | 'success' | 'warning' | 'error''default'Color theme
size'sm' | 'md' | 'lg''md'Button size
radius'none' | 'sm' | 'md' | 'lg' | 'full''md'Corner radius
disabledbooleanfalseDisables the button
loadingbooleanfalseShows a spinner and disables the button
fullWidthbooleanfalseMakes the button take the full available width
startContentReactNode-Content rendered before the label
endContentReactNode-Content rendered after the label
startContentPlacement'inside' | 'outside''inside'Where startContent is rendered
endContentPlacement'inside' | 'outside''inside'Where endContent is rendered
labelstring-Field label rendered above the button
descriptionstring-Helper text shown alongside the button
descriptionPlacement'label' | 'element''element'Render description below the label or below the button
classNamestring-Class applied to the root element
classNamesPartial<Record<'base' | 'startContent' | 'endContent' | 'text' | 'spinner' | 'label' | 'description', string>>-Per-slot class overrides

Button also accepts every native <button> attribute (onClick, type, name, etc.) and forwards ref to the underlying <button> element.

Storybook

Open in Storybook → and see more combinations.