탐색

v2.1.0
미디어

기기

스크린샷, 동영상 또는 실행 중인 데모를 감싸는 휴대전화 본체입니다.

이 페이지의 내용

기기 컴포넌트는 스크린샷, 동영상 또는 실행 중인 데모를 감싸는 휴대전화 본체입니다. 점토로 빚은 모형처럼 살짝 떠 있는 판 형태의 본체, 좁은 베젤, 화면 상단의 카메라 자리에 있는 작은 오목한 영역을 모두 같은 재질로 표현합니다. 데스크톱용 창과 마찬가지로, 프레임은 휴대전화임을 알아볼 수 있게 하고 화면 색상은 표시되는 콘텐츠에 맡깁니다.

기기

<div class="device" style="--device-width: 13.5rem">  <img class="device-screen" src="/demo/moonstone.svg" alt="A pale stone over grey hills"></div>
<div className="device" style={{ '--device-width': '13.5rem' } as React.CSSProperties}>  <img className="device-screen" src="/demo/moonstone.svg" alt="A pale stone over grey hills" /></div>
<div class="device" style="--device-width: 13.5rem">  <img class="device-screen" src="/demo/moonstone.svg" alt="A pale stone over grey hills"></div>
<template>  <div class="device" style="--device-width: 13.5rem">    <img class="device-screen" src="/demo/moonstone.svg" alt="A pale stone over grey hills">  </div></template>

#화면

화면에 표시할 <img>, <video>, <iframe> 또는 마크업 블록에 device-screen 클래스를 적용하세요. 콘텐츠는 베젤 안쪽을 가득 채우며, 이미지는 화면 영역에 맞춰 잘립니다. 화면 모서리의 반지름은 본체 모서리의 반지름에서 베젤 두께를 뺀 값이므로 모서리 곡선을 따라 간격이 일정합니다.

마크업으로 만든 화면의 콘텐츠는 카메라의 오목한 영역 아래에서 시작합니다. 실제 상태 표시줄처럼 상단에 본체 너비의 약 6분의 1만큼 여백을 두세요.

마크업으로 만든 화면

<div class="device" style="--device-width: 13.5rem">  <div class="device-screen bg-surface-base flex flex-col gap-sm px(14) pt(44) pb(14)">    <p class="eyebrow">Wednesday</p>    <p class="heading heading-lg">Today</p>    <ul class="checklist mt(4)">      <li class="checklist-item">        <label class="checklist-label">          <input class="checkbox" type="checkbox" checked><span class="checklist-title">Review the contract</span>        </label>      </li>      <li class="checklist-item">        <label class="checklist-label">          <input class="checkbox" type="checkbox"><span class="checklist-title">Call Grace at three</span>        </label>      </li>      <li class="checklist-item">        <label class="checklist-label">          <input class="checkbox" type="checkbox"><span class="checklist-title">Book the flight</span>        </label>      </li>    </ul>  </div></div>
<div className="device" style={{ '--device-width': '13.5rem' } as React.CSSProperties}>  <div className="device-screen bg-surface-base flex flex-col gap-sm px(14) pt(44) pb(14)">    <p className="eyebrow">Wednesday</p>    <p className="heading heading-lg">Today</p>    <ul className="checklist mt(4)">      <li className="checklist-item">        <label className="checklist-label">          <input className="checkbox" type="checkbox" defaultChecked /><span className="checklist-title">Review the contract</span>        </label>      </li>      <li className="checklist-item">        <label className="checklist-label">          <input className="checkbox" type="checkbox" /><span className="checklist-title">Call Grace at three</span>        </label>      </li>      <li className="checklist-item">        <label className="checklist-label">          <input className="checkbox" type="checkbox" /><span className="checklist-title">Book the flight</span>        </label>      </li>    </ul>  </div></div>
<div class="device" style="--device-width: 13.5rem">  <div class="device-screen bg-surface-base flex flex-col gap-sm px(14) pt(44) pb(14)">    <p class="eyebrow">Wednesday</p>    <p class="heading heading-lg">Today</p>    <ul class="checklist mt(4)">      <li class="checklist-item">        <label class="checklist-label">          <input class="checkbox" type="checkbox" checked><span class="checklist-title">Review the contract</span>        </label>      </li>      <li class="checklist-item">        <label class="checklist-label">          <input class="checkbox" type="checkbox"><span class="checklist-title">Call Grace at three</span>        </label>      </li>      <li class="checklist-item">        <label class="checklist-label">          <input class="checkbox" type="checkbox"><span class="checklist-title">Book the flight</span>        </label>      </li>    </ul>  </div></div>
<template>  <div class="device" style="--device-width: 13.5rem">    <div class="device-screen bg-surface-base flex flex-col gap-sm px(14) pt(44) pb(14)">      <p class="eyebrow">Wednesday</p>      <p class="heading heading-lg">Today</p>      <ul class="checklist mt(4)">        <li class="checklist-item">          <label class="checklist-label">            <input class="checkbox" type="checkbox" checked><span class="checklist-title">Review the contract</span>          </label>        </li>        <li class="checklist-item">          <label class="checklist-label">            <input class="checkbox" type="checkbox"><span class="checklist-title">Call Grace at three</span>          </label>        </li>        <li class="checklist-item">          <label class="checklist-label">            <input class="checkbox" type="checkbox"><span class="checklist-title">Book the flight</span>          </label>        </li>      </ul>    </div>  </div></template>

#크기

본체의 너비는 280px이고 가로세로 비율은 9:19.5입니다. 너비를 직접 지정하는 대신 --device-width로 크기를 조절하세요. 모서리 반지름은 이 속성 값의 14%, 베젤 두께는 3%이므로 크기를 바꿔도 휴대전화의 형태가 유지됩니다. 구형 휴대전화나 소형 태블릿을 표현하려면 --device-ratio로 비율을 바꾸세요. 측면 버튼은 본체에서 2px 돌출되며, 요소가 양쪽으로 2px씩 더 넓어 버튼까지 포함합니다. 따라서 스크롤 영역 가장자리에 기기를 배치해도 스크롤 범위가 늘어나지 않습니다.

기기 크기

<div class="device" style="--device-width: 7rem">  <img class="device-screen" src="/demo/moonstone.svg" alt></div><div class="device" style="--device-width: 9rem">  <img class="device-screen" src="/demo/moonstone.svg" alt></div><div class="device" style="--device-width: 11rem; --device-ratio: 3 / 4">  <img class="device-screen" src="/demo/moonstone.svg" alt></div>
<>  <div className="device" style={{ '--device-width': '7rem' } as React.CSSProperties}>    <img className="device-screen" src="/demo/moonstone.svg" alt="" />  </div>  <div className="device" style={{ '--device-width': '9rem' } as React.CSSProperties}>    <img className="device-screen" src="/demo/moonstone.svg" alt="" />  </div>  <div className="device" style={{ '--device-width': '11rem', '--device-ratio': '3 / 4' } as React.CSSProperties}>    <img className="device-screen" src="/demo/moonstone.svg" alt="" />  </div></>
<div class="device" style="--device-width: 7rem">  <img class="device-screen" src="/demo/moonstone.svg" alt></div><div class="device" style="--device-width: 9rem">  <img class="device-screen" src="/demo/moonstone.svg" alt></div><div class="device" style="--device-width: 11rem; --device-ratio: 3 / 4">  <img class="device-screen" src="/demo/moonstone.svg" alt></div>
<template>  <div class="device" style="--device-width: 7rem">    <img class="device-screen" src="/demo/moonstone.svg" alt>  </div>  <div class="device" style="--device-width: 9rem">    <img class="device-screen" src="/demo/moonstone.svg" alt>  </div>  <div class="device" style="--device-width: 11rem; --device-ratio: 3 / 4">    <img class="device-screen" src="/demo/moonstone.svg" alt>  </div></template>

#접근성

  • 프레임은 장식용이므로 스크린 리더가 읽지 않습니다. 화면의 의미를 전달하려면 이미지에 인터페이스가 무엇을 보여 주는지 설명하는 alt를 지정하세요. 옆의 텍스트에 이미 같은 설명이 있다면 빈 alt를 지정하세요.
  • 화면 안에서 실행되는 데모는 그 자체로 작은 웹페이지입니다. 조작 대상은 터치하기에 충분한 크기로 유지하고, 데모를 키보드로 조작할 수 있게 하거나 키보드 탐색에서 제외하세요.
  • 강제 색상 모드에서는 본체와 카메라의 오목한 영역에 시스템 윤곽선이 표시됩니다.
  • 화면 안에서 자동으로 재생되는 녹화는 소리 없이 재생하세요. 소리나 단계로 내용을 전달하는 녹화에는 자막이나 텍스트 설명도 필요합니다.

#클래스

클래스설명
device본체는 너비 280px, 가로세로 비율 9:19.5의 떠 있는 표면이며, 좁은 베젤과 카메라가 들어가는 홈, 측면 버튼이 있습니다. 버튼은 본체에서 2px 돌출되지만 요소 자체의 상자 안에 들어가므로 상자 밖에는 아무것도 그려지지 않습니다.
device-screen이미지, 동영상, 프레임 또는 마크업 블록에 적용하는 화면 영역입니다. 베젤 안쪽 본체를 채우며, 화면과 본체의 둥근 모서리는 같은 중심점을 공유합니다

#사용자 지정 속성

속성기본값설명
--device-width17.5rem본체의 너비입니다. 모서리 반지름과 베젤 두께는 이 너비를 기준으로 정합니다.
--device-ratio9 / 19.5본체의 가로세로 비율
--device-radiuscalc(var(--device-width) * .14)본체 모서리의 원형 반지름
--device-bezelcalc(var(--device-width) * .03)화면을 둘러싼 프레임의 너비입니다.

#소스

@master/ui/components/device.css
/* * Device: the body of a phone around a screenshot, a video or a running demo. * It is drawn in one material, like a model cast in clay: a lifted sheet for the body, a narrow bezel, and * a small well at the top of the screen where the camera would be. The frame says "this is a phone" and * leaves every color to what it shows, as a window does. * Everything is measured from the body's width: the corner is 14% of it, the bezel 3% and the screen's own * corner is the body's minus the bezel, so the gap keeps one width around the bend. The body is 280px wide * and 9 by 19.5; set --device-width to resize it, not a width, so the corners follow. * The side buttons stand 2px proud of the body, and the element is that much wider than the body on each * side to hold them: nothing is drawn outside its box, so a device at the edge of a scroller adds no scroll. */@layer components.ui {  .device {    --device-width: 17.5rem;    --device-ratio: 9 / 19.5;    --device-radius: calc(var(--device-width) * .14);    --device-bezel: calc(var(--device-width) * .03);    --device-button: 2px;    --surface-color: var(--color-surface-raised);    position: relative;    display: block;    flex: none;    box-sizing: border-box;    /* The body and the camera's well are layers of the device, and no further back or forward than that. */    isolation: isolate;    width: calc(var(--device-width) + var(--device-button) * 2);    height: calc(var(--device-width) / (var(--device-ratio)));    margin: 0;    padding: var(--device-bezel) calc(var(--device-bezel) + var(--device-button));    /* The buttons: three on one side and one on the other, as thin slips the body covers all but 2px of. */    background:      linear-gradient(var(--color-line-strong) 0 0) 0 17% / 50% 4% no-repeat,      linear-gradient(var(--color-line-strong) 0 0) 0 26% / 50% 8% no-repeat,      linear-gradient(var(--color-line-strong) 0 0) 0 37% / 50% 8% no-repeat,      linear-gradient(var(--color-line-strong) 0 0) 100% 31% / 50% 13% no-repeat;    /* The body: a lifted sheet behind the screen. A hairline inside its edge turns the sheet into a frame with a rim. */    &::before {      content: '';      position: absolute;      z-index: -1;      inset: 0 var(--device-button);      border-radius: calc(var(--device-radius) * var(--corner-scale));      corner-shape: var(--corner-shape);      @apply --surface-sheet;      box-shadow: inset 0 0 0 1px var(--color-line-hair), var(--shadow-lifted);      pointer-events: none;    }    /* The camera's well: a pill a third of the screen wide, a little below its top edge. */    &::after {      content: '';      position: absolute;      z-index: 1;      top: calc(var(--device-bezel) + var(--device-width) * .03);      left: 50%;      width: calc(var(--device-width) * .3);      aspect-ratio: 3.4;      border-radius: 999px;      corner-shape: round;      background: var(--color-surface-raised-low);      box-shadow: var(--shadow-pressed);      translate: -50% 0;      pointer-events: none;    }    @media (forced-colors: active) {      background: none;      &::before, &::after {        outline: 1px solid CanvasText;        outline-offset: -1px;      }    }  }  /* The screen: a picture, a video, a frame or a block of markup, finished by a corner concentric with the body's. */  .device-screen {    display: block;    box-sizing: border-box;    width: 100%;    height: 100%;    margin: 0;    border: 0;    border-radius: calc(var(--device-radius) * var(--corner-scale) - var(--device-bezel));    corner-shape: var(--corner-shape);    overflow: clip;    background: var(--color-surface-inset);    outline: 1px solid var(--color-line-image-strong);    outline-offset: -1px;    object-fit: cover;    @media (forced-colors: active) {      outline-color: CanvasText;    }  }}