Reaction Button
A component that allows users to express reactions to content. Used to easily provide emotional feedback such as likes and interests.
@seed-design/lynx-react@0.6.0, @seed-design/lynx-css@0.10.0
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 "./styles";
import IconBellFill from "@karrotmarket/lynx-monochrome-icon/IconBellFill";
import { Count, PrefixIcon, ReactionButton, useSeedClassName } from "@seed-design/lynx-react";
export default function Example() {
const seedClassName = useSeedClassName({ colorMode: "system" });
return (
<view className={`${seedClassName} docs-lynx-reaction-button-root`}>
<view className="reaction-button-preview">
<ReactionButton>
<PrefixIcon icon={<IconBellFill />} />
도움돼요
<Count>1</Count>
</ReactionButton>
</view>
</view>
);
}
pressed?boolean | undefined
defaultPressed?boolean | undefined
onPressedChange?((pressed: boolean) => void) | undefined
disabled?boolean | undefined
loading?boolean | undefined
style?CSSProperties | undefined
children?React.ReactNode
className?string | undefined
bindtap?EventHandler<BaseTouchEvent<Target>> | undefined
main-thread:bindtap?EventHandler<BaseTouchEvent<Element>> | undefined
import "./styles";
import IconBellFill from "@karrotmarket/lynx-monochrome-icon/IconBellFill";
import { Count, PrefixIcon, ReactionButton, useSeedClassName } from "@seed-design/lynx-react";
export default function Example() {
const seedClassName = useSeedClassName({ colorMode: "system" });
return (
<view className={`${seedClassName} docs-lynx-reaction-button-root`}>
<view className="reaction-button-preview">
<ReactionButton size="small">
<PrefixIcon icon={<IconBellFill />} />
도움돼요
<Count>1</Count>
</ReactionButton>
</view>
</view>
);
}
import "./styles";
import IconBellFill from "@karrotmarket/lynx-monochrome-icon/IconBellFill";
import { Count, PrefixIcon, ReactionButton, useSeedClassName } from "@seed-design/lynx-react";
export default function Example() {
const seedClassName = useSeedClassName({ colorMode: "system" });
return (
<view className={`${seedClassName} docs-lynx-reaction-button-root`}>
<view className="reaction-button-preview">
<ReactionButton size="xsmall">
<PrefixIcon icon={<IconBellFill />} />
도움돼요
<Count>1</Count>
</ReactionButton>
</view>
</view>
);
}
import "./styles";
import IconBellFill from "@karrotmarket/lynx-monochrome-icon/IconBellFill";
import { PrefixIcon, ReactionButton, useSeedClassName } from "@seed-design/lynx-react";
export default function Example() {
const seedClassName = useSeedClassName({ colorMode: "system" });
return (
<view className={`${seedClassName} docs-lynx-reaction-button-root`}>
<view className="reaction-button-preview">
<ReactionButton disabled>
<PrefixIcon icon={<IconBellFill />} />
비활성
</ReactionButton>
</view>
</view>
);
}
import "./styles";
import IconBellFill from "@karrotmarket/lynx-monochrome-icon/IconBellFill";
import { useState } from "@lynx-js/react";
import { PrefixIcon, ReactionButton, useSeedClassName } from "@seed-design/lynx-react";
export default function Example() {
const seedClassName = useSeedClassName({ colorMode: "system" });
const [{ pressed, loading }, setState] = useState({
pressed: false,
loading: false,
});
function handleToggle() {
"background only";
setState((previous) => ({ pressed: previous.pressed, loading: true }));
setTimeout(() => {
setState((previous) => ({ pressed: !previous.pressed, loading: false }));
}, 2000);
}
return (
<view className={`${seedClassName} docs-lynx-reaction-button-root`}>
<view className="reaction-button-preview">
<ReactionButton loading={loading} pressed={pressed} onPressedChange={handleToggle}>
<PrefixIcon icon={<IconBellFill />} />
시간이 걸리는 토글
</ReactionButton>
</view>
</view>
);
}
Even during loading, bindtap and onPressedChange still work. If you need to block events, use disabled together with loading.
Lynx ReactionButton has the following differences from React ReactionButton:
- Event Handling: Uses
bindtap instead of onClick.
- Rendering Elements: Renders native
<view> and <text> elements instead of HTML <button>.
- Accessibility Attributes: Uses Lynx native
accessibility-* attributes instead of aria-*.
- HTML Features: Does not support button/form attributes, keyboard focus, or
asChild.
- Loading State: Positions a spinner absolutely and hides existing content to maintain the original button width. Events are preserved like React.