Class CardBuilder
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
CardBuilder
Card
객체의 빌더입니다.
자세한 문서
addCardAction(cardAction)
addSection(section)
이 카드에 섹션을 추가합니다. 카드에 섹션을 100개 이상 추가할 수 없습니다.
매개변수
리턴
CardBuilder
: 연결을 위한 객체입니다.
build()
현재 카드를 빌드하고 유효성을 검사합니다.
리턴
Card
: 확인된 카드입니다.
생성 값
Error
: 생성된 카드가 유효하지 않은 경우
setDisplayStyle(displayStyle)
이 카드의 표시 스타일을 설정합니다.
표시 스타일이 DisplayStyle.REPLACE
로 설정된 경우 카드 스택에서 맨 위 카드의 뷰를 대체하여 카드가 표시됩니다.
디스플레이 스타일이 DisplayStyle.PEEK
로 설정된 경우 카드의 헤더가 사이드바 하단에 표시되어 비슷한 사진의 현재 상단 카드를 부분적으로 가립니다. 헤더를 클릭하면 카드가 카드 스택으로 튀어나옵니다. 카드에 헤더가 없으면 생성된 헤더가 대신 사용됩니다.
DisplayStyle
는 문맥 트리거 함수에서 반환된 카드에만 작동합니다.
매개변수
리턴
CardBuilder
: 연결을 위한 객체입니다.
setName(name)
이 카드의 이름을 설정합니다. 이 이름은 탐색에 사용할 수 있습니다.
매개변수
리턴
CardBuilder
: 연결을 위한 객체입니다.
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-07-26(UTC)
[null,null,["최종 업데이트: 2025-07-26(UTC)"],[[["\u003cp\u003e\u003ccode\u003eCardBuilder\u003c/code\u003e helps in constructing \u003ca href=\"/apps-script/reference/card-service/card\"\u003eCard\u003c/a\u003e objects for Google Apps Script.\u003c/p\u003e\n"],["\u003cp\u003eIt offers methods to add sections, actions, headers, footers and define display styles for the card.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eCardBuilder\u003c/code\u003e provides control over the card's structure and behavior within the user interface.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003ebuild()\u003c/code\u003e method finalizes the card creation and validates its structure before returning a \u003ccode\u003eCard\u003c/code\u003e object.\u003c/p\u003e\n"],["\u003cp\u003eYou can chain methods together for a more fluent and concise building process.\u003c/p\u003e\n"]]],[],null,["# Class CardBuilder\n\nCardBuilder\n\nA builder for [Card](/apps-script/reference/card-service/card) objects. \n\n### Methods\n\n| Method | Return type | Brief description |\n|---------------------------------------------------------------------|--------------------------------------------------|------------------------------------------------------------------------------------|\n| [addCardAction(cardAction)](#addCardAction(CardAction)) | [CardBuilder](#) | Adds a [CardAction](/apps-script/reference/card-service/card-action) to this Card. |\n| [addSection(section)](#addSection(CardSection)) | [CardBuilder](#) | Adds a section to this card. |\n| [build()](#build()) | [Card](/apps-script/reference/card-service/card) | Builds the current card and validates it. |\n| [setDisplayStyle(displayStyle)](#setDisplayStyle(DisplayStyle)) | [CardBuilder](#) | Sets the display style for this card. |\n| [setFixedFooter(fixedFooter)](#setFixedFooter(FixedFooter)) | [CardBuilder](#) | Sets a fixed footer for this card. |\n| [setHeader(cardHeader)](#setHeader(CardHeader)) | [CardBuilder](#) | Sets the header for this card. |\n| [setName(name)](#setName(String)) | [CardBuilder](#) | Sets the name for this card. |\n| [setPeekCardHeader(peekCardHeader)](#setPeekCardHeader(CardHeader)) | [CardBuilder](#) | Sets the peek card header. |\n\nDetailed documentation\n----------------------\n\n### `add``Card``Action(cardAction)`\n\nAdds a [CardAction](/apps-script/reference/card-service/card-action) to this Card.\n\n#### Parameters\n\n| Name | Type | Description |\n|----------------|---------------------------------------------------------------|---------------------------------------------------------------------------|\n| `card``Action` | [CardAction](/apps-script/reference/card-service/card-action) | The [CardAction](/apps-script/reference/card-service/card-action) to use. |\n\n#### Return\n\n\n[CardBuilder](#) --- This object, for chaining.\n\n*** ** * ** ***\n\n### `add``Section(section)`\n\nAdds a section to this card. You can't add more than 100 sections to a card.\n\n#### Parameters\n\n| Name | Type | Description |\n|-----------|-----------------------------------------------------------------|-----------------------------------------------------------------------------|\n| `section` | [CardSection](/apps-script/reference/card-service/card-section) | The [CardSection](/apps-script/reference/card-service/card-section) to use. |\n\n#### Return\n\n\n[CardBuilder](#) --- This object, for chaining.\n\n*** ** * ** ***\n\n### `build()`\n\nBuilds the current card and validates it.\n\n#### Return\n\n\n[Card](/apps-script/reference/card-service/card) --- A validated card.\n\n#### Throws\n\n\n[`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) --- if the constructed card isn't valid.\n\n*** ** * ** ***\n\n### `set``Display``Style(displayStyle)`\n\nSets the display style for this card.\n\nIf the display style is set to `Display``Style.REPLACE`, the card is shown by replacing\nthe view of top card in the card stack.\n\nIf the display style is set to `Display``Style.PEEK`, the header of the card appears at\nthe bottom of the sidebar, partially covering the current top card of the stack. Clicking the\nheader pops the card into the card stack. If the card has no header, a generated header is used\ninstead.\n\n\n`Display``Style` only works for card returned from contextual trigger function.\n\n#### Parameters\n\n| Name | Type | Description |\n|------------------|-------------------------------------------------------------------|-------------------------------------------------------------------------------|\n| `display``Style` | [DisplayStyle](/apps-script/reference/card-service/display-style) | The [DisplayStyle](/apps-script/reference/card-service/display-style) to set. |\n\n#### Return\n\n\n[CardBuilder](#) --- This object, for chaining.\n\n*** ** * ** ***\n\n### `set``Fixed``Footer(fixedFooter)`\n\nSets a fixed footer for this card.\n\n#### Parameters\n\n| Name | Type | Description |\n|-----------------|-----------------------------------------------------------------|-----------------------------------------------------------------------------|\n| `fixed``Footer` | [FixedFooter](/apps-script/reference/card-service/fixed-footer) | The [FixedFooter](/apps-script/reference/card-service/fixed-footer) to use. |\n\n#### Return\n\n\n[CardBuilder](#) --- This object, for chaining.\n\n*** ** * ** ***\n\n### `set``Header(cardHeader)`\n\nSets the header for this card.\n\n#### Parameters\n\n| Name | Type | Description |\n|----------------|---------------------------------------------------------------|---------------------------------------------------------------------------|\n| `card``Header` | [CardHeader](/apps-script/reference/card-service/card-header) | The [CardHeader](/apps-script/reference/card-service/card-header) to use. |\n\n#### Return\n\n\n[CardBuilder](#) --- This object, for chaining.\n\n*** ** * ** ***\n\n### `set``Name(name)`\n\nSets the name for this card. The name can be used for [navigation](/gmail/add-ons/how-tos/navigation).\n\n#### Parameters\n\n| Name | Type | Description |\n|--------|----------|-------------|\n| `name` | `String` | The name. |\n\n#### Return\n\n\n[CardBuilder](#) --- This object, for chaining.\n\n*** ** * ** ***\n\n### `set``Peek``Card``Header(peekCardHeader)`\n\nSets the peek card header.\n\nThe peek card is set on the first card returned from a contextual trigger function. It is\nused as a descriptive placeholder widget so that users can navigate from a homepage stack to\nthe contextual stack.\n\n#### Parameters\n\n| Name | Type | Description |\n|----------------------|---------------------------------------------------------------|---------------------------------------------------------------------------|\n| `peek``Card``Header` | [CardHeader](/apps-script/reference/card-service/card-header) | The [CardHeader](/apps-script/reference/card-service/card-header) to set. |\n\n#### Return\n\n\n[CardBuilder](#) --- This object, for chaining."]]