紋理
在表面鋪上圓點、格線、斜紋、交叉斜紋或棋盤格。
本頁內容
紋理是在表面上反覆鋪排的圖樣。當一塊區域沒有內容,仍需要讓人看出用途時,可以在元素上加上 .texture。紋理以低調的單色背景圖片呈現,疊在元素原有的底色上。例如,內凹區域加上圓點後,仍保有原本內凹的外觀。
紋理
<div class="well texture flex items-center justify-center h(160)"> <button type="button" class="btn">Publish</button></div><div className="well texture flex items-center justify-center h(160)"> <button type="button" className="btn">Publish</button></div><div class="well texture flex items-center justify-center h(160)"> <button type="button" class="btn">Publish</button></div><template> <div class="well texture flex items-center justify-center h(160)"> <button type="button" class="btn">Publish</button> </div></template>#圖樣
五種圖樣各自傳達所在區域的用途。選擇圖樣時,應以它傳達的意義為準,不能只看外觀。這樣使用者在兩處看到斜紋時,就能知道兩處都表示預留空間。
圖樣
<div class="auto-grid auto-grid-fit" style="--auto-grid-min: 6rem"> <figure class="m(0) flex flex-col gap-xs"> <div class="well texture h(96)"></div> <figcaption class="text-xs fg-text-muted">Dots</figcaption> </figure> <figure class="m(0) flex flex-col gap-xs"> <div class="well texture texture-grid h(96)"></div> <figcaption class="text-xs fg-text-muted">Grid</figcaption> </figure> <figure class="m(0) flex flex-col gap-xs"> <div class="well texture texture-stripes h(96)"></div> <figcaption class="text-xs fg-text-muted">Stripes</figcaption> </figure> <figure class="m(0) flex flex-col gap-xs"> <div class="well texture texture-crosshatch h(96)"></div> <figcaption class="text-xs fg-text-muted">Crosshatch</figcaption> </figure> <figure class="m(0) flex flex-col gap-xs"> <div class="well texture texture-checker h(96)"></div> <figcaption class="text-xs fg-text-muted">Checker</figcaption> </figure></div><div className="auto-grid auto-grid-fit" style={{ '--auto-grid-min': '6rem' } as React.CSSProperties}> <figure className="m(0) flex flex-col gap-xs"> <div className="well texture h(96)"></div> <figcaption className="text-xs fg-text-muted">Dots</figcaption> </figure> <figure className="m(0) flex flex-col gap-xs"> <div className="well texture texture-grid h(96)"></div> <figcaption className="text-xs fg-text-muted">Grid</figcaption> </figure> <figure className="m(0) flex flex-col gap-xs"> <div className="well texture texture-stripes h(96)"></div> <figcaption className="text-xs fg-text-muted">Stripes</figcaption> </figure> <figure className="m(0) flex flex-col gap-xs"> <div className="well texture texture-crosshatch h(96)"></div> <figcaption className="text-xs fg-text-muted">Crosshatch</figcaption> </figure> <figure className="m(0) flex flex-col gap-xs"> <div className="well texture texture-checker h(96)"></div> <figcaption className="text-xs fg-text-muted">Checker</figcaption> </figure></div><div class="auto-grid auto-grid-fit" style="--auto-grid-min: 6rem"> <figure class="m(0) flex flex-col gap-xs"> <div class="well texture h(96)"></div> <figcaption class="text-xs fg-text-muted">Dots</figcaption> </figure> <figure class="m(0) flex flex-col gap-xs"> <div class="well texture texture-grid h(96)"></div> <figcaption class="text-xs fg-text-muted">Grid</figcaption> </figure> <figure class="m(0) flex flex-col gap-xs"> <div class="well texture texture-stripes h(96)"></div> <figcaption class="text-xs fg-text-muted">Stripes</figcaption> </figure> <figure class="m(0) flex flex-col gap-xs"> <div class="well texture texture-crosshatch h(96)"></div> <figcaption class="text-xs fg-text-muted">Crosshatch</figcaption> </figure> <figure class="m(0) flex flex-col gap-xs"> <div class="well texture texture-checker h(96)"></div> <figcaption class="text-xs fg-text-muted">Checker</figcaption> </figure></div><template> <div class="auto-grid auto-grid-fit" style="--auto-grid-min: 6rem"> <figure class="m(0) flex flex-col gap-xs"> <div class="well texture h(96)"></div> <figcaption class="text-xs fg-text-muted">Dots</figcaption> </figure> <figure class="m(0) flex flex-col gap-xs"> <div class="well texture texture-grid h(96)"></div> <figcaption class="text-xs fg-text-muted">Grid</figcaption> </figure> <figure class="m(0) flex flex-col gap-xs"> <div class="well texture texture-stripes h(96)"></div> <figcaption class="text-xs fg-text-muted">Stripes</figcaption> </figure> <figure class="m(0) flex flex-col gap-xs"> <div class="well texture texture-crosshatch h(96)"></div> <figcaption class="text-xs fg-text-muted">Crosshatch</figcaption> </figure> <figure class="m(0) flex flex-col gap-xs"> <div class="well texture texture-checker h(96)"></div> <figcaption class="text-xs fg-text-muted">Checker</figcaption> </figure> </div></template>| 類別 | 代表意義 | 用途 |
|---|---|---|
texture | 開放的展示區 | 範例、畫布或圖解的背景 |
texture texture-grid | 有定位基準的區域 | 編輯器、平面圖或版面配置教學等重視位置的畫布 |
texture texture-stripes | 預留的空間 | 欄間距、留白、空槽或圖片預留位置 |
texture texture-crosshatch | 不可使用的區域 | 封鎖的時段、不開放的日期或超出界限的範圍 |
texture texture-checker | 透明 | 用來襯出圖片或色彩的透明處 |
請勿把文字直接放在紋理上。圖樣會穿過字形,降低可讀性。請將說明文字放在紋理區域旁,或放在覆蓋紋理的面板上。
#預留與不可用
斜紋與交叉斜紋用來區分兩種空白區域。斜紋表示預留的空位,之後可能填入內容。交叉斜紋則表示無法選取。也請用文字說明狀態,讓無法辨識圖樣的使用者也能理解。這裡不開放的時段同時設為停用,並標明狀態。
預留與不可用
<div class="sheet grid grid-cols(4) gap-xs p-xs"> <button type="button" class="btn btn-quiet h(88)">9:00</button> <button type="button" class="btn btn-quiet h(88)">10:00</button> <div class="well texture texture-stripes h(88)" role="img" aria-label="11:00, kept free"></div> <div class="well texture texture-crosshatch h(88)" role="img" aria-label="12:00, closed"></div></div><p class="m(0) mt-md text-xs fg-text-muted">11:00 is kept free. The office is closed at 12:00.</p><> <div className="sheet grid grid-cols(4) gap-xs p-xs"> <button type="button" className="btn btn-quiet h(88)">9:00</button> <button type="button" className="btn btn-quiet h(88)">10:00</button> <div className="well texture texture-stripes h(88)" role="img" aria-label="11:00, kept free"></div> <div className="well texture texture-crosshatch h(88)" role="img" aria-label="12:00, closed"></div> </div> <p className="m(0) mt-md text-xs fg-text-muted"> 11:00 is kept free. The office is closed at 12:00. </p></><div class="sheet grid grid-cols(4) gap-xs p-xs"> <button type="button" class="btn btn-quiet h(88)">9:00</button> <button type="button" class="btn btn-quiet h(88)">10:00</button> <div class="well texture texture-stripes h(88)" role="img" aria-label="11:00, kept free"></div> <div class="well texture texture-crosshatch h(88)" role="img" aria-label="12:00, closed"></div></div><p class="m(0) mt-md text-xs fg-text-muted">11:00 is kept free. The office is closed at 12:00.</p><template> <div class="sheet grid grid-cols(4) gap-xs p-xs"> <button type="button" class="btn btn-quiet h(88)">9:00</button> <button type="button" class="btn btn-quiet h(88)">10:00</button> <div class="well texture texture-stripes h(88)" role="img" aria-label="11:00, kept free"></div> <div class="well texture texture-crosshatch h(88)" role="img" aria-label="12:00, closed"></div> </div> <p class="m(0) mt-md text-xs fg-text-muted">11:00 is kept free. The office is closed at 12:00.</p></template>#透明度
棋盤格用來襯出內容的透明處。把圖片放在棋盤格上,方格就會從圖片的透明處顯露出來,例如這裡的圖形鏤空處。
透明度
<div class="well texture texture-checker flex items-center justify-center w(240) h(136) fg-text-strong"> <svg width="80" height="80" viewBox="0 0 96 96" role="img" aria-label="A square mark with a round hole"> <path fill="currentColor" fill-rule="evenodd" d="M20 8h56a12 12 0 0 1 12 12v56a12 12 0 0 1-12 12H20A12 12 0 0 1 8 76V20A12 12 0 0 1 20 8Zm28 18a22 22 0 1 0 0 44 22 22 0 0 0 0-44Z" /> </svg></div><div className="well texture texture-checker flex items-center justify-center w(240) h(136) fg-text-strong"> <svg width="80" height="80" viewBox="0 0 96 96" role="img" aria-label="A square mark with a round hole"> <path fill="currentColor" fillRule="evenodd" d="M20 8h56a12 12 0 0 1 12 12v56a12 12 0 0 1-12 12H20A12 12 0 0 1 8 76V20A12 12 0 0 1 20 8Zm28 18a22 22 0 1 0 0 44 22 22 0 0 0 0-44Z" /> </svg></div><div class="well texture texture-checker flex items-center justify-center w(240) h(136) fg-text-strong"> <svg width="80" height="80" viewBox="0 0 96 96" role="img" aria-label="A square mark with a round hole"> <path fill="currentColor" fill-rule="evenodd" d="M20 8h56a12 12 0 0 1 12 12v56a12 12 0 0 1-12 12H20A12 12 0 0 1 8 76V20A12 12 0 0 1 20 8Zm28 18a22 22 0 1 0 0 44 22 22 0 0 0 0-44Z" /> </svg></div><template> <div class="well texture texture-checker flex items-center justify-center w(240) h(136) fg-text-strong"> <svg width="80" height="80" viewBox="0 0 96 96" role="img" aria-label="A square mark with a round hole"> <path fill="currentColor" fill-rule="evenodd" d="M20 8h56a12 12 0 0 1 12 12v56a12 12 0 0 1-12 12H20A12 12 0 0 1 8 76V20A12 12 0 0 1 20 8Zm28 18a22 22 0 1 0 0 44 22 22 0 0 0 0-44Z" /> </svg> </div></template>#尺寸、粗細與顏色
可用三個自訂屬性調整個別圖樣。--texture-size 是單一圖塊的邊長,--texture-weight 是圓點半徑或線條寬度,--texture-ink 是圖樣的顏色。主題可透過 --color-texture 一次設定所有紋理的顏色。
讓紋理比上方的內容更低調。展示範例時,細而稀疏的圖樣就足以襯出範例的邊緣,太密則會分散注意力。
尺寸、粗細與顏色
<div class="auto-grid auto-grid-fit" style="--auto-grid-min: 9rem"> <figure class="m(0) flex flex-col gap-xs"> <div class="well texture h(96)" style="--texture-size: 20px"></div> <figcaption class="text-xs fg-text-muted">A 20px tile</figcaption> </figure> <figure class="m(0) flex flex-col gap-xs"> <div class="well texture texture-stripes h(96)" style="--texture-weight: 1px; --texture-size: 12px"></div> <figcaption class="text-xs fg-text-muted">A 1px stripe in a 12px tile</figcaption> </figure> <figure class="m(0) flex flex-col gap-xs"> <div class="well texture texture-grid h(96)" style="--texture-ink: var(--color-line-hair)"></div> <figcaption class="text-xs fg-text-muted">The hairline's ink</figcaption> </figure></div><div className="auto-grid auto-grid-fit" style={{ '--auto-grid-min': '9rem' } as React.CSSProperties}> <figure className="m(0) flex flex-col gap-xs"> <div className="well texture h(96)" style={{ '--texture-size': '20px' } as React.CSSProperties}></div> <figcaption className="text-xs fg-text-muted">A 20px tile</figcaption> </figure> <figure className="m(0) flex flex-col gap-xs"> <div className="well texture texture-stripes h(96)" style={{ '--texture-weight': '1px', '--texture-size': '12px' } as React.CSSProperties}></div> <figcaption className="text-xs fg-text-muted">A 1px stripe in a 12px tile</figcaption> </figure> <figure className="m(0) flex flex-col gap-xs"> <div className="well texture texture-grid h(96)" style={{ '--texture-ink': 'var(--color-line-hair)' } as React.CSSProperties}></div> <figcaption className="text-xs fg-text-muted">The hairline's ink</figcaption> </figure></div><div class="auto-grid auto-grid-fit" style="--auto-grid-min: 9rem"> <figure class="m(0) flex flex-col gap-xs"> <div class="well texture h(96)" style="--texture-size: 20px"></div> <figcaption class="text-xs fg-text-muted">A 20px tile</figcaption> </figure> <figure class="m(0) flex flex-col gap-xs"> <div class="well texture texture-stripes h(96)" style="--texture-weight: 1px; --texture-size: 12px"></div> <figcaption class="text-xs fg-text-muted">A 1px stripe in a 12px tile</figcaption> </figure> <figure class="m(0) flex flex-col gap-xs"> <div class="well texture texture-grid h(96)" style="--texture-ink: var(--color-line-hair)"></div> <figcaption class="text-xs fg-text-muted">The hairline's ink</figcaption> </figure></div><template> <div class="auto-grid auto-grid-fit" style="--auto-grid-min: 9rem"> <figure class="m(0) flex flex-col gap-xs"> <div class="well texture h(96)" style="--texture-size: 20px"></div> <figcaption class="text-xs fg-text-muted">A 20px tile</figcaption> </figure> <figure class="m(0) flex flex-col gap-xs"> <div class="well texture texture-stripes h(96)" style="--texture-weight: 1px; --texture-size: 12px"></div> <figcaption class="text-xs fg-text-muted">A 1px stripe in a 12px tile</figcaption> </figure> <figure class="m(0) flex flex-col gap-xs"> <div class="well texture texture-grid h(96)" style="--texture-ink: var(--color-line-hair)"></div> <figcaption class="text-xs fg-text-muted">The hairline's ink</figcaption> </figure> </div></template>斜紋在正方形圖塊中以 45° 傾斜,因此線條間距為圖塊邊長除以 √2。預設圖塊邊長為 8px,間距為 5.7px。請將圖塊邊長設為整數像素,以免線條在相鄰圖塊之間錯位。
圖塊從區域中央開始排列,因此無論區域大小,圖樣在相對兩側邊緣的裁切方式都相同。若要改從角落開始排列,請設定 background-position。
#淡出
texture-fade 讓圖樣往邊緣逐漸淡出,適合用在標題後方。這個遮罩也會讓元素內的內容淡出,因此請在內容後方放置獨立元素來套用遮罩,並讓輔助技術略過該元素。
淡出
<div class="relative flex flex-col items-center justify-center gap-md h(192)"> <div class="texture texture-grid texture-fade absolute inset(0)" aria-hidden="true"></div> <h3 class="relative m(0) text-xl fg-text-strong">Ship the first draft</h3> <button type="button" class="relative btn btn-primary">Start a project</button></div><div className="relative flex flex-col items-center justify-center gap-md h(192)"> <div className="texture texture-grid texture-fade absolute inset(0)" aria-hidden="true"></div> <h3 className="relative m(0) text-xl fg-text-strong">Ship the first draft</h3> <button type="button" className="relative btn btn-primary">Start a project</button></div><div class="relative flex flex-col items-center justify-center gap-md h(192)"> <div class="texture texture-grid texture-fade absolute inset(0)" aria-hidden="true"></div> <h3 class="relative m(0) text-xl fg-text-strong">Ship the first draft</h3> <button type="button" class="relative btn btn-primary">Start a project</button></div><template> <div class="relative flex flex-col items-center justify-center gap-md h(192)"> <div class="texture texture-grid texture-fade absolute inset(0)" aria-hidden="true"></div> <h3 class="relative m(0) text-xl fg-text-strong">Ship the first draft</h3> <button type="button" class="relative btn btn-primary">Start a project</button> </div></template>#疊層
紋理會取代表面原有的背景圖片,並保留元素的底色。若要同時保留另一張圖片,或用圖樣裁出形狀,請在套用紋理類別的元素上讀取 --texture-image,圖樣可透過這個屬性取得。
.texture.stage { background-image: var(--texture-image), linear-gradient(var(--color-surface-raised), var(--color-surface-raised-low)); background-size: var(--texture-size) var(--texture-size), auto;}交叉斜紋由兩層組成,因此請為兩層分別指定尺寸。
#無障礙
強制色彩模式會移除紋理圖樣,因此每種有意義的紋理都需要其他方式傳達其意義。
- 純裝飾的區域無須額外說明。若元素只用來承載紋理,請加上
aria-hidden="true"。 - 如果紋理用來表示預留、不開放或透明等狀態,請用看得見的文字說明:放在區域旁或區域內,強制色彩模式也會保留這些文字。在區域本身加上
role="img"和aria-label可以讓輔助技術讀到名稱,但畫面上看不到,因此不能取代文字。 - 無法使用的控制項應先設為
disabled。交叉斜紋只是補充呈現該屬性已表達的狀態。
#類別
| 類別 | 說明 |
|---|---|
texture | 每個圖樣單元放一個點,形成襯托展示樣本的背景 |
texture-grid | 用於標示空間尺寸的方格線搭配 texture 使用 |
texture-stripes | 用細斜線標示刻意留空的區域,例如欄間距、留白或預留的空位搭配 texture 使用 |
texture-crosshatch | 用兩個方向交叉的細斜線標示無法使用的區域,例如不可選取的時段或超出界限的範圍搭配 texture 使用 |
texture-checker | 以交錯方格作為透明內容的底紋搭配 texture 使用 |
texture-fade | 圖樣朝邊緣逐漸淡去。它也會遮罩元素內的內容,因此請套用在獨立的元素上搭配 texture 使用 |
#自訂屬性
| 屬性 | 預設值 | 說明 |
|---|---|---|
--texture-ink | var(--color-texture) | 圖樣標記的顏色。線條與方格以原色一半的不透明度繪製設定於 texture |
--texture-size | 12px | 單一圖樣方塊的邊長。圓點為 12px,格線為 24px,條紋與交叉斜線為 8px,棋盤格為 16px設定於 texture |
--texture-weight | 1px | 指定圓點半徑或線條寬度。條紋的線寬為 .5px,棋盤格無此設定。設定於 texture |
--texture-image | 圖樣本身,可放在另一張圖片下方,也可用作遮罩。交叉斜線由兩層組成設定於 texture |