@k8ordo/ui

Dialog

Modalの中に置く見出しと本文、閉じるボタンの組です。

インポート

ts
import { Dialog } from '@k8ordo/ui';
import { Modal } from '@k8ordo/ui';

使い方

tsx
<Dialog.Root>
  <Dialog.Header onClose={handleClose} title="Dialog Title" />
  <Dialog.Content>Dialog content here</Dialog.Content>
</Dialog.Root>

基本的な使い方

Confirmation

Are you sure you want to proceed?

tsx
const [isOpen, setIsOpen] = useState(false);

<Button onClick={() => setIsOpen(true)}>
  Open Dialog
</Button>
<Modal
  isOpen={isOpen}
  onClose={() => setIsOpen(false)}
  side="center"
>
  <Dialog.Root>
    <Dialog.Header
      onClose={() => setIsOpen(false)}
      title="Confirmation"
    />
    <Dialog.Content>
      <p>Are you sure you want to proceed?</p>
    </Dialog.Content>
  </Dialog.Root>
</Modal>

アラートダイアログ

Delete Confirmation

Are you sure you want to delete this item? This action cannot be undone.

tsx
const [isOpen, setIsOpen] = useState(false);

<Button onClick={() => setIsOpen(true)}>Delete Item</Button>
<Modal
  isOpen={isOpen}
  onClose={() => setIsOpen(false)}
  side="center"
>
  <Dialog.Root role="alertdialog">
    <Dialog.Header
      onClose={() => setIsOpen(false)}
      title="Delete Confirmation"
    />
    <Dialog.Content>
      <div className={styles.body}>
        <p>
          Are you sure you want to delete this item?
          This action cannot be undone.
        </p>
        <div className={styles.actions}>
          <Button
            color="base"
            onClick={() => setIsOpen(false)}
            variant="outline"
          >
            Cancel
          </Button>
          <Button onClick={() => setIsOpen(false)}>
            Delete
          </Button>
        </div>
      </div>
    </Dialog.Content>
  </Dialog.Root>
</Modal>

Props

Dialog.Root

children?
Type: ReactNode
Default: -
id?
Type: string
Default: -
ref?
Type: Ref<HTMLElement>
Default: -
role?
Type: 'dialog'|'alertdialog'
Default: -
tabIndex?
Type: number
Default: -
PropTypeDefault
children?ReactNode-
id?string-
ref?Ref<HTMLElement>-
role?'dialog'|'alertdialog'-
tabIndex?number-

Dialog.Header

onClose
Type: () => void
Default: -
title
Type: ReactNode
Default: -
PropTypeDefault
onClose() => void-
titleReactNode-

Dialog.Content

children?
Type: ReactNode
Default: -
PropTypeDefault
children?ReactNode-
k8ordo

Baselineに入った機能を、制限なく使うReactのライブラリ群。