Skip to main content

Excel Button

Excel Button is a reusable button for triggering Excel export or spreadsheet-related actions. It is built on MUI's Button with a success (green) contained style and rounded corners.

Use it on list or table views where users can export data to Excel. The button accepts custom children or name, and an optional startIcon (e.g. an Excel or file icon).

Import

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

Basic usage

<ExcelButton name="Export to Excel" onClick={() => exportToExcel()} />

With children

<ExcelButton onClick={() => exportToExcel()}>Download Excel</ExcelButton>

Custom start icon

import TableChartIcon from '@mui/icons-material/TableChart';

<ExcelButton
name="Export"
startIcon={<TableChartIcon />}
onClick={() => exportToExcel()}
/>

Accessibility

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

Peer dependencies

ExcelButton 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.
sxSxProps<Theme>MUI sx prop for styling.
type'button' | 'submit' | 'reset''button'Native button type.
startIconReactNodeIcon shown before the label.
dataCystring'excel-button'data-cy value for testing.
ariaLabelstringname or 'Export to Excel'Accessible label for the button.