# Floating Action Button URL: /lynx/components/floating-action-button Source: https://github.com/daangn/seed-design/blob/dev/docs/content/lynx/components/floating-action-button.mdx A button that floats on the screen and executes primary actions. Lynx Engine 최소 버전: 3.9 사용 가능 버전: @seed-design/lynx-react@0.8.0, @seed-design/lynx-css@0.12.0 ## Preview ```tsx import "./styles"; import IconPlusLine from "@karrotmarket/lynx-monochrome-icon/IconPlusLine"; import { useSeedClassName } from "@seed-design/lynx-react"; import { FloatingActionButton } from "@/components/ui/floating-action-button"; export default function Example() { const seedClassName = useSeedClassName({ colorMode: "system" }); return ( } label="Example FAB" /> ); } ``` ## Installation - npm: npx @seed-design/cli@latest add ui:floating-action-button - pnpm: pnpm dlx @seed-design/cli@latest add ui:floating-action-button - yarn: yarn dlx @seed-design/cli@latest add ui:floating-action-button - bun: bun x @seed-design/cli@latest add ui:floating-action-button ## Props ## Usage `FloatingActionButton` combines `Root`, `Icon`, `Label` from the Lynx package. `label` is required and is used by default as Root's `accessibility-label`. `extended` defaults to `true`. ```tsx import IconPlusLine from "@karrotmarket/lynx-monochrome-icon/IconPlusLine"; import { FloatingActionButton } from "@/components/ui/floating-action-button"; function handleTap() { "background only"; // Handle new post creation action. } export function NewPostButton() { return ( } label="Write new post" bindtap={handleTap} /> ); } ``` When `extended={false}`, the label is hidden on screen and displayed as a 56×56px icon button. Even then, `label` remains as the accessibility name of Root. If a different description is needed, specify `accessibility-label` directly. ## Examples ### Extended You can switch label display and layout with the `extended` prop. The default is `true`. ```tsx import "./styles"; import IconPlusLine from "@karrotmarket/lynx-monochrome-icon/IconPlusLine"; import { useState } from "@lynx-js/react"; import { Box, VStack, useSeedClassName } from "@seed-design/lynx-react"; import { FloatingActionButton } from "@/components/ui/floating-action-button"; import { Switch } from "@/components/ui/switch"; export default function Example() { const [extended, setExtended] = useState(true); function handleCheckedChange(checked: boolean) { "background only"; setExtended(checked); } const seedClassName = useSeedClassName({ colorMode: "system" }); return ( } label="Extended" extended={extended} /> ); } ``` ### Float Composition Lynx does not have React's `` component. Specify `position="relative"` on the positioning `Box`, and apply `position="absolute"`, `right`, `bottom` to the button wrapper to achieve the same layout. ```tsx import "./styles"; import IconBellFill from "@karrotmarket/lynx-monochrome-icon/IconBellFill"; import { Box, useSeedClassName } from "@seed-design/lynx-react"; import { FloatingActionButton } from "@/components/ui/floating-action-button"; export default function Example() { const seedClassName = useSeedClassName({ colorMode: "system" }); return ( } label="알림 설정" /> ); } ``` ## Web Version Differences - **Events**: Use native `bindtap` instead of `onClick`. If a handler that changes React state is passed through a wrapper, put `"background only"` on the first line of the handler. - **Accessibility**: Use `accessibility-label` instead of `aria-label`. The Registry wrapper uses the required `label` as the default accessibility name, so it preserves the name even in collapsed state. - **Rendering**: Renders native `` / `` and Lynx icon tint instead of HTML `