LinkButton (링크 버튼)
LinkButton은 하이라이트 피드백이 없는 고스트(ghost) variant 버튼으로, 인라인 링크 스타일의 상호작용을 위해 설계된 컴포넌트예요. 일반 텍스트처럼 보이면서도 터치에 반응해서, 텍스트 중간에 자연스럽게 링크를 넣을 수 있어요. size, isDisabled, className prop을 활용해 크기와 스타일을 자유롭게 조절할 수 있어요.
출처: 문서
본문
Import
import { LinkButton } from 'heroui-native';
Anatomy
<LinkButton>
<LinkButton.Label>...</LinkButton.Label>
</LinkButton>
- LinkButton: 루트 pressable 컨테이너예요. 내부적으로
ghostvariant와 비활성 하이라이트 피드백을 강제해서Button을 렌더링해요. 이 값들은 소비자가 재정의할 수 없어요. - LinkButton.Label: 링크 버튼의 텍스트 콘텐츠예요. 부모 컨텍스트에서 크기와 variant 스타일을 상속받아요.
Usage
Basic Usage
LinkButton 컴포넌트는 터치 이벤트에 반응하는 인라인 링크 스타일 텍스트를 렌더링해요.
<LinkButton onPress={handlePress}>Learn more</LinkButton>
Sizes
size prop으로 텍스트 크기를 조절해요.
<LinkButton size="sm">
Small
</LinkButton>
<LinkButton size="md">
Medium
</LinkButton>
<LinkButton size="lg">
Large
</LinkButton>
Disabled State
링크 버튼을 비활성화해서 상호작용을 막을 수 있어요.
<LinkButton isDisabled>Disabled link</LinkButton>
Custom Styling
루트와 라벨 모두 className prop으로 커스텀 스타일을 적용할 수 있어요.
<LinkButton className="px-2">
<LinkButton.Label className="text-accent underline">
Styled link
</LinkButton.Label>
</LinkButton>
Inline with Text
링크 버튼을 일반 텍스트 옆에 인라인으로 배치해서 약관, 정책, 상황별 내비게이션에 활용할 수 있어요.
<View className="flex-row flex-wrap">
<Text className="text-sm text-muted">I agree to the </Text>
<LinkButton size="sm" onPress={handleTermsPress}>
<LinkButton.Label className="text-accent">
Terms of Service
</LinkButton.Label>
</LinkButton>
<Text className="text-sm text-muted"> and </Text>
<LinkButton size="sm" onPress={handlePrivacyPress}>
<LinkButton.Label className="text-accent">Privacy Policy</LinkButton.Label>
</LinkButton>
</View>
Example
import { Button, Checkbox, ControlField, LinkButton } from 'heroui-native';
import React from 'react';
import { Alert, View } from 'react-native';
export default function LinkButtonExample() {
const [isAgreed, setIsAgreed] = React.useState(false);
const handleTermsPress = () => Alert.alert('Terms', 'Navigate to Terms');
const handlePrivacyPress = () =>
Alert.alert('Privacy', 'Navigate to Privacy Policy');
return (
<View className="flex-1 px-5 items-center justify-center">
<View className="w-full max-w-xs gap-6">
<ControlField
isSelected={isAgreed}
onSelectedChange={setIsAgreed}
className="items-start"
>
<ControlField.Indicator>
<Checkbox className="mt-0.5" />
</ControlField.Indicator>
<View className="flex-row flex-wrap flex-1">
<Text className="text-sm text-muted">I agree to the </Text>
<LinkButton size="sm" onPress={handleTermsPress}>
<LinkButton.Label className="text-accent">
Terms of Service
</LinkButton.Label>
</LinkButton>
<Text className="text-sm text-muted"> and </Text>
<LinkButton size="sm" onPress={handlePrivacyPress}>
<LinkButton.Label className="text-accent">
Privacy Policy
</LinkButton.Label>
</LinkButton>
</View>
</ControlField>
<Button isDisabled={!isAgreed}>Sign up</Button>
</View>
</View>
);
}
GitHub 저장소에서 더 많은 예제를 볼 수 있어요.
API Reference
LinkButton
variant(내부에서 ghost로 강제됨)를 제외한 모든 Button prop을 상속해요.
내부적으로 적용되는 동작 오버라이드:
| override | value | description |
|---|---|---|
variant |
ghost |
항상 고스트 버튼으로 렌더링되며 변경할 수 없어요 |
highlight |
false |
하이라이트 피드백이 비활성화되며 변경할 수 없어요 |
className |
h-auto p-0 |
기본 버튼 높이와 패딩을 제거해요 |
LinkButton.Label
Button.Label과 동일해요. 동일한 prop을 받아요.