Field Button
A button in the form of an input field, used to open selection dialogs or pickers. When selection is complete, the selected value is displayed in the button label.
import "./styles";
import { useCallback, useState } from "@lynx-js/react";
import { VStack, useSeedClassName } from "@seed-design/lynx-react";
import {
FieldButton,
FieldButtonPlaceholder,
FieldButtonValue,
} from "@/components/ui/field-button";
export default function Example() {
const seedClassName = useSeedClassName({ colorMode: "system" });
const [value, setValue] = useState<string | null>(null);
const selectValue = useCallback(() => {
"background only";
setValue("판교동");
}, []);
const clearValue = useCallback(() => {
"background only";
setValue(null);
}, []);
return (
<view className={`${seedClassName} docs-lynx-input-button-root`}>
<VStack className="input-button-preview">
<VStack className="input-button-preview__content">
<FieldButton
label="동네"
description="거래할 동네를 선택해 주세요."
showClearButton={value != null}
buttonProps={{
"accessibility-label": value ? `동네 변경. 현재: ${value}` : "동네 선택",
bindtap: selectValue,
}}
clearButtonProps={{
bindtap: clearValue,
}}
>
{value == null ? (
<FieldButtonPlaceholder>동네를 선택해 주세요</FieldButtonPlaceholder>
) : (
<FieldButtonValue>{value}</FieldButtonValue>
)}
</FieldButton>
</VStack>
</VStack>
</view>
);
}Installation
npx @seed-design/cli@latest add ui:field-buttonpnpm dlx @seed-design/cli@latest add ui:field-buttonyarn dlx @seed-design/cli@latest add ui:field-buttonbun x @seed-design/cli@latest add ui:field-buttonInstall dependencies
npm install @karrotmarket/lynx-monochrome-icon @seed-design/lynx-reactyarn add @karrotmarket/lynx-monochrome-icon @seed-design/lynx-reactpnpm add @karrotmarket/lynx-monochrome-icon @seed-design/lynx-reactbun add @karrotmarket/lynx-monochrome-icon @seed-design/lynx-reactCopy the code below and paste it in
/**
* @file ui:field-button
* @requires @seed-design/lynx-react@>=0.7.0 <1.0.0
* @requires @seed-design/lynx-css@>=0.11.0 <1.0.0
* @requires @karrotmarket/lynx-monochrome-icon@>=1.20.0 <2.0.0
**/
import IconXmarkCircleFill from "@karrotmarket/lynx-monochrome-icon/IconXmarkCircleFill";
import * as React from "@lynx-js/react";
import { Field as SeedField, InputButton as SeedInputButton } from "@seed-design/lynx-react";
interface FieldButtonClearButtonProps extends Omit<SeedInputButton.ClearButtonProps, "icon"> {}
export interface FieldButtonProps extends Omit<SeedInputButton.RootProps, "children"> {
children?: React.ReactNode;
label?: React.ReactNode;
labelWeight?: SeedField.LabelProps["weight"];
indicator?: React.ReactNode;
prefixIcon?: SeedInputButton.PrefixIconProps["icon"];
prefix?: React.ReactNode;
suffixIcon?: SeedInputButton.SuffixIconProps["icon"];
suffix?: React.ReactNode;
description?: React.ReactNode;
errorMessage?: React.ReactNode;
required?: boolean;
showRequiredIndicator?: boolean;
showClearButton?: boolean;
buttonProps?: SeedInputButton.ButtonProps;
clearButtonProps?: FieldButtonClearButtonProps;
fieldRef?: React.Ref<React.ComponentRef<typeof SeedField.Root>>;
inputButtonRef?: React.Ref<React.ComponentRef<typeof SeedInputButton.Root>>;
}
/**
* @see https://crispy.carrot-soft.tech/lynx/components/input-button
*/
export const FieldButton = React.forwardRef<unknown, FieldButtonProps>((props, ref) => {
const {
children,
label,
labelWeight,
indicator,
prefixIcon,
prefix,
suffixIcon,
suffix,
description,
errorMessage,
required,
showRequiredIndicator,
showClearButton,
buttonProps,
clearButtonProps,
fieldRef,
inputButtonRef,
disabled,
invalid,
readOnly,
...rootProps
} = props;
const renderHeader = label != null || indicator != null;
const renderDescription = description != null && !(invalid && errorMessage != null);
const renderErrorMessage = invalid && errorMessage != null;
const renderFooter = renderDescription || renderErrorMessage;
const renderClearButton = showClearButton && !disabled && !readOnly;
if (process.env.NODE_ENV !== "production" && !buttonProps?.["accessibility-label"]) {
console.warn("FieldButton: `buttonProps.accessibility-label` should be provided.");
}
return (
<SeedField.Root
ref={fieldRef}
required={required}
disabled={disabled}
invalid={invalid}
readOnly={readOnly}
>
{renderHeader ? (
<SeedField.Header>
<SeedField.Label weight={labelWeight}>
{label}
{showRequiredIndicator ? <SeedField.RequiredIndicator /> : null}
{indicator != null ? (
<SeedField.IndicatorText>{indicator}</SeedField.IndicatorText>
) : null}
</SeedField.Label>
</SeedField.Header>
) : null}
<SeedInputButton.Root
ref={inputButtonRef}
disabled={disabled}
invalid={invalid}
readOnly={readOnly}
{...rootProps}
>
<SeedInputButton.Button ref={ref} {...buttonProps} />
{prefixIcon ? <SeedInputButton.PrefixIcon icon={prefixIcon} /> : null}
{prefix != null ? <SeedInputButton.PrefixText>{prefix}</SeedInputButton.PrefixText> : null}
{children}
{renderClearButton ? (
<SeedInputButton.ClearButton
// 소비처에서 서비스 언어에 맞는 레이블로 재정의할 수 있습니다.
accessibility-label="지우기"
icon={<IconXmarkCircleFill />}
{...clearButtonProps}
/>
) : null}
{suffix != null ? <SeedInputButton.SuffixText>{suffix}</SeedInputButton.SuffixText> : null}
{suffixIcon ? <SeedInputButton.SuffixIcon icon={suffixIcon} /> : null}
</SeedInputButton.Root>
{renderFooter ? (
<SeedField.Footer>
{renderDescription ? <SeedField.Description>{description}</SeedField.Description> : null}
{renderErrorMessage ? (
<SeedField.ErrorMessage>{errorMessage}</SeedField.ErrorMessage>
) : null}
</SeedField.Footer>
) : null}
</SeedField.Root>
);
});
FieldButton.displayName = "FieldButton";
export interface FieldButtonValueProps extends SeedInputButton.ValueProps {}
/**
* @see https://crispy.carrot-soft.tech/lynx/components/input-button
*/
export const FieldButtonValue = SeedInputButton.Value;
export interface FieldButtonPlaceholderProps extends SeedInputButton.PlaceholderProps {}
/**
* @see https://crispy.carrot-soft.tech/lynx/components/input-button
*/
export const FieldButtonPlaceholder = SeedInputButton.Placeholder;
/**
* This file is a snippet from Crispy, helping you get started quickly with @seed-design/* packages.
* You can extend this snippet however you want.
*/
Props
FieldButton
Prop
Type
children?React.ReactNodelabel?React.ReactNodelabelWeight?"medium" | "bold" | undefinedindicator?React.ReactNodeprefixIcon?React.ReactElement<LynxIconElementProps, string | React.JSXElementConstructor<any>> | undefinedprefix?React.ReactNodesuffixIcon?React.ReactElement<LynxIconElementProps, string | React.JSXElementConstructor<any>> | undefinedsuffix?React.ReactNodedescription?React.ReactNodeerrorMessage?React.ReactNoderequired?boolean | undefinedshowRequiredIndicator?boolean | undefinedshowClearButton?boolean | undefinedbuttonProps?SeedInputButton.ButtonProps | undefinedclearButtonProps?FieldButtonClearButtonProps | undefinedfieldRef?React.Ref<NodesRef> | undefinedinputButtonRef?React.Ref<NodesRef> | undefinedstyle?CSSProperties | undefinedclassName?string | undefinedFieldButtonValue
Prop
Type
style?CSSProperties | undefinedchildren?React.ReactNodeclassName?string | undefinedFieldButtonPlaceholder
Prop
Type
style?CSSProperties | undefinedchildren?React.ReactNodeclassName?string | undefinedExamples
Basic Usage
FieldButton has an appearance similar to TextField but is a button that opens a selection dialog or picker without directly editing the value.
buttonPropsbindtap: Button tap handleraccessibility-label: Button's accessibility label
children- Composed of
FieldButtonValueorFieldButtonPlaceholder - Both elements differ only in style and are hidden from the accessibility tree. Describe the current value and action that occurs when the button is pressed with
buttonProps["accessibility-label"].
- Composed of
import "./styles";
import { useState } from "@lynx-js/react";
import { useSeedClassName, VStack } from "@seed-design/lynx-react";
import {
FieldButton,
FieldButtonPlaceholder,
FieldButtonValue,
} from "@/components/ui/field-button";
export default function Example() {
const seedClassName = useSeedClassName({ colorMode: "system" });
const [selectedCity, setSelectedCity] = useState("");
function selectCity() {
"background only";
setSelectedCity("서울");
}
function clearCity() {
"background only";
setSelectedCity("");
}
return (
<view className={`${seedClassName} docs-lynx-input-button-root`}>
<VStack className="input-button-preview">
<VStack className="input-button-preview__content">
<FieldButton
label="도시"
showClearButton={selectedCity !== ""}
buttonProps={{
bindtap: selectCity,
"accessibility-label": selectedCity
? `도시 변경. 현재: ${selectedCity}`
: "도시 선택",
}}
clearButtonProps={{ bindtap: clearCity }}
>
{selectedCity ? (
<FieldButtonValue>{selectedCity}</FieldButtonValue>
) : (
<FieldButtonPlaceholder>도시를 선택해주세요</FieldButtonPlaceholder>
)}
</FieldButton>
</VStack>
</VStack>
</view>
);
}Clear Button
Setting showClearButton to true displays the Clear Button. Clear the selected value managed by the consumer in clearButtonProps.bindtap.
If FieldButton is in disabled or readOnly state, the Clear Button is not displayed.
import "./styles";
import { useState } from "@lynx-js/react";
import { useSeedClassName, VStack } from "@seed-design/lynx-react";
import {
FieldButton,
FieldButtonPlaceholder,
FieldButtonValue,
} from "@/components/ui/field-button";
export default function Example() {
const seedClassName = useSeedClassName({ colorMode: "system" });
const [value, setValue] = useState("판교동");
function selectValue() {
"background only";
setValue("정자동");
}
function clearValue() {
"background only";
setValue("");
}
return (
<view className={`${seedClassName} docs-lynx-input-button-root`}>
<VStack className="input-button-preview">
<VStack className="input-button-preview__content">
<FieldButton
label="동네"
showClearButton={value !== ""}
buttonProps={{
bindtap: selectValue,
"accessibility-label": `동네 선택.${value ? ` 현재 동네는 ${value}입니다.` : ""}`,
}}
clearButtonProps={{ bindtap: clearValue }}
>
{value ? (
<FieldButtonValue>{value}</FieldButtonValue>
) : (
<FieldButtonPlaceholder>동네를 선택해주세요</FieldButtonPlaceholder>
)}
</FieldButton>
</VStack>
</VStack>
</view>
);
}FieldButtonValue & FieldButtonPlaceholder
FieldButtonValue and FieldButtonPlaceholder are Lynx <text> elements placed as children of FieldButton. Both elements are hidden from the accessibility tree to prevent screen readers from reading them twice.
Provide the current value and button action together with buttonProps["accessibility-label"].
import "./styles";
import { useState } from "@lynx-js/react";
import { useSeedClassName, VStack } from "@seed-design/lynx-react";
import {
FieldButton,
FieldButtonPlaceholder,
FieldButtonValue,
} from "@/components/ui/field-button";
export default function Example() {
const seedClassName = useSeedClassName({ colorMode: "system" });
const [value, setValue] = useState("");
function toggleValue() {
"background only";
setValue((current) => (current ? "" : "값 설정됨"));
}
return (
<view className={`${seedClassName} docs-lynx-input-button-root`}>
<VStack className="input-button-preview">
<VStack className="input-button-preview__content" gap="spacingY.componentDefault">
<FieldButton buttonProps={{ "accessibility-label": "현재 값: FieldButtonValue" }}>
<FieldButtonValue>FieldButtonValue</FieldButtonValue>
</FieldButton>
<FieldButton buttonProps={{ "accessibility-label": "현재 값 없음" }}>
<FieldButtonPlaceholder>FieldButtonPlaceholder</FieldButtonPlaceholder>
</FieldButton>
<FieldButton
buttonProps={{
bindtap: toggleValue,
"accessibility-label": value ? `값 지우기. 현재: ${value}` : "값 설정",
}}
>
{value ? (
<FieldButtonValue>{value}</FieldButtonValue>
) : (
<FieldButtonPlaceholder>탭하여 값 설정</FieldButtonPlaceholder>
)}
</FieldButton>
</VStack>
</VStack>
</view>
);
}Accessibility
Provide accessibility-label to the button inside Field Button. Describe which selection screen opens when the button is pressed, and if there is a currently selected value, include it as well.
<FieldButton
label="Username"
description="You don't have to use your real name."
buttonProps={{
"accessibility-label": `Open username selection screen. Currently selected name: ${username || "none"}`,
bindtap: openUsernamePicker,
}}
>
{username ? (
<FieldButtonValue>{username}</FieldButtonValue>
) : (
<FieldButtonPlaceholder>Kim Haneul</FieldButtonPlaceholder>
)}
</FieldButton>Use Cases
Controlled State
Lynx does not support HTML Form. Manage the selected value with React state and update the value in buttonProps.bindtap after opening the picker. Clear Button empties the same state in clearButtonProps.bindtap.
import "./styles";
import { useState } from "@lynx-js/react";
import { useSeedClassName, VStack } from "@seed-design/lynx-react";
import {
FieldButton,
FieldButtonPlaceholder,
FieldButtonValue,
} from "@/components/ui/field-button";
export default function Example() {
const seedClassName = useSeedClassName({ colorMode: "system" });
const [selectedCity, setSelectedCity] = useState("");
function selectCity() {
"background only";
setSelectedCity("서울");
}
function clearCity() {
"background only";
setSelectedCity("");
}
return (
<view className={`${seedClassName} docs-lynx-input-button-root`}>
<VStack className="input-button-preview">
<VStack className="input-button-preview__content">
<FieldButton
label="도시"
showClearButton={selectedCity !== ""}
buttonProps={{
bindtap: selectCity,
"accessibility-label": selectedCity
? `도시 변경. 현재: ${selectedCity}`
: "도시 선택",
}}
clearButtonProps={{ bindtap: clearCity }}
>
{selectedCity ? (
<FieldButtonValue>{selectedCity}</FieldButtonValue>
) : (
<FieldButtonPlaceholder>도시를 선택해주세요</FieldButtonPlaceholder>
)}
</FieldButton>
</VStack>
</VStack>
</view>
);
}Bottom Sheet or Picker
Open a Bottom Sheet or picker in buttonProps.bindtap and render the selection result with FieldButtonValue. Field Button does not determine which selection UI to open.
import "./styles";
import { useState } from "@lynx-js/react";
import { ActionButton, BottomSheet, useSeedClassName, VStack } from "@seed-design/lynx-react";
import {
FieldButton,
FieldButtonPlaceholder,
FieldButtonValue,
} from "@/components/ui/field-button";
export default function Example() {
const seedClassName = useSeedClassName({ colorMode: "system" });
const [open, setOpen] = useState(false);
const [value, setValue] = useState("");
function openPicker() {
"background only";
setOpen(true);
}
function selectValue() {
"background only";
setValue("판교동");
setOpen(false);
}
function clearValue() {
"background only";
setValue("");
}
return (
<view className={`${seedClassName} docs-lynx-input-button-root`}>
<VStack className="input-button-preview">
<VStack className="input-button-preview__content">
<FieldButton
label="동네"
showClearButton={value !== ""}
buttonProps={{
bindtap: openPicker,
"accessibility-label": value ? `동네 변경. 현재: ${value}` : "동네 선택",
}}
clearButtonProps={{ bindtap: clearValue }}
>
{value ? (
<FieldButtonValue>{value}</FieldButtonValue>
) : (
<FieldButtonPlaceholder>동네를 선택해주세요</FieldButtonPlaceholder>
)}
</FieldButton>
</VStack>
</VStack>
<BottomSheet.Root open={open} onOpenChange={setOpen}>
<BottomSheet.Positioner>
<BottomSheet.Backdrop />
<BottomSheet.Content>
<BottomSheet.Header>
<BottomSheet.Title>동네 선택</BottomSheet.Title>
<BottomSheet.Description>거래할 동네를 선택해주세요.</BottomSheet.Description>
</BottomSheet.Header>
<BottomSheet.Footer>
<ActionButton variant="neutralSolid" bindtap={selectValue}>
판교동 선택
</ActionButton>
</BottomSheet.Footer>
</BottomSheet.Content>
</BottomSheet.Positioner>
</BottomSheet.Root>
</view>
);
}State
Enabled
import "./styles";
import { useSeedClassName, VStack } from "@seed-design/lynx-react";
import { FieldButton, FieldButtonPlaceholder } from "@/components/ui/field-button";
export default function Example() {
const seedClassName = useSeedClassName({ colorMode: "system" });
function handleTap() {
"background only";
}
return (
<view className={`${seedClassName} docs-lynx-input-button-root`}>
<VStack className="input-button-preview">
<VStack className="input-button-preview__content" gap="spacingY.componentDefault">
<FieldButton
label="라벨"
description="설명을 써주세요"
buttonProps={{ bindtap: handleTap, "accessibility-label": "값 선택" }}
>
<FieldButtonPlaceholder>플레이스홀더</FieldButtonPlaceholder>
</FieldButton>
<FieldButton
label="라벨"
invalid
errorMessage="오류가 발생한 이유를 써주세요"
buttonProps={{ bindtap: handleTap, "accessibility-label": "값 다시 선택" }}
>
<FieldButtonPlaceholder>플레이스홀더</FieldButtonPlaceholder>
</FieldButton>
</VStack>
</VStack>
</view>
);
}Disabled
In disabled state, the button tap handler is not executed and the Clear Button is not rendered.
import "./styles";
import { useSeedClassName, VStack } from "@seed-design/lynx-react";
import { FieldButton, FieldButtonPlaceholder } from "@/components/ui/field-button";
export default function Example() {
const seedClassName = useSeedClassName({ colorMode: "system" });
function handleTap() {
"background only";
}
return (
<view className={`${seedClassName} docs-lynx-input-button-root`}>
<VStack className="input-button-preview">
<VStack className="input-button-preview__content" gap="spacingY.componentDefault">
<FieldButton
label="라벨"
description="설명을 써주세요"
disabled
showClearButton
buttonProps={{ bindtap: handleTap, "accessibility-label": "값 선택" }}
>
<FieldButtonPlaceholder>플레이스홀더</FieldButtonPlaceholder>
</FieldButton>
<FieldButton
label="라벨"
disabled
invalid
errorMessage="오류가 발생한 이유를 써주세요"
buttonProps={{ bindtap: handleTap, "accessibility-label": "값 선택" }}
>
<FieldButtonPlaceholder>플레이스홀더</FieldButtonPlaceholder>
</FieldButton>
</VStack>
</VStack>
</view>
);
}Read Only
In readOnly state, the current value is displayed but the button tap handler is not executed and the Clear Button is not rendered.
import "./styles";
import { useSeedClassName, VStack } from "@seed-design/lynx-react";
import { FieldButton, FieldButtonPlaceholder } from "@/components/ui/field-button";
export default function Example() {
const seedClassName = useSeedClassName({ colorMode: "system" });
return (
<view className={`${seedClassName} docs-lynx-input-button-root`}>
<VStack className="input-button-preview">
<VStack className="input-button-preview__content" gap="spacingY.componentDefault">
<FieldButton
label="라벨"
description="설명을 써주세요"
readOnly
showClearButton
buttonProps={{ "accessibility-label": "현재 값: 플레이스홀더" }}
>
<FieldButtonPlaceholder>플레이스홀더</FieldButtonPlaceholder>
</FieldButton>
<FieldButton
label="라벨"
readOnly
invalid
errorMessage="오류가 발생한 이유를 써주세요"
buttonProps={{ "accessibility-label": "현재 값: 플레이스홀더" }}
>
<FieldButtonPlaceholder>플레이스홀더</FieldButtonPlaceholder>
</FieldButton>
</VStack>
</VStack>
</view>
);
}Size
Define the Field Button size with size. The default is large.
Lynx supports large and medium. responsive is not supported due to the lack of CSS viewport breakpoints.
import "./styles";
import { useSeedClassName, VStack } from "@seed-design/lynx-react";
import { FieldButton, FieldButtonPlaceholder } from "@/components/ui/field-button";
export default function Example() {
const seedClassName = useSeedClassName({ colorMode: "system" });
return (
<view className={`${seedClassName} docs-lynx-input-button-root`}>
<VStack className="input-button-preview">
<VStack className="input-button-preview__content" gap="spacingY.componentDefault">
<FieldButton
label="라벨"
description="size=large (default)"
size="large"
buttonProps={{ "accessibility-label": "큰 크기 선택 화면 열기" }}
>
<FieldButtonPlaceholder>플레이스홀더</FieldButtonPlaceholder>
</FieldButton>
<FieldButton
label="라벨"
description="size=medium"
size="medium"
buttonProps={{ "accessibility-label": "중간 크기 선택 화면 열기" }}
>
<FieldButtonPlaceholder>플레이스홀더</FieldButtonPlaceholder>
</FieldButton>
</VStack>
</VStack>
</view>
);
}Customizable Parts
Do not convey meaning with icons alone. Describe the selection target and current value as text in label, description, and buttonProps["accessibility-label"].
Prefix
import "./styles";
import IconMagnifyingglassLine from "@karrotmarket/lynx-monochrome-icon/IconMagnifyingglassLine";
import { useSeedClassName, VStack } from "@seed-design/lynx-react";
import { FieldButton, FieldButtonPlaceholder } from "@/components/ui/field-button";
export default function Example() {
const seedClassName = useSeedClassName({ colorMode: "system" });
return (
<view className={`${seedClassName} docs-lynx-input-button-root`}>
<VStack className="input-button-preview">
<VStack className="input-button-preview__content" gap="spacingY.componentDefault">
<FieldButton
label="주소"
description="사이트 주소를 선택해주세요."
prefix="https://"
buttonProps={{ "accessibility-label": "사이트 주소 선택" }}
>
<FieldButtonPlaceholder>example.com</FieldButtonPlaceholder>
</FieldButton>
<FieldButton
label="검색"
description="검색 조건을 선택해주세요."
prefixIcon={<IconMagnifyingglassLine />}
buttonProps={{ "accessibility-label": "검색 조건 선택" }}
>
<FieldButtonPlaceholder>검색 조건</FieldButtonPlaceholder>
</FieldButton>
</VStack>
</VStack>
</view>
);
}Suffix
import "./styles";
import IconWonLine from "@karrotmarket/lynx-monochrome-icon/IconWonLine";
import { useSeedClassName, VStack } from "@seed-design/lynx-react";
import { FieldButton, FieldButtonPlaceholder } from "@/components/ui/field-button";
export default function Example() {
const seedClassName = useSeedClassName({ colorMode: "system" });
return (
<view className={`${seedClassName} docs-lynx-input-button-root`}>
<VStack className="input-button-preview">
<VStack className="input-button-preview__content" gap="spacingY.componentDefault">
<FieldButton
label="키"
description="측정한 키를 선택해주세요."
suffix="cm"
buttonProps={{ "accessibility-label": "키 선택" }}
>
<FieldButtonPlaceholder>170</FieldButtonPlaceholder>
</FieldButton>
<FieldButton
label="금액"
description="거래 금액을 선택해주세요."
suffixIcon={<IconWonLine />}
buttonProps={{ "accessibility-label": "거래 금액 선택" }}
>
<FieldButtonPlaceholder>50,000</FieldButtonPlaceholder>
</FieldButton>
</VStack>
</VStack>
</view>
);
}Both Affixes
import "./styles";
import IconPlusCircleLine from "@karrotmarket/lynx-monochrome-icon/IconPlusCircleLine";
import IconWonLine from "@karrotmarket/lynx-monochrome-icon/IconWonLine";
import { useSeedClassName, VStack } from "@seed-design/lynx-react";
import { FieldButton, FieldButtonPlaceholder } from "@/components/ui/field-button";
export default function Example() {
const seedClassName = useSeedClassName({ colorMode: "system" });
return (
<view className={`${seedClassName} docs-lynx-input-button-root`}>
<VStack className="input-button-preview">
<VStack className="input-button-preview__content" gap="spacingY.componentDefault">
<FieldButton
label="나이"
description="나이를 선택해주세요."
prefix="만"
suffix="세"
buttonProps={{ "accessibility-label": "나이 선택" }}
>
<FieldButtonPlaceholder>25</FieldButtonPlaceholder>
</FieldButton>
<FieldButton
label="추가 금액"
description="추가할 금액을 선택해주세요."
prefixIcon={<IconPlusCircleLine />}
suffixIcon={<IconWonLine />}
buttonProps={{ "accessibility-label": "추가 금액 선택" }}
>
<FieldButtonPlaceholder>50,000</FieldButtonPlaceholder>
</FieldButton>
</VStack>
</VStack>
</view>
);
}Indicator
You can use indicator or showRequiredIndicator. For required items, also specify required together.
import "./styles";
import { useSeedClassName, VStack } from "@seed-design/lynx-react";
import { FieldButton, FieldButtonPlaceholder } from "@/components/ui/field-button";
export default function Example() {
const seedClassName = useSeedClassName({ colorMode: "system" });
return (
<view className={`${seedClassName} docs-lynx-input-button-root`}>
<VStack className="input-button-preview">
<VStack className="input-button-preview__content" gap="spacingY.componentDefault">
<FieldButton
label="선택 필드"
labelWeight="bold"
indicator="선택"
description="이 필드는 선택사항입니다."
buttonProps={{ "accessibility-label": "선택 값 입력" }}
>
<FieldButtonPlaceholder>플레이스홀더</FieldButtonPlaceholder>
</FieldButton>
<FieldButton
label="필수 필드"
required
showRequiredIndicator
description="이 필드는 필수사항입니다."
buttonProps={{ "accessibility-label": "필수 값 입력" }}
>
<FieldButtonPlaceholder>플레이스홀더</FieldButtonPlaceholder>
</FieldButton>
</VStack>
</VStack>
</view>
);
}Web Version Differences
The body applies Content Scale that maintains the background and scales only content, while ClearButton applies Root Scale that scales its own area. When combining Primitives directly, Button must be placed as a direct child of Root or inside a Fragment for the body Content Scale to be applied. If Button is wrapped by a custom component, the body Content Scale is not applied.
- Apply tap handler and
accessibility-*attributes to Lynx<view>instead of HTML<button>. - Use
buttonProps.bindtapinstead ofonClick. If a main thread handler is needed, you can usebuttonProps["main-thread:bindtap"]. - Use
buttonProps["accessibility-label"]instead ofaria-label. - Manage the selected value with the consumer's React state instead of
valuesandonValuesChange. size="responsive"is not supported. Specifylargeormedium.
Unsupported Lynx Features
- HTML form submit, hidden input, browser validation, and React Hook Form integration are not supported.
- DOM id-based
aria-describedbyconnection andaria-haspopupare not supported.