Sweep Docs
API PreferencesSweep components and how to use them.
SweepWrapper  AnatomyThis contains one single component that wraps your app.
TypeScript
<SweepWrapper>
    ...
</SweepWrapper>
SweepWrapper  PropsDescription of each SweepWrapper prop.
PropTypeRequiredDescription
backgroundColorstringfalseThe background color of the slide-up panel.
foregroundColorstringfalseThe background color of your App.
backgroundClassNamestringfalseWith TailwindCSS, pass the background color of the panel as a class, for example: bg-indigo-900
backgroundClassNamestringfalseWith TailwindCSS, pass the background color of your app as a class, for example: bg-indigo-600
useSweep  AnatomyuseSweep is a hook that comes with Sweep.
TypeScript
const sweep = useSweep( config , callbacks );
...
sweep.open( ... );
...
sweep.close();
useSweep  MethodsDescription of the methods returned by the hook.
MethodParametersDescription
open( element )element: The component to display.Opens the sweep panel.
close()NoneCloses any open sweep.
useSweep  ParamsDescription of properties of the hook.
PropTypeDescription
configsweepConfigEnable and disable some functionalities.
callbackssweepCallbacksCall-back funtions.
config  AnatomyYour can enable and disable some functionalities using the config property.
TypeScript
sweepConfig : {
    blur: boolean,
    disableTouchEvents: boolean,
    blockBodyClick: boolean,
    clickBodyToClose: boolean,
    borderRadius: number,
    snapPoint: number
}
config  KeysDescription of the keys of the config.
KeyDefaultDescription
blurfalseAdds 10px of blur to every sweep animation.
disableTouchEventsfalseDisables all touch events.
blockBodyClickfalsePrevents users from clicking the children of SweepWrapper when the panel is open.
clickBodyToClosefalseCloses the panel when the user clicks the children of SweepWrapper.
borderRadius20The border radius of the bottom left and right corners of your App when the panel is open (in pixels).
snapPoint50px threshold before drag-to-close fires
callbacks  AnatomyCallbacks from the useSweep hook.
TypeScript
callbacks : {
    onToggle: (state: boolean) => void,
    onSwitch: (oldChildren: React.ReactNode, newChildren: React.ReactNode) => void
}
callbacks  KeysDescription of the keys of the callbacks param.
KeyParametersDescription
onTogglestateTriggered on sweep panel open/close, receiving a boolean for its state.
onSwitcholdChildren,newChildrenTriggered on content switch in the open sweep panel,
passing old and new content.
Types  You can import the types from the package.
TypeScript
import { sweepConfig, sweepCallbacks } from "@aiko-lab/sweep";
Types  sweepConfigThe code of sweepConfig type.
TypeScript
type sweepConfig = {
  blur?: boolean;
  disableTouchEvents?: boolean;
  blockBodyClick?: boolean;
  clickBodyToClose?: boolean;
  borderRadius?: number;
};
Types  sweepCallbacksThe code of sweepCallbacks type.
TypeScript
type sweepCallbacks = {
  onToggle?: (state: boolean) => void;
  onSwitch?: (
    oldChildren: React.ReactNode;
    newChildren: React.ReactNode
  ) => void;
};
PreviousGetting Started
NextExamples