KNOW IDEA UIv0.18.0GitHub

Popover

ボタンの近くに出る小さな面。表示の設定や、言葉の説明のように、今の画面から離れずに済む短い中身に使う。中で押せる物があってよい点が Tooltip と違う。外を押すか Esc で閉じ、開いたボタンに focus が戻る。

tsx
import { Popover, Button } from "knowidea-ui";

カテゴリ: Data display。同じカテゴリ: Avatar、Badge、Chip、Status、Stat、Table、List、Timeline、Tooltip、CodeBlock、Kbd、Quote、Display、Jacket、Conversation、CodeEditor、DiffView

Demos

Basic

表示の設定を開く例。closable で右上に閉じるボタンを出す。

Show code
tsx
import { Popover, Button, Icon, Switch, SegmentedControl } from "knowidea-ui";​function Basic() {  return (    <Popover trigger={<Button variant="secondary" icon={<Icon name="settings" />}>表示</Button>} title="表示の設定" closable>      <SegmentedControl label="表示の形" fullWidth defaultValue="list" options={[{ value: "list", label: "リスト" }, { value: "calendar", label: "カレンダー" }]} />      <Switch label="完了した項目を表示する" placement="end" defaultChecked />    </Popover>  );}

Explanation

言葉の横の i から説明を出す。指で触る画面では Tooltip が出ないので、説明は Popover にする。

使用量
Show code
tsx
import { Popover, IconButton, Icon } from "knowidea-ui";​function Info() {  return (    <span style={{ display: "inline-flex", alignItems: "center", gap: "var(--space-1)" }}>      使用量      <Popover trigger={<IconButton variant="quiet" label="使用量の説明" icon={<Icon name="info" />} />} title="使用量" description="その日の 0 時からの合計。日付が変わると 0 から数え直す。" side="top" align="center" />    </span>  );}

Plain HTML

React を使わないページでは、knowidea-css の CSS を読み込み、クラスを指定する。

ブラウザの popover は、外を押すか Esc で閉じる。

Show code
html
<!-- React を使わない時は、ブラウザの popover 属性を使う --><button type="button" class="ki-button" data-variant="secondary" popovertarget="p1">表示</button><div id="p1" popover class="ki-popover" style="position: fixed; inset: auto; margin: auto"><p class="ki-popover__description">ブラウザの popover は、外を押すか Esc で閉じる。</p></div>

States

すべてのコンポーネントが、Empty、Loading、Error、Disabled、Focus の 5 つの状態を備える。Hover と Active は、確認用に固定して表示している。そのコンポーネントにあてはまらない状態は「対象外」とし、理由を添える。

StateAppearance
Empty対象外。中身の無い Popover は開かない
Loading対象外。中身の中で Skeleton を使う
Error対象外。中身の中で Alert を使う
Disabled対象外。開くボタンを Disabled にする
Focus開くと中の最初の押せる物に focus が移る。Esc か外を押すと閉じ、開いたボタンに戻る

API

NameTypeDefaultDescription
triggerReactElement-開くボタン。必須
title / descriptionReactNode-見出しと説明。見出しが読み上げの名前になる
childrenReactNode-中身
side / align"top" | "bottom" | "left" | "right" / "start" | "center" | "end""bottom" / "start"開く向き。画面の端では反対へ回る
closable / closeLabelboolean / stringfalse / "閉じる"右上の閉じるボタン
aria-labelstring-見出しが無い時の名前
open / defaultOpen / onOpenChangeboolean-制御と非制御

CSS

Classes and data attributes

NameDescription
.ki-popover面。data-starting-style と data-ending-style で出入りする
.ki-popover__head、__title、__description、__body見出しの行、見出し、説明、中身

CSS variables

コンポーネントが参照するのは、役割を表す名前の変数だけで、素の値は参照しない。オーバーライドの方法は Overriding を参照。

VariableUsage
--color-surface、--color-line、--shadow-pop背景、枠線、影
--radius-3角丸
--motion-duration-fast出入りの動き。prefers-reduced-motion で止まる

Accessibility

KNOW IDEA UIv0.18.0

GitHub

ページと見出しを探す。/ か Ctrl K でどのページからも開く。

Code