Float
The Float component is used to place elements fixed at a specific position.
import { Box, Float } from "@seed-design/react";
import { ContextualFloatingButton } from "seed-design/ui/contextual-floating-button";
export default function FloatPreview() {
return (
<Box
position="relative"
width="480px"
height="480px"
borderWidth={1}
borderColor="stroke.neutralMuted"
>
<Float placement="top-start">
<ContextualFloatingButton>Top Start</ContextualFloatingButton>
</Float>
<Float placement="top-center">
<ContextualFloatingButton>Top Center</ContextualFloatingButton>
</Float>
<Float placement="top-end">
<ContextualFloatingButton>Top End</ContextualFloatingButton>
</Float>
<Float placement="middle-start">
<ContextualFloatingButton>Middle Start</ContextualFloatingButton>
</Float>
<Float placement="middle-center">
<ContextualFloatingButton>Middle Center</ContextualFloatingButton>
</Float>
<Float placement="middle-end">
<ContextualFloatingButton>Middle End</ContextualFloatingButton>
</Float>
<Float placement="bottom-start">
<ContextualFloatingButton>Bottom Start</ContextualFloatingButton>
</Float>
<Float placement="bottom-center">
<ContextualFloatingButton>Bottom Center</ContextualFloatingButton>
</Float>
<Float placement="bottom-end">
<ContextualFloatingButton>Bottom End</ContextualFloatingButton>
</Float>
</Box>
);
}
as?React.ElementType<any, keyof React.JSX.IntrinsicElements> | undefined
placement"bottom-end" | "bottom-start" | "top-end" | "top-start" | "bottom-center" | "top-center" | "middle-center" | "middle-end" | "middle-start"
zIndex?number | (string & {}) | undefined
You can adjust position in the left-right direction using the offsetX property.
In start and middle, adjustment is to the right; in end, adjustment is to the left.
import { Box, Float } from "@seed-design/react";
import { ContextualFloatingButton } from "seed-design/ui/contextual-floating-button";
export default function FloatOffsetX() {
return (
<Box
position="relative"
width="480px"
height="480px"
borderWidth={1}
borderColor="stroke.neutralMuted"
>
<Float placement="middle-start" offsetX="x4">
<ContextualFloatingButton>Middle Start</ContextualFloatingButton>
</Float>
<Float placement="middle-center" offsetX="x4">
<ContextualFloatingButton>Middle Center</ContextualFloatingButton>
</Float>
<Float placement="middle-end" offsetX="x4">
<ContextualFloatingButton>Middle End</ContextualFloatingButton>
</Float>
</Box>
);
}
You can adjust position in the top-bottom direction using the offsetY property.
In top and middle, adjustment is downward; in bottom, adjustment is upward.
import { Box, Float } from "@seed-design/react";
import { ContextualFloatingButton } from "seed-design/ui/contextual-floating-button";
export default function FloatOffsetY() {
return (
<Box
position="relative"
width="480px"
height="480px"
borderWidth={1}
borderColor="stroke.neutralMuted"
>
<Float placement="top-center" offsetY="x4">
<ContextualFloatingButton>Top Center</ContextualFloatingButton>
</Float>
<Float placement="middle-center" offsetY="x4">
<ContextualFloatingButton>Middle Center</ContextualFloatingButton>
</Float>
<Float placement="bottom-center" offsetY="x4">
<ContextualFloatingButton>Bottom Center</ContextualFloatingButton>
</Float>
</Box>
);
}