Skip to main content

Success Button

Success Button is a reusable primary action button for submit, save, or confirm actions. It is built on MUI's Button with a success (green) contained style by default.

Use it as the main submit or save control in forms and dialogs. The button accepts custom children or name, and an optional startIcon. It does not include a loading state—use LoadingSuccessButton when you need to show loading.

Import

import { SuccessButton } from '@js-smart/react-kit';

Basic usage

<SuccessButton name="Save" onClick={() => handleSave()} />

With children

<SuccessButton onClick={() => handleSubmit()}>Submit</SuccessButton>

As form submit

<SuccessButton name="Save" type="submit" onClick={() => handleSave()} />

With start icon

<SuccessButton
name="Save"
startIcon={<SaveIcon />}
onClick={() => handleSave()}
/>

Variant and color

Override the default contained variant and success color:

<SuccessButton
name="Confirm"
variant="outlined"
color="success"
onClick={() => handleConfirm()}
/>

Accessibility

The button uses aria-label from the ariaLabel prop, or falls back to name or "Save". Set ariaLabel when the visible label is not descriptive enough for screen readers.

Peer dependencies

SuccessButton uses MUI's Button. Ensure your project has @mui/material installed (see Installation).

Props

PropTypeDefaultDescription
onClick() => voidRequired. Called when the button is clicked.
childrenReactNodeButton content. If omitted, name is used.
namestringButton label (used when children is not provided).
classNamestringCSS class name.
dataCystring'success-button'data-cy value for testing.
sxSxProps<Theme>MUI sx prop for styling.
type'button' | 'submit' | 'reset''button'Native button type.
variant'text' | 'outlined' | 'contained''contained'MUI button variant.
color'inherit' | 'primary' | 'secondary' | 'success' | 'error' | 'info' | 'warning''success'MUI button color.
startIconReactNodeIcon shown before the label.
ariaLabelstringname or 'Save'Accessible label for the button.