Texture
Dots, a grid, stripes, a crosshatch and a checker, drawn across the face of a surface.
On this page
A texture is one drawing repeated across the face of a surface. Use .texture on any element for room that holds no content and still has to say what it is. It is a background image in one quiet ink, so it stands on whatever color the element already has: a well stays a well, with dots across it.
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>#Drawings
There are five, and each says one thing about the room it fills. Choose by that meaning, not by which looks best: a reader who meets stripes in two places should be able to assume the same thing about both.
Drawings
<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>| Class | Says | Use for |
|---|---|---|
texture | An open stage | The field a specimen, a canvas or a diagram is seen against |
texture texture-grid | Measured room | A canvas where position matters: an editor, a floor plan, a layout lesson |
texture texture-stripes | Room kept empty | A gutter, a clear space, a slot nothing fills, a placeholder for a picture |
texture texture-crosshatch | Room that cannot be used | A blocked time, a day that is closed, a range out of bounds |
texture texture-checker | Nothing at all | The ground under a transparent picture or a color with alpha |
Words never stand on a texture. The marks run through the letters and make them harder to read, so put a caption beside the textured room or on a sheet over it.
#Kept and unavailable
Stripes and a crosshatch part two kinds of empty. A striped slot is kept free and may be filled later; a crosshatched one cannot be chosen. Say the same in words, since a drawing is not read by everyone: here the closed hours are also disabled and named.
Kept and unavailable
<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>#Transparency
A checker is the ground under something that has none of its own. Put the picture on it, so the squares show where it is clear: here, through the hole in the mark.
Transparency
<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>#Size, weight and ink
Three custom properties tune a drawing where it stands. --texture-size is the side of one tile, --texture-weight the radius of a dot or the width of a rule, and --texture-ink the color of the marks. A theme sets the ink for every texture at once with --color-texture.
Keep a texture quieter than what stands on it. On a stage that holds a specimen, a sparse, fine drawing is enough for the eye to find an edge against; a dense one competes with the specimen.
Size, weight and ink
<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>Stripes turn 45° in a square tile, so they stand the tile's side over √2 apart: 5.7px in the default 8px tile. Keep the tile a whole number of pixels, or the lines drift from one tile to the next.
Tiles are counted from the middle of the room, so a drawing is cut the same way at opposite edges, whatever the room's size. Set background-position to start it from a corner instead.
#Fade
texture-fade thins the drawing out toward the edges, for a field behind a heading. It is a mask, and a mask fades what the element holds too, so put it on an element of its own behind the content and hide that element from assistive technology.
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>#Layering
A texture takes the place of the face's own image, and the element keeps its color. To keep another image as well, or to cut a shape with the drawing, read --texture-image on the element that carries the class: the drawing is published there.
.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;}A crosshatch is two layers, so give it two sizes.
#Accessibility
A texture is a drawing, and it is removed in forced colors. Never let it carry a meaning alone:
- Room that is only decorated needs nothing. An element that exists just to hold a texture takes
aria-hidden="true". - Room whose texture means something (kept free, closed, transparent) says so in words that are seen: text beside it or in it, which forced colors keep.
role="img"with anaria-labelon the room names it for assistive technology too, but nobody sees it, so it does not replace the words. - A control that cannot be used is
disabledfirst. A crosshatch only repeats what the attribute says.
#Classes
| Class | Description |
|---|---|
texture | Dots: one point a tile, the field a specimen is seen against |
texture-grid | Ruled squares, for room that is measuredApply with texture |
texture-stripes | Diagonal hairlines, for room that is kept empty: a gutter, a clear space, a slot nothing fillsApply with texture |
texture-crosshatch | Hairlines both ways, for room that cannot be used: a blocked time, a range out of boundsApply with texture |
texture-checker | Alternate squares, the ground under something transparentApply with texture |
texture-fade | The drawing thins out toward the edges. It masks what the element holds too, so it goes on an element of its ownApply with texture |
#Custom properties
| Property | Default | Description |
|---|---|---|
--texture-ink | var(--color-texture) | The color of the marks. Rules and squares are drawn at half of itSet on texture |
--texture-size | 12px | The side of one tile: 12px for dots, 24px for a grid, 8px for stripes and a crosshatch, 16px for a checkerSet on texture |
--texture-weight | 1px | The radius of a dot or the width of a rule; a stripe's is .5px. A checker has noneSet on texture |
--texture-image | The drawing itself, to lay under another image or to use as a mask. A crosshatch is two layersSet on texture |