화면 위에 떠 있으며 특정 상황에서만 나타나는 보조적인 동작을 위한 버튼입니다.
npm install @seed-design/lynx-react @seed-design/lynx-css
pnpm add @seed-design/lynx-react @seed-design/lynx-css
yarn add @seed-design/lynx-react @seed-design/lynx-css
bun add @seed-design/lynx-react @seed-design/lynx-css
import IconBellFill from "@karrotmarket/lynx-monochrome-icon/IconBellFill";
import { ContextualFloatingButton, PrefixIcon } from "@seed-design/lynx-react";
export default function Example() {
return (
<ContextualFloatingButton>
<PrefixIcon icon={<IconBellFill />} />
알림 설정
</ContextualFloatingButton>
);
}
variant?"layer" | "solid" | undefined
Type
"layer" | "solid" | undefined
Default
"solid"
layout?"iconOnly" | "withText" | undefined
Type
"iconOnly" | "withText" | undefined
Default
"withText"
disabled?boolean | undefined
버튼의 비활성화 여부입니다. true이면 tap과 눌림 상태가 막힙니다.
Type
boolean | undefined
Default
false
loading?boolean | undefined
버튼에 등록된 비동기 작업이 진행 중임을 나타냅니다. disabled와 같이 tap과 눌림 상태를 막습니다.
Type
boolean | undefined
Default
false
Contextual Floating Button은 Float와 함께 사용하면 편리합니다. 위치 기준 frame에 position="relative"를 지정하고, Float의 placement="bottom-center"로 버튼을 가운데 아래에 배치하세요.
import IconBellFill from "@karrotmarket/lynx-monochrome-icon/IconBellFill";
import { Box, ContextualFloatingButton, Float, PrefixIcon } from "@seed-design/lynx-react";
export default function Example() {
return (
<Box
position="relative"
display="flex"
flexDirection="column"
width="full"
flexGrow
minHeight="0"
borderWidth={1}
borderColor="stroke.neutralMuted"
>
<Float placement="bottom-center" offsetY="x4">
<ContextualFloatingButton>
<PrefixIcon icon={<IconBellFill />} />
알림 설정
</ContextualFloatingButton>
</Float>
</Box>
);
}
import IconPlusLine from "@karrotmarket/lynx-monochrome-icon/IconPlusLine";
import { ContextualFloatingButton, PrefixIcon } from "@seed-design/lynx-react";
export default function Example() {
return (
<ContextualFloatingButton variant="solid">
<PrefixIcon icon={<IconPlusLine />} />
Solid Variant
</ContextualFloatingButton>
);
}
import IconPlusLine from "@karrotmarket/lynx-monochrome-icon/IconPlusLine";
import { ContextualFloatingButton, PrefixIcon } from "@seed-design/lynx-react";
export default function Example() {
return (
<ContextualFloatingButton variant="layer">
<PrefixIcon icon={<IconPlusLine />} />
Layer Variant
</ContextualFloatingButton>
);
}
layout="iconOnly"에는 스크린 리더가 읽을 accessibility-label을 함께 지정하세요.
import IconPlusFill from "@karrotmarket/lynx-monochrome-icon/IconPlusFill";
import { ContextualFloatingButton, Icon } from "@seed-design/lynx-react";
export default function Example() {
return (
<ContextualFloatingButton layout="iconOnly" accessibility-label="추가">
<Icon icon={<IconPlusFill />} />
</ContextualFloatingButton>
);
}
이 예제는 탭하면 loading 상태가 즉시 시작되고 2초 뒤에 원래 상태로 돌아옵니다. loading 중에는 탭할 수 없습니다.
import IconPlusLine from "@karrotmarket/lynx-monochrome-icon/IconPlusLine";
import { useState } from "@lynx-js/react";
import { ContextualFloatingButton, PrefixIcon } from "@seed-design/lynx-react";
export default function Example() {
const [loading, setLoading] = useState(false);
function handleTap() {
"background only";
setLoading(true);
setTimeout(() => setLoading(false), 2000);
}
return (
<ContextualFloatingButton loading={loading} bindtap={handleTap}>
<PrefixIcon icon={<IconPlusLine />} />
시간이 걸리는 액션
</ContextualFloatingButton>
);
}
onClick 대신 bindtap 또는 main-thread:bindtap을 사용합니다.
aria-label 대신 accessibility-label을 사용합니다. disabled 또는 loading 상태는 비활성 버튼으로 알립니다.
- 웹 SVG 대신 Lynx icon을
PrefixIcon 또는 Icon slot에 전달합니다.
- Lynx에서는 loading 중 탭을 차단합니다.
- 버튼 자체의
transform을 덮어쓰지 마세요. 위치 조정이 필요하면 바깥 wrapper에 적용하세요.