Installation
npm install @kuzenbo/core
Usage
import { Affix } from "@kuzenbo/core";
import { Button } from "@kuzenbo/core";
function Example() {
return (
<Affix position={{ bottom: 20, right: 20 }}>
<Button>Scroll to top</Button>
</Affix>
);
}
Props
position
AffixPosition
default:"{ bottom: 0, right: 0 }"
Position of the affix element. Can specify top, bottom, left, right as numbers (px) or strings.
Whether to render the affix within a portal.
Props passed to the Portal component when withinPortal is true.
Custom z-index value. Defaults to the --kb-z-affix CSS variable.
Additional CSS classes to apply.
Position Interface
interface AffixPosition {
top?: number | string;
bottom?: number | string;
left?: number | string;
right?: number | string;
}
Examples
Bottom Right (Default)
<Affix>
<Button>Fixed Button</Button>
</Affix>
Top Center
<Affix position={{ top: 20, left: "50%" }} style={{ transform: "translateX(-50%)" }}>
<Alert>Important notification</Alert>
</Affix>
Bottom Left
<Affix position={{ bottom: 40, left: 40 }}>
<Button variant="outline" size="lg">
Help
</Button>
</Affix>
Custom Z-Index
<Affix position={{ top: 0, right: 0 }} zIndex={9999}>
<Button>Always on top</Button>
</Affix>
Without Portal
<div className="relative">
<Affix withinPortal={false} position={{ top: 10, right: 10 }}>
<Button size="sm">Relative to parent</Button>
</Affix>
</div>