본문으로 건너뛰기

예제

액션

명령과 경로 링크를 구분하고 액션 강조, 접근 가능한 아이콘·새로고침 컨트롤, 맥락 도움말, 파괴적 메뉴 의미를 구성합니다.

공개 계약NxActionButtonNxButtonNxDropdownMenuNxHelpTooltipNxIconButtonNxIconLinkNxLinkButtonNxRefreshControlNxTooltip

실행 미리 보기

실시간
홈 열기
2분 전에 업데이트됨
매칭 정책

복사 가능한 소스

코드 예시
TSX
import { useState } from "react";

import {
    NxActionButton,
    NxButton,
    NxDropdownMenu,
    NxHelpTooltip,
    NxIconButton,
    NxIconLink,
    NxLinkButton,
    NxRefreshControl,
    NxTooltip,
} from "@nexia/sdk/host";

export function ActionsExample() {
    const [updatedAt, setUpdatedAt] = useState("Updated 2 minutes ago");

    return (
        <div className="grid gap-5">
            <div className="flex flex-wrap items-center gap-3">
                <NxButton variant="primary">Save changes</NxButton>
                <NxButton variant="secondary">Preview</NxButton>
                <NxButton variant="ghost">Cancel</NxButton>
                <NxButton variant="dangerGhost">Deactivate</NxButton>
                <NxButton variant="danger">Delete</NxButton>
                <NxButton loading>Saving</NxButton>
                <NxButton disabled>Unavailable</NxButton>
                <NxLinkButton href="/home" variant="secondary">
                    Open home
                </NxLinkButton>
                <NxActionButton kind="create" label="New record" />
                <NxDropdownMenu
                    aria-label="More actions"
                    trigger={<NxButton variant="secondary">More</NxButton>}
                    items={[
                        {
                            id: "duplicate",
                            label: "Duplicate",
                            onSelect: () => undefined,
                        },
                        {
                            id: "archive",
                            label: "Archive",
                            onSelect: () => undefined,
                        },
                        {
                            id: "delete",
                            label: "Delete",
                            destructive: true,
                            onSelect: () => undefined,
                        },
                    ]}
                />
            </div>

            <div className="flex flex-wrap items-center gap-4">
                <NxTooltip content="Reload this panel">
                    <NxIconButton
                        aria-label="Reload panel"
                        title=""
                        onClick={() => setUpdatedAt("Updated just now")}
                    >
                        <span aria-hidden="true">↻</span>
                    </NxIconButton>
                </NxTooltip>
                <NxIconLink aria-label="Open home" href="/home">
                    <span aria-hidden="true">↗</span>
                </NxIconLink>
                <NxRefreshControl
                    context="snapshot"
                    status={updatedAt}
                    onRefresh={() => setUpdatedAt("Updated just now")}
                />
                <span className="inline-flex items-center gap-1 text-sm">
                    Matching policy
                    <NxHelpTooltip content="Applied before the record list is loaded." />
                </span>
            </div>
        </div>
    );
}
예제 원본: docs/developers/examples/ui/actions.tsx