ナビゲーション

v2.1.0
質感

区切り線

セクションを分ける細い線です。ラベルを付けることもできます。

このページの内容

区切り線は、セクションの間に引く細い線です。既定で separator ロールを持つ<hr>に.dividerを指定します。線は境界を最もはっきり示す手段なので、余白やグループ化だけでは区切りが伝わりにくいときに使います。

区切り線

<p class="m(0) text-sm fg-text-body">Billing is managed by the workspace owner.</p><hr class="divider"><p class="m(0) text-sm fg-text-body">Invoices are sent on the first day of each month.</p>
<>  <p className="m(0) text-sm fg-text-body">Billing is managed by the workspace owner.</p>  <hr className="divider" />  <p className="m(0) text-sm fg-text-body">Invoices are sent on the first day of each month.</p></>
<p class="m(0) text-sm fg-text-body">Billing is managed by the workspace owner.</p><hr class="divider"><p class="m(0) text-sm fg-text-body">Invoices are sent on the first day of each month.</p>
<template>  <p class="m(0) text-sm fg-text-body">Billing is managed by the workspace owner.</p>  <hr class="divider">  <p class="m(0) text-sm fg-text-body">Invoices are sent on the first day of each month.</p></template>

#ラベル付き

divider-labelはラベルの両側に線を引きます。<hr>にはテキストを入れられないため、role="separator"を指定した要素に適用します。

ラベル付き

<button type="button" class="btn w-full">Continue with a passkey</button><div class="divider divider-label" role="separator">or</div><input class="input" type="email" placeholder="you@example.com" aria-label="Email">
<>  <button type="button" className="btn w-full">Continue with a passkey</button>  <div className="divider divider-label" role="separator">or</div>  <input className="input" type="email" placeholder="you@example.com" aria-label="Email" /></>
<button type="button" class="btn w-full">Continue with a passkey</button><div class="divider divider-label" role="separator">or</div><input class="input" type="email" placeholder="you@example.com" aria-label="Email">
<template>  <button type="button" class="btn w-full">Continue with a passkey</button>  <div class="divider divider-label" role="separator">or</div>  <input class="input" type="email" placeholder="you@example.com" aria-label="Email"></template>

#縦の区切り線

divider-verticalは横並びの項目の間に置く区切り線で、行全体の高さに伸びます。操作要素のグループを区切る場合はrole="separator"とaria-orientation="vertical"を指定し、見た目の区切りとしてのみ使う場合はaria-hidden="true"で支援技術から隠します。

縦の区切り線

<div class="flex items-center gap-sm">  <button type="button" class="btn btn-quiet btn-sm">Edit</button>  <span class="divider divider-vertical" role="separator" aria-orientation="vertical"></span>  <button type="button" class="btn btn-quiet btn-sm">Share</button>  <button type="button" class="btn btn-quiet btn-sm">Export</button></div>
<div className="flex items-center gap-sm">  <button type="button" className="btn btn-quiet btn-sm">Edit</button>  <span className="divider divider-vertical" role="separator" aria-orientation="vertical"></span>  <button type="button" className="btn btn-quiet btn-sm">Share</button>  <button type="button" className="btn btn-quiet btn-sm">Export</button></div>
<div class="flex items-center gap-sm">  <button type="button" class="btn btn-quiet btn-sm">Edit</button>  <span class="divider divider-vertical" role="separator" aria-orientation="vertical"></span>  <button type="button" class="btn btn-quiet btn-sm">Share</button>  <button type="button" class="btn btn-quiet btn-sm">Export</button></div>
<template>  <div class="flex items-center gap-sm">    <button type="button" class="btn btn-quiet btn-sm">Edit</button>    <span class="divider divider-vertical" role="separator" aria-orientation="vertical"></span>    <button type="button" class="btn btn-quiet btn-sm">Share</button>    <button type="button" class="btn btn-quiet btn-sm">Export</button>  </div></template>

#クラス

クラス説明
divider--color-line-dividerの1px罫線
divider-vertical同じ行の項目を区切る線です。高さは行と同じです。divider と併用します
divider-label「または」などのキャプションを挟んで線が分かれます。hr にはテキストを入れられないため、role="separator"を持つ要素に適用します。divider と併用します

#ソース

@master/ui/components/divider.css
/* * Divider: one hairline between sections, on an <hr> or an element with role="separator". * With a label, the line parts around the words. */@layer components.ui {  .divider {    flex: none;    height: 1px;    margin: 0;    border: 0;    background: var(--color-line-divider);    color: var(--color-text-muted);    /* Between items in a row: it takes the row's height. */    &.divider-vertical {      align-self: stretch;      width: 1px;      height: auto;      min-height: 1em;    }    /* A caption in the line, such as "or". */    &.divider-label {      display: flex;      align-items: center;      gap: .75rem;      height: auto;      background: none;      font-size: .75rem;      line-height: 1.5;      /* A caption longer than its room wraps in the middle and leaves a line on each side, so it still parts. */      text-align: center;      text-wrap: balance;      &::before, &::after {        content: '';        flex: 1 0 1.5rem;        height: 1px;        background: var(--color-line-divider);      }    }    @media (forced-colors: active) {      background: CanvasText;      &.divider-label {        background: none;        &::before, &::after {          background: CanvasText;        }      }    }  }}