알림 수신함은 독자가 자리를 비운 동안 일어난 일을 모은 페이지입니다. 누가 했는지 또는 무엇이었는지, 언제였는지, 읽었는지를 보여 줍니다. 읽지 않은 것만 걸러 보고, 하나 또는 전체를 읽음으로 표시할 수 있습니다. 알림은 시트 위의 목록이며, 세그먼트 컨트롤 아래에 놓입니다.
알림 수신함
<section class="sheet container-inline flex flex-col overflow-hidden max-w(640) mx-auto" data-example="notification-inbox" aria-labelledby="inbox-title"> <header class="flex flex-wrap items-center justify-between gap-sm p-md"> <div class="flex flex-col gap-3xs"> <h2 class="heading heading-sm" id="inbox-title">Notifications</h2> <p class="m(0) fg-text-muted" data-inbox-count>4 unread</p> </div> <div class="flex flex-wrap items-center gap-xs"> <div class="segmented segmented-sm" role="radiogroup" aria-label="Show"> <label class="segmented-item"> <input type="radio" class="segmented-input" name="inbox-filter" value="all" checked disabled>All</label> <label class="segmented-item"> <input type="radio" class="segmented-input" name="inbox-filter" value="unread" disabled>Unread</label> </div> <button type="button" class="btn btn-sm" data-inbox-read-all disabled>Mark all as read</button> </div> </header> <div class="px-md bt(1) bt-solid b-line-hair"> <ul class="list" aria-label="Notifications" data-inbox-list> <li class="list-row" data-unread> <span class="avatar list-media"> <img class="avatar-image" src="/demo/people/kenta-nakamura.webp" alt width="256" height="256"> </span> <div class="list-body"> <p class="list-title"> <a class="link link-quiet" href="#inbox-title">Kenta Nakamura mentioned you</a> </p> <p class="list-description">“Can you check the edge logs?”</p> </div> <p class="list-meta"> <time datetime="2026-11-13T09:31">Today, 09:31</time> <span class="badge badge-sm badge-dot" data-inbox-unread>Unread</span> </p> <span class="list-end"> <button type="button" class="btn btn-quiet btn-square btn-sm" aria-label="Mark “Kenta Nakamura mentioned you” as read" data-inbox-read disabled> <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M3 8L6.3532 11.3532A0.2 0.2 0 0 0 6.6412 11.3479L13 4.5" /> </svg> </button> </span> </li> <li class="list-row" data-unread> <span class="icon-frame icon-frame-xs list-media" aria-hidden="true"> <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M8.8742 3.8235L13.4246 12.0144A1 1 0 0 1 12.5505 13.5L3.4495 13.5A1 1 0 0 1 2.5754 12.0144L7.1258 3.8235A1 1 0 0 1 8.8742 3.8235Z" /> <path d="M8 6.5L8 9" /> <circle cx="8" cy="11.5" r="0.5" fill="currentColor" stroke="none" /> </svg> </span> <div class="list-body"> <p class="list-title"> <a class="link link-quiet" href="#inbox-title">Deployment failed on atlas.dev</a> </p> <p class="list-description">The install step failed.</p> </div> <p class="list-meta"> <time datetime="2026-11-13T09:12">Today, 09:12</time> <span class="badge badge-sm badge-dot" data-inbox-unread>Unread</span> </p> <span class="list-end"> <button type="button" class="btn btn-quiet btn-square btn-sm" aria-label="Mark “Deployment failed on atlas.dev” as read" data-inbox-read disabled> <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M3 8L6.3532 11.3532A0.2 0.2 0 0 0 6.6412 11.3479L13 4.5" /> </svg> </button> </span> </li> <li class="list-row" data-unread> <span class="avatar list-media"> <img class="avatar-image" src="/demo/people/misaki-sato.webp" alt width="256" height="256"> </span> <div class="list-body"> <p class="list-title"> <a class="link link-quiet" href="#inbox-title">Misaki Sato left a comment</a> </p> <p class="list-description">“The hero reads much better.”</p> </div> <p class="list-meta"> <time datetime="2026-11-12T17:40">Yesterday, 17:40</time> <span class="badge badge-sm badge-dot" data-inbox-unread>Unread</span> </p> <span class="list-end"> <button type="button" class="btn btn-quiet btn-square btn-sm" aria-label="Mark “Misaki Sato left a comment” as read" data-inbox-read disabled> <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M3 8L6.3532 11.3532A0.2 0.2 0 0 0 6.6412 11.3479L13 4.5" /> </svg> </button> </span> </li> <li class="list-row" data-unread> <span class="icon-frame icon-frame-xs list-media" aria-hidden="true"> <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <circle cx="8" cy="8" r="6" /> <path d="M8 4.3333L8 7.8892A0.2 0.2 0 0 0 8.094 8.0588L10.6667 9.6667" /> </svg> </span> <div class="list-body"> <p class="list-title"> <a class="link link-quiet" href="#inbox-title">Build minutes are at 62%</a> </p> <p class="list-description">760 minutes are left.</p> </div> <p class="list-meta"> <time datetime="2026-11-12T08:00">Yesterday, 08:00</time> <span class="badge badge-sm badge-dot" data-inbox-unread>Unread</span> </p> <span class="list-end"> <button type="button" class="btn btn-quiet btn-square btn-sm" aria-label="Mark “Build minutes are at 62%” as read" data-inbox-read disabled> <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M3 8L6.3532 11.3532A0.2 0.2 0 0 0 6.6412 11.3479L13 4.5" /> </svg> </button> </span> </li> <li class="list-row"> <span class="avatar list-media"> <img class="avatar-image" src="/demo/people/pohan-chen.webp" alt width="256" height="256"> </span> <div class="list-body"> <p class="list-title"> <a class="link link-quiet" href="#inbox-title">Po-han Chen invited you to Borealis</a> </p> <p class="list-description">You joined as a member.</p> </div> <p class="list-meta"> <time datetime="2026-11-11T14:05">11 November</time> </p> </li> <li class="list-row"> <span class="icon-frame icon-frame-xs list-media" aria-hidden="true"> <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M4.4667 2L11.5333 2A0.8 0.8 0 0 1 12.3333 2.8L12.3333 12.7907A0.7018 0.7018 0 0 1 11.2833 13.4L10.4293 12.912A0.8 0.8 0 0 0 9.5886 12.9409L8.4438 13.7042A0.8 0.8 0 0 1 7.5562 13.7042L6.4114 12.9409A0.8 0.8 0 0 0 5.5707 12.912L4.7167 13.4A0.7018 0.7018 0 0 1 3.6667 12.7907L3.6667 2.8A0.8 0.8 0 0 1 4.4667 2Z" /> <path d="M6 5.3333L10 5.3333" /> <path d="M6 8.3333L10 8.3333" /> </svg> </span> <div class="list-body"> <p class="list-title"> <a class="link link-quiet" href="#inbox-title">Invoice INV-2026-011 was paid</a> </p> <p class="list-description">$100.00 for November.</p> </div> <p class="list-meta"> <time datetime="2026-11-01T00:00">1 November</time> </p> </li> </ul> <div data-inbox-empty hidden> <div class="empty"> <span class="icon-frame empty-media" aria-hidden="true"> <svg class="icon" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M3.5 10L7.8545 14.3545A0.2 0.2 0 0 0 8.1413 14.3504L16.5 5.5" /> </svg> </span> <h3 class="empty-title">You have read everything</h3> <p class="empty-description">Nothing is unread. What arrives next is listed here first.</p> <div class="empty-actions"> <button type="button" class="btn btn-sm" data-inbox-show-all>Show all notifications</button> </div> </div> </div> </div> <p class="sr-only" role="status" data-inbox-status></p></section>/** * An inbox of notifications on the page. The rows are markup the server wrote, so the list reads in full * without this script; the script reads which rows are unread into one list of its own and draws everything * from it: the rows that show, the count, whether "Mark all as read" can be pressed and the empty result. * Marking a row read is kept for this visit only: saving it, and anything arriving, is the application's. * Returns the function that stops it and puts every row back as it was. */export function mount(root) { const controller = new AbortController() const { signal } = controller const list = root.querySelector('[data-inbox-list]') const empty = root.querySelector('[data-inbox-empty]') const count = root.querySelector('[data-inbox-count]') const status = root.querySelector('[data-inbox-status]') const readAll = root.querySelector('[data-inbox-read-all]') const filters = [...root.querySelectorAll('[name="inbox-filter"]')] /** The one state: every notification, whether it is unread, and a copy of its row as it arrived. */ const items = [...list.children].map(row => ({ row, arrived: row.cloneNode(true), title: row.querySelector('.list-title').textContent.trim(), unread: row.hasAttribute('data-unread'), })) let filter = 'all' const unread = () => items.filter(item => item.unread).length const shown = () => items.filter(item => filter === 'all' || item.unread) const left = () => unread() ? `${unread()} unread.` : 'Nothing is unread.' const say = (message) => { status.textContent = message } const current = () => filters.find(input => input.checked) /** Draws the inbox from the state. A row that has been read loses its badge and its button for good. */ function render() { for (const { row, unread } of items) { if (unread) continue row.removeAttribute('data-unread') row.querySelector('[data-inbox-unread]')?.remove() row.querySelector('.list-end')?.remove() } const rows = shown().map(item => item.row) list.replaceChildren(...rows) empty.hidden = rows.length > 0 count.textContent = unread() ? `${unread()} unread` : 'All read' readAll.disabled = !unread() } function read(item) { // Focus goes to the next unread notification, then to the one before, then to the filter. const rows = [...list.children] const here = rows.indexOf(item.row) const others = rows.filter(row => row !== item.row && row.querySelector('[data-inbox-read]')) const next = others.find(row => rows.indexOf(row) > here) ?? others.findLast(row => rows.indexOf(row) < here) item.unread = false render() say(`“${item.title}” marked as read. ${left()}`) ;(next?.querySelector('[data-inbox-read]') ?? current()).focus() } list.addEventListener('click', (event) => { const button = event.target.closest('[data-inbox-read]') const item = button && items.find(item => item.row === button.closest('.list-row')) if (item) read(item) }, { signal }) readAll.addEventListener('click', () => { for (const item of items) item.unread = false // The button is disabled once nothing is unread, so focus leaves it first. current().focus() render() say('All notifications marked as read.') }, { signal }) /** Every way of changing the filter draws and says the same thing. */ function show(value) { filter = value render() const total = shown().length say(filter === 'unread' ? left() : `${total} ${total === 1 ? 'notification' : 'notifications'}. ${left()}`) } root.addEventListener('change', (event) => { if (event.target.name === 'inbox-filter') show(event.target.value) }, { signal }) root.querySelector('[data-inbox-show-all]').addEventListener('click', () => { filters[0].checked = true show('all') filters[0].focus() }, { signal }) const controls = [...filters, readAll, ...root.querySelectorAll('[data-inbox-read]')] for (const control of controls) control.disabled = false render() return () => { controller.abort() filters[0].checked = true list.replaceChildren(...items.map(item => item.arrived)) empty.hidden = true count.textContent = `${items.filter(item => item.arrived.hasAttribute('data-unread')).length} unread` readAll.disabled = true for (const input of filters) input.disabled = true say('') }}“Unread”(읽지 않음)로 전환하고, 체크 표시로 알림 하나를 읽음으로 표시한 다음, 나머지도 표시해 보세요. 읽음 상태는 이 미리보기에서만 유지됩니다.
블록은 복사해 사용하는 마크업입니다. 페이지의 텍스트 색상과 크기를 따르며, 미리보기에서는 body에 fg-text-body text-sm 클래스를 설정합니다. 각 블록은 크기 컨테이너이므로 넓은 페이지, 사이드바 너비의 공간, 대화 상자 어디서든 자체 너비에 맞춰 배치가 바뀝니다.
#구성 요소
- 읽기 너비의 시트 하나,
max-w(640)입니다. 제목, 개수, 컨트롤을 담은 헤더와 그 뒤의 목록으로 구성됩니다. 블록이 좁으면 컨트롤이 제목 아래로 줄바꿈됩니다. - 개수는 제목 아래의 글입니다. “4 unread”(읽지 않음 4개)처럼 씁니다. 행에 보이는 것과 같은 숫자입니다. 둘 다 하나의 상태에서 그리기 때문입니다.
- “All”(전체) 또는 “Unread”는 네이티브 라디오 두 개로 이루어진
segmented입니다. 필터는 몇 가지 중 하나를 고르는 선택이며, 라디오 그룹이 바로 그것입니다. 브라우저가 화살표 키와 선택 상태를 그대로 처리하고, 선택되지 않은 것이 “선택됨”으로 안내되는 일도 없습니다. - 각 알림은
list-row입니다. 누가 또는 무엇이 했는지를list-media로, 대상 자체로 가는 링크인 제목, 세부 내용 한 줄, 그 아래에 도착한 시각을 둡니다. 사람은 아바타이고 시스템은 아이콘 프레임이므로, 실패한 배포가 사람의 얼굴을 빌리지 않습니다. - 읽지 않음은 단어입니다. 점이 있는 중립 배지가 시각 옆에서 “Unread”라고 알려 줍니다.
aria-current도aria-selected도 아닙니다. 어느 쪽도 “아직 읽지 않음”을 뜻하지 않으며, 행은 새롭다는 이유로 선택되는 것이 아닙니다. - 읽지 않은 행 끝의 차분한 버튼 하나가 그 행을 읽음으로 표시합니다. 버튼 이름에는 행의 제목이 들어갑니다. “Mark “Deployment failed on atlas.dev” as read”(“Deployment failed on atlas.dev” 읽음으로 표시)처럼 씁니다. 읽은 행에는 버튼도 배지도 없습니다.
- “Mark all as read”(모두 읽음으로 표시)는 행이 아니라 필터와 함께 놓이며, 읽지 않은 것이 없는 동안에는 비활성화됩니다.
- 읽지 않은 것이 없다는 것은 아무것도 없다는 것과 다릅니다. “Unread” 필터에 행이 하나도 남지 않으면 빈 상태가 “You have read everything”(모두 읽었습니다)이라고 알리고 전체 알림으로 돌아가는 길을 제공합니다. 알림을 한 번도 받은 적 없는 수신함은 다른 문구가 필요한 다른 상태입니다.
제목과 세부 내용은 각각 한 줄을 유지하고 말줄임표로 끝납니다. 알림은 대상을 가리키는 포인터이고, 나머지는 대상이 담고 있습니다.
#스크립트가 필요한 동작
행은 마크업에 있으므로 수신함은 스크립트 없이도 전체 내용을 읽을 수 있습니다. 컨트롤은 마크업에서 disabled이고 스크립트가 켭니다. 그런 다음 main.js는 목록 하나를 유지합니다. 모든 알림과 각각 읽지 않았는지 여부를 담으며, 행에서 한 번 읽어 들입니다. 모든 것은 이 목록에서 그립니다.
- 필터는 모든 행 또는 읽지 않은 행을 보여 줍니다. 개수, 행, 빈 결과는 서로 어긋날 수 없습니다. 어느 것도 따로 보관하지 않기 때문입니다.
- 하나를 읽음으로 표시하면 그 행에서 배지와 버튼이 빠집니다. “Unread”에서는 행도 목록에서 빠집니다.
- 포커스가 따라갑니다. 행을 읽음으로 표시하면 포커스가 다음 읽지 않은 행의 버튼으로, 없으면 그 앞 행의 버튼으로, 하나도 남지 않으면 필터로 이동합니다. “Mark all as read”는 비활성화되기 전에 포커스를 필터에 넘깁니다.
- 화면에 그리지 않는 polite 상태 줄 하나가 결과와 남은 개수를 알립니다. ““Kenta Nakamura mentioned you” marked as read. 3 unread.”(“Kenta Nakamura mentioned you” 읽음으로 표시됨. 읽지 않음 3개.)처럼 알립니다.
읽음 상태는 방문하는 동안에만 유지됩니다. 애플리케이션에서는 같은 함수가 변경 내용을 서버로 보내고, 실패하면 행을 읽지 않음으로 되돌립니다. 새 알림은 목록에 추가되고 같은 방식으로 셉니다. 블록은 페이지 안에 머뭅니다. 종 아이콘 아래의 팝오버가 아니며, 푸시 알림도 보내지 않습니다.
#접근성
- 블록은
<h2>로 이름을 지정한<section>이며, 목록은 “Notifications”(알림)라는 이름의<ul>입니다. - 필터는 “Show”(표시)라는 이름의
radiogroup입니다. Tab 키는 선택된 옵션에 닿고, 화살표 키가 선택을 옮깁니다. - 각 행에는 클릭 영역이 두 개 있고, 각각 무엇을 하는지 알려 줍니다. 제목은 대상으로 이동하고, 버튼은 행을 읽음으로 표시합니다. 버튼의 체크 표시는 장식이며, 이름은
aria-label에 있습니다. - 이름 옆의 인물 사진은
alt를 비워 두고, 아이콘 프레임에는aria-hidden을 지정합니다. 누가 또는 무엇이 했는지는 제목이 이미 알려 줍니다. - 시각은
datetime을 지정한<time>입니다. “Today, 09:31”(오늘, 09:31)은 독자를 위한 것이고, 속성은 그 밖의 모든 것을 위한 것입니다. - 상태 줄은
role="status"이므로 결과가 포커스를 옮기지 않고 안내되며, 행이 빠져도 포커스가 페이지 맨 위로 돌아가는 일이 없습니다. - 터치 화면에서 32px 버튼은 크기를 유지하고 터치 영역이 44px로 커집니다.
#관련 항목
- 표면모든 컴포넌트의 바탕이 되는 트레이, 볼록한 표면, 오목한 영역의 높이 체계입니다.
- 세그먼트 컨트롤하나의 오목한 영역에 몇 가지 옵션을 배치하고, 솟아오른 표면이 현재 옵션으로 부드럽게 이동합니다.
- 목록이미지나 아이콘, 텍스트, 끝에 놓이는 요소로 구성된 행을 나열합니다.
- 아바타사람이나 팀을 사진 또는 이니셜로 나타내며, 하나만 표시하거나 여러 개를 겹쳐 표시할 수 있습니다.
- 아이콘 프레임제목 옆에 아이콘을 크기에 맞게 담는 작은 오목한 영역입니다.
- 배지상태, 카테고리 또는 개수를 표시하는 작은 칩입니다. 색에 의미가 있을 때만 색을 사용합니다.
- 빈 상태뷰에 아직 표시할 내용이 없을 때 나타나는 상태입니다.
- 버튼표면 위로 살짝 돌출되어 있으며, 포인터를 올리면 떠오르고 누르면 가라앉는 버튼입니다.
- 링크문장 속에서 주변 텍스트와 같은 색으로 표시되며 다른 위치로 이동하는 텍스트입니다.
- 제목페이지의 기본 글자색으로 표시하는 제목과 제목 위 안내 문구, 아래 소개 문단입니다.