React
Action Sheet (Deprecated)
더 이상 사용되지 않습니다. Swipeable Menu Sheet을 사용하세요.
import {
ActionSheetContent,
ActionSheetItem,
ActionSheetRoot,
ActionSheetTrigger,
} from "seed-design/ui/action-sheet";
import { ActionButton } from "seed-design/ui/action-button";
const ActionSheetPreview = () => {
return (
<ActionSheetRoot>
<ActionSheetTrigger asChild>
<ActionButton>Open</ActionButton>
</ActionSheetTrigger>
<ActionSheetContent aria-label="Action Sheet">
<ActionSheetItem label="Action 1" />
<ActionSheetItem label="Action 2" />
<ActionSheetItem tone="critical" label="Action 3" />
</ActionSheetContent>
</ActionSheetRoot>
);
};
export default ActionSheetPreview;Installation
npx @seed-design/cli@latest add ui:action-sheetpnpm dlx @seed-design/cli@latest add ui:action-sheetyarn dlx @seed-design/cli@latest add ui:action-sheetbun x @seed-design/cli@latest add ui:action-sheet의존성 설치
npm install @seed-design/reactyarn add @seed-design/reactpnpm add @seed-design/reactbun add @seed-design/react아래 코드를 복사 후 붙여넣고 사용하세요
/**
* @file ui:action-sheet
* @requires @seed-design/react@^2.0.0
* @requires @seed-design/css@^2.0.0
**/
"use client";
import { ActionSheet as SeedActionSheet } from "@seed-design/react";
import { forwardRef } from "react";
import type * as React from "react";
/**
* @deprecated Use swipeable-menu-sheet instead.
*/
export interface ActionSheetRootProps extends SeedActionSheet.RootProps {}
/**
* @see https://seed-design.io/react/components/action-sheet
* @deprecated Use swipeable-menu-sheet instead.
*/
export const ActionSheetRoot = (props: ActionSheetRootProps) => {
const { children, ...otherProps } = props;
return (
<SeedActionSheet.Root closeOnInteractOutside={true} {...otherProps}>
{children}
</SeedActionSheet.Root>
);
};
/**
* @deprecated Use swipeable-menu-sheet instead.
*/
export interface ActionSheetTriggerProps extends SeedActionSheet.TriggerProps {}
/**
* @deprecated Use swipeable-menu-sheet instead.
*/
export const ActionSheetTrigger = SeedActionSheet.Trigger;
/**
* @deprecated Use swipeable-menu-sheet instead.
*/
export interface ActionSheetContentProps extends Omit<SeedActionSheet.ContentProps, "title"> {
title?: React.ReactNode;
description?: React.ReactNode;
layerIndex?: number;
}
/**
* @deprecated Use swipeable-menu-sheet instead.
*/
export const ActionSheetContent = forwardRef<HTMLDivElement, ActionSheetContentProps>(
({ children, title, description, layerIndex, ...otherProps }, ref) => {
if (
!title &&
!otherProps["aria-labelledby"] &&
!otherProps["aria-label"] &&
process.env.NODE_ENV !== "production"
) {
console.warn(
"ActionSheetContent: aria-labelledby or aria-label should be provided if title is not provided.",
);
}
const shouldRenderHeader = title || description;
return (
<SeedActionSheet.Positioner style={{ "--layer-index": layerIndex } as React.CSSProperties}>
<SeedActionSheet.Backdrop />
<SeedActionSheet.Content ref={ref} {...otherProps}>
{shouldRenderHeader && (
<SeedActionSheet.Header>
{title && <SeedActionSheet.Title>{title}</SeedActionSheet.Title>}
{description && (
<SeedActionSheet.Description>{description}</SeedActionSheet.Description>
)}
</SeedActionSheet.Header>
)}
<SeedActionSheet.List>{children}</SeedActionSheet.List>
{/* You may implement your own i18n for dismiss label */}
<SeedActionSheet.CloseButton>취소</SeedActionSheet.CloseButton>
</SeedActionSheet.Content>
</SeedActionSheet.Positioner>
);
},
);
/**
* @deprecated Use swipeable-menu-sheet instead.
*/
export interface ActionSheetItemProps
extends Omit<SeedActionSheet.ItemProps, "asChild" | "children"> {
label: React.ReactNode;
}
/**
* @deprecated Use swipeable-menu-sheet instead.
*/
export const ActionSheetItem = forwardRef<HTMLButtonElement, ActionSheetItemProps>(
({ label, ...otherProps }, ref) => {
return (
<SeedActionSheet.Item ref={ref} {...otherProps}>
{label}
</SeedActionSheet.Item>
);
},
);
/**
* This file is a snippet from SEED Design, helping you get started quickly with @seed-design/* packages.
* You can extend this snippet however you want.
*/
Props
ActionSheetRoot
Prop
Type
childrenReact.ReactNodeopen?boolean | undefineddefaultOpen?boolean | undefinedonOpenChange?((open: boolean, details?: DialogChangeDetails) => void) | undefinedActionSheetContent
Prop
Type
title?React.ReactNodedescription?React.ReactNodelayerIndex?number | undefinedActionSheetItem
Prop
Type
labelReact.ReactNodeExamples
Portalled
<Portal>으로 <ActionSheetContent>를 감싸서 컨텐츠를 원하는 요소에 렌더링할 수 있습니다.
Portal은 기본적으로 document.body에 렌더링됩니다.
import { Portal } from "@seed-design/react";
import { ActionButton } from "seed-design/ui/action-button";
import {
ActionSheetContent,
ActionSheetItem,
ActionSheetRoot,
ActionSheetTrigger,
} from "seed-design/ui/action-sheet";
const ActionSheetPortalled = () => {
return (
<ActionSheetRoot>
<ActionSheetTrigger asChild>
<ActionButton>Open</ActionButton>
</ActionSheetTrigger>
<Portal>
<ActionSheetContent aria-label="Action Sheet">
<ActionSheetItem label="Action 1" />
<ActionSheetItem label="Action 2" />
<ActionSheetItem tone="critical" label="Action 3" />
</ActionSheetContent>
</Portal>
</ActionSheetRoot>
);
};
export default ActionSheetPortalled;Last updated on