@yuanzong/mui
v1.5.0
Published
Custom MUI components
Downloads
141
Readme
@yuanzong/mui
Custom Material UI helpers for Create & Learn projects. This package bundles a handful of common patterns: confirmation dialogs, responsive modals, lazy-loaded accordions, and a curated timezone picker.
Installation
npm install @yuanzong/mui @mui/material @mui/icons-material react react-domOptionally include the baseline CSS reset if you want the bundled typography and link styles:
import '@yuanzong/mui/baseline.css';Components
ConfirmationModal
A small dialog with cancel/submit actions.
import { ConfirmationModal } from '@yuanzong/mui';
function DeleteUserDialog({ open, onClose, onConfirm, loading }: Props) {
return (
<ConfirmationModal
open={open}
onClose={onClose}
onSubmit={onConfirm}
loading={loading}
submitLabel="Delete"
>
Are you sure you want to delete this user?
</ConfirmationModal>
);
}Key props:
onClose: closes the dialogonSubmit: submit action handlerloading: disables the submit button and shows its loading statecancelLabel/submitLabel: override button text- Accepts other
Dialogprops exceptonClose
ResponsiveModal
A dialog that automatically switches to full-screen on small viewports.
import { ResponsiveModal } from '@yuanzong/mui';
<ResponsiveModal open={open} onClose={handleClose} title="Edit profile">
{/* modal body */}
</ResponsiveModal>;LazyLoader
An accordion that triggers a callback when first expanded and shows a loading bar until content is ready.
import { LazyLoader } from '@yuanzong/mui';
<LazyLoader
summary="Show details"
loading={isFetching}
onExpanded={fetchData}
actions={<Button onClick={refresh}>Refresh</Button>}
>
{content}
</LazyLoader>;Supports select Accordion props: square, elevation, variant, and sx.
TimezonePicker
Autocomplete dropdown backed by a curated list of timezones.
import { TimezonePicker, zones } from '@yuanzong/mui';
<TimezonePicker
defaultZone="America/New_York"
setTimezone={(zone) => console.log(zone.tzCode)}
label="Timezone"
fullWidth
/>;Details:
defaultZonedefaults toAmerica/Los_Angeleswhen omitted or nullsetTimezonereceives{ tzCode, name }- Additional
TextFieldprops likelabel,placeholder,helperText, etc. are supported - The
zonesarray andZonetype are exported if you need to reuse or filter the list
Scripts
npm run build– build the distributable bundlenpm run lint– lint with Biomenpm run typecheck– TypeScript type check
License
MIT © Yuanzong Qiu
