본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

아코디언

원문 보기 위키 갱신

아코디언 (Accordion)

아코디언(accordion) 컴포넌트는 사용자가 페이지에서 관련 콘텐츠의 섹션을 보여주고 숨길 수 있게 해줘요.

출처: 문서

본문

<div class="govuk-accordion" data-module="govuk-accordion" id="accordion-default">
  <div class="govuk-accordion__section">
    <div class="govuk-accordion__section-header">
      <h2 class="govuk-accordion__section-heading">
        <span class="govuk-accordion__section-button" id="accordion-default-heading-1">
          Writing well for the web
        </span>
      </h2>
    </div>
    <div id="accordion-default-content-1" class="govuk-accordion__section-content">
      <p class="govuk-body">This is the content for Writing well for the web.</p>
    </div>
  </div>
  <div class="govuk-accordion__section">
    <div class="govuk-accordion__section-header">
      <h2 class="govuk-accordion__section-heading">
        <span class="govuk-accordion__section-button" id="accordion-default-heading-2">
          Writing well for specialists
        </span>
      </h2>
    </div>
    <div id="accordion-default-content-2" class="govuk-accordion__section-content">
      <p class="govuk-body">This is the content for Writing well for specialists.</p>
    </div>
  </div>
  <div class="govuk-accordion__section">
    <div class="govuk-accordion__section-header">
      <h2 class="govuk-accordion__section-heading">
        <span class="govuk-accordion__section-button" id="accordion-default-heading-3">
          Know your audience
        </span>
      </h2>
    </div>
    <div id="accordion-default-content-3" class="govuk-accordion__section-content">
      <p class="govuk-body">This is the content for Know your audience.</p>
    </div>
  </div>
  <div class="govuk-accordion__section">
    <div class="govuk-accordion__section-header">
      <h2 class="govuk-accordion__section-heading">
        <span class="govuk-accordion__section-button" id="accordion-default-heading-4">
          How people read
        </span>
      </h2>
    </div>
    <div id="accordion-default-content-4" class="govuk-accordion__section-content">
      <p class="govuk-body">This is the content for How people read.</p>
    </div>
  </div>
</div>
{% from "govuk/components/accordion/macro.njk" import govukAccordion %}

{{ govukAccordion({
  id: "accordion-default",
  items: [
    {
      heading: {
        text: "Writing well for the web"
      },
      content: {
        html: '<p class="govuk-body">This is the content for Writing well for the web.</p>'
      }
    },
    {
      heading: {
        text: "Writing well for specialists"
      },
      content: {
        html: '<p class="govuk-body">This is the content for Writing well for specialists.</p>'
      }
    },
    {
      heading: {
        text: "Know your audience"
      },
      content: {
        html: '<p class="govuk-body">This is the content for Know your audience.</p>'
      }
    },
    {
      heading: {
        text: "How people read"
      },
      content: {
        html: '<p class="govuk-body">This is the content for How people read.</p>'
      }
    }
  ]
}) }}

이 컴포넌트를 언제 사용하나요

아코디언은 사용자에게 다음과 같은 점이 유용하다는 증거가 있을 때만 사용하세요:

  • 여러 관련 콘텐츠 섹션의 개요를 볼 수 있는 것

  • 자신과 관련된 섹션을 보여주고 숨길 수 있는 것

  • 그렇지 않으면 서로 다른 페이지에 있을 수 있는 정보를 살펴보는 것

예를 들어, 사용자가 자신과 관련된 정보를 펼쳐서 비교해야 할 때 아코디언이 잘 작동할 수 있어요.

아코디언은 서비스를 자주 사용하는 사람들에게도 잘 작동할 수 있어요. 예를 들어, 익숙한 작업을 빠르게 처리해야 하는 케이스워킹(caseworking) 시스템 사용자에게 말이죠.

사용자와 테스트해서 아코디언을 사용하는 것이 콘텐츠를 숨길 때의 잠재적 문제보다 나은지 결정하세요.

이 컴포넌트를 언제 사용하지 않나요

아코디언은 사용자로부터 콘텐츠를 숨겨요. 모든 사용자가 그것을 알아차리거나 작동 방식을 이해하지는 못해요. 그런 이유로, 특정 상황에서 그리고 사용자 리서치가 뒷받침할 때만 사용해야 해요.

모든 사용자가 봐야 하는 콘텐츠에는 아코디언을 사용하지 마세요.

먼저 아코디언 없이 콘텐츠를 테스트해 보세요. GOV.UK 작성 표준에 나와 있는 것처럼 잘 쓰여지고 잘 구조화된 콘텐츠는 아코디언을 사용할 필요를 없앨 수 있어요.

보통 다음 방법이 더 좋아요:

  • 콘텐츠의 양을 단순화하고 줄이기

  • 콘텐츠를 여러 페이지로 나누기

  • 콘텐츠를 하나의 페이지에 두고 제목으로 구분하기

  • 페이지 시작 부분에 링크 목록(이른바 '앵커 링크'라고도 해요)을 사용해 사용자를 페이지의 특정 섹션으로 데려가기

아코디언은 단순한 콘텐츠와 링크에 가장 잘 작동해요. 일련의 질문을 나누는 데 아코디언을 사용하지 마세요. 대신 별도의 페이지를 사용하세요.

아코디언 안에 아코디언을 넣지 마세요. 콘텐츠를 찾기 어렵게 만들 테니까요.

내부 콘텐츠 양 때문에 페이지 로딩이 느려질 경우 아코디언 컴포넌트를 사용하지 마세요.

아코디언, 탭, 디테일 사이에서 결정하기

아코디언(Accordion) 컴포넌트, 탭(Tabs) 컴포넌트, 디테일(Details) 컴포넌트는 모두 사용자가 선택해서 나타내는 콘텐츠의 섹션을 숨기는 방식으로 작동해요. 이 컴포넌트들을 서로 안에 넣어 사용하는 것은 피하세요.

이 중 하나를 사용하기로 결정했다면, 다음을 고려해 보세요:

  • 사용자가 한 번에 둘 이상의 섹션을 봐야 하는 경우 – 아코디언은 탭과 달리 여러 섹션을 동시에 보여줄 수 있어요

  • 사용자가 섹션 사이를 빠르게 전환해야 하는 경우 – 탭은 아코디언과 달리 다른 섹션을 페이지 아래로 밀어내지 않고 콘텐츠를 보여줄 수 있어요

  • 콘텐츠 섹션이 많은 경우 – 아코디언은 수직으로 배치되어 탭이 수평으로 배치된 것과 달리 더 많은 섹션을 수용할 수 있어요

  • 짧고 덜 중요한 콘텐츠가 한두 조각뿐인 경우 – 디테일 컴포넌트가 시각적으로 더 작고 아코디언이나 탭보다 덜 눈에 띄기 때문에 더 적합해요

어떻게 작동하나요

아코디언 컴포넌트를 사용하는 방법은 2가지예요. HTML을 사용하거나, Nunjucks나 GOV.UK Prototype Kit을 사용한다면 Nunjucks 매크로를 사용할 수 있어요.

아코디언 컴포넌트는 JavaScript를 사용해요. JavaScript를 사용할 수 없을 때는, 사용자가 섹션 라벨을 제목으로 하여 모든 콘텐츠가 표시된 것을 보게 돼요.

HTML을 사용한다면 govuk-accordion 클래스를 가진 `` 태그에 'id' 속성을 추가해야 해요. 아코디언의 지속된 펼침 상태를 유지하려면 이 id는 서비스 도메인 전체에서 고유해야 해요.

섹션 제목 버튼

아코디언은 보통 모든 섹션이 숨겨진 상태로 시작해요. 섹션을 보여주려면, 사용자가 제목 버튼의 아무 곳이나 상호작용할 수 있어요.

제목 버튼에는 다음 영역이 모두 포함돼요:

  • 제목 텍스트

  • 요약 줄(추가하기로 결정한 경우)

  • 'show' 또는 'hide'라는 행동 유도(call-to-action) 텍스트

스크린 리더 사용자의 경우, 버튼의 모든 텍스트가 하나의 문장으로 읽혀요(약간의 호흡을 위해 쉼표로 구분). 또한 행동 유도를 '이 섹션 보여주기(show this section)'나 '이 섹션 숨기기(hide this section)'로 안내하기 위해 제목 텍스트에 시각적으로 숨겨진 콘텐츠도 있어요.

<div class="govuk-accordion" data-module="govuk-accordion" id="accordion-default">
  <div class="govuk-accordion__section">
    <div class="govuk-accordion__section-header">
      <h2 class="govuk-accordion__section-heading">
        <span class="govuk-accordion__section-button" id="accordion-default-heading-1">
          Writing well for the web
        </span>
      </h2>
    </div>
    <div id="accordion-default-content-1" class="govuk-accordion__section-content">
      <p class="govuk-body">This is the content for Writing well for the web.</p>
    </div>
  </div>
  <div class="govuk-accordion__section">
    <div class="govuk-accordion__section-header">
      <h2 class="govuk-accordion__section-heading">
        <span class="govuk-accordion__section-button" id="accordion-default-heading-2">
          Writing well for specialists
        </span>
      </h2>
    </div>
    <div id="accordion-default-content-2" class="govuk-accordion__section-content">
      <p class="govuk-body">This is the content for Writing well for specialists.</p>
    </div>
  </div>
  <div class="govuk-accordion__section">
    <div class="govuk-accordion__section-header">
      <h2 class="govuk-accordion__section-heading">
        <span class="govuk-accordion__section-button" id="accordion-default-heading-3">
          Know your audience
        </span>
      </h2>
    </div>
    <div id="accordion-default-content-3" class="govuk-accordion__section-content">
      <p class="govuk-body">This is the content for Know your audience.</p>
    </div>
  </div>
  <div class="govuk-accordion__section">
    <div class="govuk-accordion__section-header">
      <h2 class="govuk-accordion__section-heading">
        <span class="govuk-accordion__section-button" id="accordion-default-heading-4">
          How people read
        </span>
      </h2>
    </div>
    <div id="accordion-default-content-4" class="govuk-accordion__section-content">
      <p class="govuk-body">This is the content for How people read.</p>
    </div>
  </div>
</div>
{% from "govuk/components/accordion/macro.njk" import govukAccordion %}

{{ govukAccordion({
  id: "accordion-default",
  items: [
    {
      heading: {
        text: "Writing well for the web"
      },
      content: {
        html: '<p class="govuk-body">This is the content for Writing well for the web.</p>'
      }
    },
    {
      heading: {
        text: "Writing well for specialists"
      },
      content: {
        html: '<p class="govuk-body">This is the content for Writing well for specialists.</p>'
      }
    },
    {
      heading: {
        text: "Know your audience"
      },
      content: {
        html: '<p class="govuk-body">This is the content for Know your audience.</p>'
      }
    },
    {
      heading: {
        text: "How people read"
      },
      content: {
        html: '<p class="govuk-body">This is the content for How people read.</p>'
      }
    }
  ]
}) }}

명확한 버튼 텍스트 작성하기

제목과 요약 줄을 다른 버튼 텍스트처럼 작성하세요. 문장형 대소문자(sentence case)를 사용하고, 보여줄 콘텐츠를 설명하며, 짧게 유지하세요.

버튼 텍스트가 너무 길면 스크린 리더 사용자가 아코디언을 탐색하기 어려워할 수 있어요.

명확한 버튼 텍스트를 만들기 어렵다면, 콘텐츠를 나눈 방식이 명확하지 않기 때문일 수 있어요. 사용자의 필요에 기반해 사용자에게 의미가 있는 방식으로 섹션을 구성하세요.

요약 줄 추가하기

요약 줄은 실제로 필요할 때만 추가하세요. 버튼 텍스트를 너무 길게 만들 가능성이 높으니까요.

요약 줄이 필요하다고 결정했다면, 가능한 한 짧게 만들어야 해요.

<div class="govuk-accordion" data-module="govuk-accordion" id="accordion-with-summary-sections">
  <div class="govuk-accordion__section">
    <div class="govuk-accordion__section-header">
      <h2 class="govuk-accordion__section-heading">
        <span class="govuk-accordion__section-button" id="accordion-with-summary-sections-heading-1">
          Understanding agile project management
        </span>
      </h2>
      <div class="govuk-accordion__section-summary govuk-body" id="accordion-with-summary-sections-summary-1">
        Introductions, methods, core features.
      </div>
    </div>
    <div id="accordion-with-summary-sections-content-1" class="govuk-accordion__section-content">
      <ul class="govuk-list">
        <li>
          <a class="govuk-link" href="#">Agile and government services: an introduction</a>
        </li>
        <li>
          <a class="govuk-link" href="#">Agile methods: an introduction</a>
        </li>
        <li>
          <a class="govuk-link" href="#">Core principles of agile</a>
        </li>
      </ul>
    </div>
  </div>
  <div class="govuk-accordion__section">
    <div class="govuk-accordion__section-header">
      <h2 class="govuk-accordion__section-heading">
        <span class="govuk-accordion__section-button" id="accordion-with-summary-sections-heading-2">
          Working with agile methods
        </span>
      </h2>
      <div class="govuk-accordion__section-summary govuk-body" id="accordion-with-summary-sections-summary-2">
        Workspaces, tools and techniques, user stories, planning.
      </div>
    </div>
    <div id="accordion-with-summary-sections-content-2" class="govuk-accordion__section-content">
      <ul class="govuk-list">
        <li>
          <a class="govuk-link" href="#">Creating an agile working environment</a>
        </li>
        <li>
          <a class="govuk-link" href="#">Agile tools and techniques</a>
        </li>
        <li>
          <a class="govuk-link" href="#">Set up a team wall</a>
        </li>
        <li>
          <a class="govuk-link" href="#">Writing user stories</a>
        </li>
        <li>
          <a class="govuk-link" href="#">Planning in agile</a>
        </li>
        <li>
          <a class="govuk-link" href="#">Deciding on priorities</a>
        </li>
        <li>
          <a class="govuk-link" href="#">Developing a roadmap</a>
        </li>
      </ul>
    </div>
  </div>
  <div class="govuk-accordion__section">
    <div class="govuk-accordion__section-header">
      <h2 class="govuk-accordion__section-heading">
        <span class="govuk-accordion__section-button" id="accordion-with-summary-sections-heading-3">
          Governing agile services
        </span>
      </h2>
      <div class="govuk-accordion__section-summary govuk-body" id="accordion-with-summary-sections-summary-3">
        Principles, measuring progress, spending money.
      </div>
    </div>
    <div id="accordion-with-summary-sections-content-3" class="govuk-accordion__section-content">
      <ul class="govuk-list">
        <li>
          <a class="govuk-link" href="#">Governance principles for agile service delivery</a>
        </li>
        <li>
          <a class="govuk-link" href="#">Measuring and reporting progress</a>
        </li>
        <li>
          <a class="govuk-link" href="#">Spend controls: check if you need approval to spend money on a service</a>
        </li>
        <li>
          <a class="govuk-link" href="#">Spend controls: apply for approval to spend money on a service</a>
        </li>
        <li>
          <a class="govuk-link" href="#">Spend controls: the new pipeline process</a>
        </li>
        <li>
          <a class="govuk-link" href="#">Working across organisational boundaries</a>
        </li>
      </ul>
    </div>
  </div>
  <div class="govuk-accordion__section">
    <div class="govuk-accordion__section-header">
      <h2 class="govuk-accordion__section-heading">
        <span class="govuk-accordion__section-button" id="accordion-with-summary-sections-heading-4">
          Phases of an agile project
        </span>
      </h2>
      <div class="govuk-accordion__section-summary govuk-body" id="accordion-with-summary-sections-summary-4">
        Discovery, alpha, beta, live and retirement.
      </div>
    </div>
    <div id="accordion-with-summary-sections-content-4" class="govuk-accordion__section-content">
      <ul class="govuk-list">
        <li>
          <a class="govuk-link" href="#">How the discovery phase works</a>
        </li>
        <li>
          <a class="govuk-link" href="#">How the alpha phase works</a>
        </li>
        <li>
          <a class="govuk-link" href="#">How the beta phase works</a>
        </li>
        <li>
          <a class="govuk-link" href="#">How the live phase works</a>
        </li>
        <li>
          <a class="govuk-link" href="#">Retiring your service</a>
        </li>
      </ul>
    </div>
  </div>
</div>
{% from "govuk/components/accordion/macro.njk" import govukAccordion %}

{{ govukAccordion({
  id: "accordion-with-summary-sections",
  items: [
    {
      heading: {
        text: "Understanding agile project management"
      },
      summary: {
        text: "Introductions, methods, core features."
      },
      content: {
        html:
        '<ul class="govuk-list">
            <li>
              <a class="govuk-link" href="#">Agile and government services: an introduction</a>
            </li>
            <li>
              <a class="govuk-link" href="#">Agile methods: an introduction</a>
            </li>
            <li>
              <a class="govuk-link" href="#">Core principles of agile</a>
            </li>
        </ul>'
      }
    },
    {
      heading: {
        text: "Working with agile methods"
      },
      summary: {
        text: "Workspaces, tools and techniques, user stories, planning."
      },
      content: {
        html:
        '<ul class="govuk-list">
            <li>
              <a class="govuk-link" href="#">Creating an agile working environment</a>
            </li>
            <li>
              <a class="govuk-link" href="#">Agile tools and techniques</a>
            </li>
            <li>
              <a class="govuk-link" href="#">Set up a team wall</a>
            </li>
            <li>
              <a class="govuk-link" href="#">Writing user stories</a>
            </li>
            <li>
              <a class="govuk-link" href="#">Planning in agile</a>
            </li>
            <li>
              <a class="govuk-link" href="#">Deciding on priorities</a>
            </li>
            <li>
              <a class="govuk-link" href="#">Developing a roadmap</a>
            </li>
        </ul>'
      }
    },
    {
      heading: {
        text: "Governing agile services"
      },
      summary: {
        text: "Principles, measuring progress, spending money."
      },
      content: {
        html:
        '<ul class="govuk-list">
            <li>
              <a class="govuk-link" href="#">Governance principles for agile service delivery</a>
            </li>
            <li>
              <a class="govuk-link" href="#">Measuring and reporting progress</a>
            </li>
            <li>
              <a class="govuk-link" href="#">Spend controls: check if you need approval to spend money on a service</a>
            </li>
            <li>
              <a class="govuk-link" href="#">Spend controls: apply for approval to spend money on a service</a>
            </li>
            <li>
              <a class="govuk-link" href="#">Spend controls: the new pipeline process</a>
            </li>
            <li>
              <a class="govuk-link" href="#">Working across organisational boundaries</a>
            </li>
        </ul>'
      }
    },
    {
      heading: {
        text: "Phases of an agile project"
      },
      summary: {
        text: "Discovery, alpha, beta, live and retirement."
      },
      content: {
        html:
        '<ul class="govuk-list">
            <li>
              <a class="govuk-link" href="#">How the discovery phase works</a>
            </li>
            <li>
              <a class="govuk-link" href="#">How the alpha phase works</a>
            </li>
            <li>
              <a class="govuk-link" href="#">How the beta phase works</a>
            </li>
            <li>
              <a class="govuk-link" href="#">How the live phase works</a>
            </li>
            <li>
              <a class="govuk-link" href="#">Retiring your service</a>
            </li>
        </ul>'
      }
    }
  ]
}) }}

섹션 제목을 페이지의 나머지 제목과 구조화하기

아코디언 컴포넌트는 섹션 제목을 `` 제목으로 표시해요. 필요하다면 섹션 제목의 제목 레벨을 변경해 페이지의 다른 제목들과 잘 어울리도록 하세요.

섹션을 펼친 상태로 시작하기

일부 섹션은 처음부터 펼친 상태가 필요할 수 있어요. 사용자가 페이지를 떠났다가 다시 돌아올 때, 펼쳤던 섹션도 계속 펼쳐져 있으면 좋을 수 있어요.

기본적으로 사용자가 같은 페이지 세션 안에서 페이지를 떠났다가 돌아오면, 아코디언 컴포넌트는 '세션 저장소(session storage)'를 사용해 어떤 섹션이 펼쳐져 있었는지 기억해요. 이 기능은 Nunjucks 매크로에 rememberExpanded: false를 추가해 끌 수 있어요.

변경 사항을 보려면 새 '세션'을 만들어야 할 수 있어요. 예를 들어, 새 탭이나 창에서 페이지를 여는 방식으로 말이죠.

govuk-accordion__section div에 govuk-accordion__section--expanded 클래스를 추가하면 개별 섹션을 처음부터 펼친 상태로 만들 수 있어요. Nunjucks 매크로를 사용한다면, 펼치고 싶은 개별 아코디언 항목에 expanded 옵션을 true로 설정하는 방식으로도 할 수 있어요.

섹션을 처음부터 펼쳐서 유지하도록 구성할 수 있지만, 접혀서 유지하도록는 구성할 수 없어요.

섹션 비활성화하지 않기

컨트롤을 비활성화하는 것은 보통 사용자에게 혼란을 줘요. 섹션에 콘텐츠가 없다면, 해당 섹션을 제거하거나, 사용자에게 혼란을 줄 것 같다면 섹션을 열었을 때 콘텐츠가 없는 이유를 설명하세요.

이 컴포넌트에 대한 리서치

우리는 2021년 12월에 버튼과 섹션 라벨이 링크로 오인될 수 있는 접근성 이슈를 해결하기 위해 이 컴포넌트를 업데이트했어요.

아코디언 컴포넌트를 개선하기 위해 이루어진 리서치와 개발에 대해 읽어 보세요.

팀은 컴포넌트가 접근 가능하도록, 예를 들어 사용자가 키보드만으로 상호작용할 수 있도록 확인했어요.

'요소 목록'으로 탐색하는 사용자

우리는 제목, 버튼, 링크 및 기타 요소의 '요소 목록'으로 탐색하는 사용자, 예를 들어 음성 인식 소프트웨어 사용자나 부분 시력(partially-sighted) 스크린 리더 사용자에 대해 더 알아볼 필요가 있어요.

이런 사용자에게는 섹션 제목이 버튼으로 간주된다는 것이 충분히 명확하지 않을 수 있어요. 이는 show/hide 라벨로 (덜 효율적으로) 탐색하도록 오도할 수 있어요.

이 경험은 처음에는 불편하지만, 사용자가 버튼 영역과 상호작용하고 포커스 상태를 보면 더 잘 이해할 가능성이 높아요. 접근성 클리닉 요약에서 'Dragon으로 테스트하기'를 확인하세요.

우리는 이 영역에서 잠재적 이슈를 식별할 수 있도록 수행된 사용자 리서치를 듣고 싶어요.

알려진 이슈와 공백

몇 단어 이상의 요약 줄을 추가하면 버튼 텍스트가 너무 길어질 가능성이 높아요. 특히 스크린 리더 사용자에게 말이죠.

우리는 서비스 팀이 언제 요약 줄을 사용하고 이것이 스크린 리더 사용자에게 어떤 영향을 주는지 더 잘 이해할 필요가 있어요. 여러분의 발견과 리서치를 우리와 공유해 주세요.

우리는 다음에 무엇을 할지 알려줄 피드백을 받고 싶어요.

최근 변경 사항

| 날짜 | 변경 | 설명 | | 2025년 4월 | 가이드 | 섹션을 기본적으로 펼친 상태로 표시하는 방법에 대한 가이드 추가. | | 2024년 2월 | GOV.UK Frontend v5.1.0 | 아코디언 섹션에서 aria-labelledby 속성 제거. | | 2023년 4월 | GOV.UK Frontend v4.6.0 | rememberExpanded 매개변수와 가이드 추가. | | 2023년 1월 | GOV.UK Frontend v4.5.0 | 사용자가 브라우저의 '페이지 내 찾기' 기능을 사용해 아코디언 안의 콘텐츠를 찾을 수 있는 기능 추가. 서로 다른 브레이크포인트 간의 간격 불일치 수정. | | 2022년 11월 | GOV.UK Frontend v4.4.0 | data-* 속성과 JavaScript를 사용해 인터페이스 텍스트를 지역화(localise)하는 옵션 추가. |

전체 변경 이력 보기

이 컴포넌트 개선에 도움 주기

이 페이지를 유용하고 관련성 있고 최신 상태로 유지하는 데 도움을 주려면 다음을 할 수 있어요:

  • GitHub의 'Accordion' 토론에 참여하고 여러분의 리서치를 공유하기

  • GitHub에서 변경을 제안하기 – GitHub에서 변경을 제안하는 방법에 대해 더 읽어보기

더 알아보기 (Learn more)

아코디언은 콘텐츠가 많고 관련된 섹션을 다루는 페이지에 유용해요. 다만 콘텐츠를 숨긴다는 점을 항상 기억하고, 사용자 리서치가 뒷받침할 때만 아코디언을 사용하세요. 탭이나 디테일과의 차이를 이해하면 더 적합한 컴포넌트를 고를 수 있어요.