セパレータ
stimeo--separator
区切り線に意味を与えます。値を持ってキーボードで動かせる形にもできます。
ただの線に、区切りとしての意味を与えます。縦か横かも伝わるので、読み上げが構造を正しく伝えられます。値を持つ形にすると、フォーカスできる仕切りになります。矢印キーで増減し、Home と End で両端へ動き、そのつど値が読み上げに伝わります。実際に領域の広さを変える動きはここでは行わないので、それが要るときは仕切りの部品を使ってください。
下の細い横線は装飾的なセパレータです(role="separator" の意味付けだけで、操作はありません)。
次は縦向きの値を持つフォーカス可能なセパレータです。Tab でフォーカスし、← / → で左右の割合を増減できます(マウスのドラッグでリサイズしたい場合は Resizable コンポーネントを使います)。
こちらは横向きの値を持つセパレータです。Tab でフォーカスし、↑ / ↓ で上下の割合を増減できます。
キーボード操作
| キー | 動作 |
|---|---|
| → / ↑ | 値を増やす(縦向きセパレータは →、横向きは ↑)。フォーカス可能版。 |
| ← / ↓ | 値を減らす(縦向きセパレータは ←、横向きは ↓)。フォーカス可能版。 |
| Home / End | 最小 / 最大へジャンプ。フォーカス可能版。 |
<%# Separator demo markup. The first separator is decorative; the other two are
focusable and value-bearing, dispatching change as the arrow keys adjust them.
The consumer-owned demo.js and demo.css turn that value into pane sizes and
the divider's appearance. %>
<div class="separator-demo">
<p class="separator-demo__text"><%= t("components.separator.demo.intro") %></p>
<div
class="separator separator--horizontal"
data-controller="stimeo--separator"
data-stimeo--separator-orientation-value="horizontal"></div>
<p class="separator-demo__text"><%= t("components.separator.demo.after") %></p>
<div class="separator-demo__split">
<%# The primary pane. Its width follows --separator-split, so the separator's
Value reports this pane's size: ArrowRight raises the value while moving
the vertical divider right. %>
<div class="separator-demo__pane" id="separator-demo-primary">
<%= t("components.separator.demo.left") %>
</div>
<div
class="separator separator--vertical"
<%# Reuse the primary pane's visible text as the separator's name. %>
aria-labelledby="separator-demo-primary"
aria-controls="separator-demo-primary"
data-controller="stimeo--separator"
data-stimeo--separator-orientation-value="vertical"
data-stimeo--separator-focusable-value="true"
data-stimeo--separator-min-value="20"
data-stimeo--separator-max-value="80"
data-stimeo--separator-step-value="5"
data-stimeo--separator-value-value="50"
data-action="keydown->stimeo--separator#onKeydown"></div>
<div class="separator-demo__pane"><%= t("components.separator.demo.right") %></div>
</div>
<p class="separator-demo__text"><%= t("components.separator.demo.after_horizontal") %></p>
<%# A horizontal separator takes ArrowUp and ArrowDown. demo.js maps the same
--separator-split custom property onto the top / bottom pane ratio. %>
<div class="separator-demo__split separator-demo__split--stacked">
<div class="separator-demo__pane"><%= t("components.separator.demo.top") %></div>
<div
class="separator separator--horizontal-handle"
aria-labelledby="separator-demo-primary-stacked"
aria-controls="separator-demo-primary-stacked"
data-controller="stimeo--separator"
data-stimeo--separator-orientation-value="horizontal"
data-stimeo--separator-focusable-value="true"
data-stimeo--separator-min-value="20"
data-stimeo--separator-max-value="80"
data-stimeo--separator-step-value="5"
data-stimeo--separator-value-value="50"
data-action="keydown->stimeo--separator#onKeydown"></div>
<%# Here the lower pane is the primary one. Flexing the last child from
--separator-split makes ArrowUp raise the primary pane's value while
moving the divider up. %>
<div class="separator-demo__pane" id="separator-demo-primary-stacked">
<%= t("components.separator.demo.bottom") %>
</div>
</div>
</div>
/*
* Presentation-only styles for the separator demo.
* The line's rendering, color, and thickness are owned by the consumer's CSS. The
* library only gives meaning to role / aria-orientation / aria-valuenow.
*/
.separator-demo {
max-width: 32rem;
}
.separator-demo__text {
margin: 0.5rem 0;
}
.separator--horizontal {
height: 1px;
margin: 0.75rem 0;
background: var(--border-strong);
}
.separator-demo__split {
display: flex;
align-items: stretch;
height: 6rem;
margin-top: 1rem;
border: 1px solid var(--border-default);
border-radius: 0.5rem;
overflow: hidden;
/* demo.js updates this variable from aria-valuenow (%) to set the left pane's width. */
--separator-split: 50%;
}
.separator-demo__pane {
display: grid;
place-items: center;
padding: 0.5rem;
background: var(--surface-subtle);
}
.separator-demo__pane:first-child {
flex: 0 0 var(--separator-split);
}
.separator-demo__pane:last-child {
flex: 1;
}
.separator--vertical {
flex: 0 0 0.5rem;
background: var(--border-strong);
cursor: col-resize;
}
/* Use :focus (not :focus-visible) so the color inversion shows on click too, not
only on keyboard focus — a resize handle is dragged with the mouse, and the user
needs to see it took focus. (Same reasoning as the time_picker demo.) */
.separator--vertical:focus {
outline: 2px solid var(--accent);
outline-offset: -2px;
background: var(--accent);
}
/* Horizontal, value-bearing separator: a top/bottom split. Stacks the panes vertically;
the value-to-pane mapping (the bottom pane) is handled by the rules just below. */
.separator-demo__split--stacked {
flex-direction: column;
height: 9rem;
}
/* Size the BOTTOM pane from the value so ArrowUp (increase) moves the handle up (the top
shrinks) — the handle follows the arrow direction instead of moving the opposite way. */
.separator-demo__split--stacked .separator-demo__pane:first-child {
flex: 1;
}
.separator-demo__split--stacked .separator-demo__pane:last-child {
flex: 0 0 var(--separator-split);
}
.separator--horizontal-handle {
flex: 0 0 0.5rem;
background: var(--border-strong);
cursor: row-resize;
}
.separator--horizontal-handle:focus {
outline: 2px solid var(--accent);
outline-offset: -2px;
background: var(--accent);
}
// Consumer-side JS for the separator demo (optional).
// A valued, focusable separator increments/decrements aria-valuenow with the arrow
// keys and fires stimeo--separator:change with { value }.
// Here we reflect that value (%) into the left pane's width to visualize the resize.
// The actual layout/size computation is the consumer's job (the library only gives the
// value meaning).
document.addEventListener("stimeo--separator:change", (event) => {
const split = event.target.closest(".separator-demo__split");
if (!split) return;
split.style.setProperty("--separator-split", `${event.detail.value}%`);
});
これらのスタイルは共通のデザイントークン(ライト/ダーク両対応)を使います。共通スタイルも一緒にコピーし、ルート要素の data-theme を切り替えればダークになります。
このコンポーネントを動かすために HTML へ記述する data-* 属性です。ルート要素に下の data-controller を付け、その内側に各 target / value / action を配置します。
ルート要素に付与
data-controller="stimeo--separator"
値(Values)
| 名前 | 説明 | 属性 |
|---|---|---|
orientation
|
描画する aria-orientation(既定 horizontal、または vertical)。 |
data-stimeo--separator-orientation-value |
focusable
|
true のとき、矢印キーで値を調整できるフォーカス可能な値付きセパレーターにする(既定 false)。 | data-stimeo--separator-focusable-value |
min
|
aria-valuemin に描画する包含的な最小値(既定 0)。 |
data-stimeo--separator-min-value |
max
|
aria-valuemax に描画する包含的な最大値(既定 100)。 |
data-stimeo--separator-max-value |
step
|
矢印キー1回あたりに aria-valuenow が変化する量(既定 1)。 |
data-stimeo--separator-step-value |
value
|
aria-valuenow に描画する現在値(既定 0)。 |
data-stimeo--separator-value-value |
アクション
| 名前 | 説明 | アクション |
|---|---|---|
onKeydown
|
フォーカス可能な場合に矢印キーと Home/End で aria-valuenow を範囲内に調整する。 |
stimeo--separator#onKeydown |
イベント
| 名前 | 説明 | イベント |
|---|---|---|
change
|
矢印・Home/End キーで値が変化したときに発火。detail にクランプ済みの { value } を載せる。 |
stimeo--separator:change |
状態フック
ライブラリが操作するのはこれらの ARIA / data 属性、カスタムプロパティだけです。見た目は利用側 CSS がこれらに反応して作ります([aria-selected] / [aria-expanded] / var(--stimeo--…) などのセレクタでフックします)。
| フック | 対象 | 意味 |
|---|---|---|
aria-orientation |
ルート要素 | "horizontal" / "vertical"。 |
aria-valuenow |
ルート要素 | 値を持つ区切りの現在値(フォーカス可能時)。 |