Card
카드는 페이지 안에서 관련된 콘텐츠를 하나의 상자로 묶어 보여주는 컴포넌트예요. 제목, 본문, 푸터, 헤더 이미지와 액션, 선택형·동작형 카드, 확장형 카드 등 다양한 형태로 활용할 수 있어요.
출처: 문서
본문
Examples
Basic cards
기본 카드는 보통 , 와 를 포함해요. 필요에 따라 이 컴포넌트들 중 일부는 생략할 수 있지만, 최소한 하나는 넣어 카드 항목에 대한 설명을 제공하는 것을 권장해요.
Title
Body
Footer
Card with subtitle
부제목이 있는 기본 카드예요.
Title
Subtitle
Body
Footer
Card with subtitle and Actions
이 카드는 이미지, 액션, 부제목을 한 카드에 함께 담은 예시예요.
actions hasNoOffset
Title
Subtitle
Body
Footer
Secondary cards
카드의 variant 속성을 secondary로 설정하면 카드에 보조 배경색 스타일을 적용할 수 있어요.
Title
Body
Footer
Modifiers
아래에 정리한 속성을 사용해 카드 내용의 스타일을 추가로 조정할 수 있어요. 이 예시에서는 각 체크박스를 선택해 수정자를 하나씩 켜 볼 수 있어요.
대부분의 수정자는 서로 조합해서 쓸 수 있지만, isCompact와 isLarge는 서로 모순되므로 함께 사용할 수 없어요.
isCompact
isLarge
isFullHeight
isPlain
Title
Body
Footer
| | Modifier | Description
| isCompact | | Modifies the card to include compact styling. Should not be used with isLarge. | | isLarge | | Modifies the card to be large. Should not be used with isCompact. | | isFullHeight | | Modifies the card so that it fills the total available height of its container. | | isPlain | | Modifies the card to include plain styling, which removes the border and background. |
Header images and actions
의 `actions` 속성으로 카드 헤더 액션을 포함할 수 있어요. 아래 예시는 [Brand](/components/brand) 컴포넌트로 이미지를 넣고, actions에 케밥 드롭다운과 체크박스도 함께 담고 있어요.
``의 actions 속성은 기본값이 false인 hasNoOffset 속성을 포함해요. hasNoOffset이 false일 때는 음수 마진이 적용되어 기본 크기의 카드 제목과 카드 액션을 정렬하는 데 도움을 줘요.
hasNoOffset을 사용하면 이 음수 마진을 제거할 수 있는데, 예를 들어 큰 카드 제목이나 높은 헤더 이미지를 사용하는 구현에서 카드 액션을 더 잘 정렬할 수 있어요.
아래 예시에서 "actions hasNoOffset" 체크박스를 선택해 이 동작을 확인해 보세요.
actions hasNoOffset
Title
Body
Footer
Title inline with images and actions
를 안에서 이동하면 이미지나 액션과 인라인으로 배치되는 스타일을 적용할 수 있어요.
This is a really really really really really really really really really really long header
Body
Footer
Card header without title
없이도 카드 액션을 카드 헤더에 배치할 수 있어요. 없이도 이미지를 카드 헤더에 배치할 수 있어요.
This is the card body. There are only actions in the card head.
Card with header that wraps
This is a longer card title that takes up more space
This is the card body
With HTML heading element
component 속성을 사용하면 카드 제목을 HTML 제목 요소 안에 넣을 수 있어요.
Title within an
element
Body
Footer
With multiple body sections
여러 개의 본문 섹션을 사용해 콘텐츠 블록을 시각적으로 구분할 수 있어요.
Title
Body
Body
Body
Footer
With a primary body section that fills
섹션은 `isFilled`이 `{true}`일 때(기본값) 카드의 가용 높이를 채워요. `isFilled`을 `{false}`로 설정하면 하나 이상의 본문 섹션에 대해 이 동작을 끌 수 있어요. 그러면 카드의 나머지 가용 높이는 `isFilled`을 `{false}`로 설정하지 않은 섹션들 사이에 나뉘어 배분돼요.
이런 경우의 흔한 활용은 아래 예시처럼 본문 섹션 중 하나를 제외한 나머지 모두를 isFilled={false}로 설정해서, 기본 본문 섹션이 카드의 가용 공간을 채우도록 하는 거예요. 이 예시는 3개의 섹션이 있고, 그중 두 개는 `isFilled`을 `{false}`로 설정하죠. 세 번째가 카드의 나머지 높이를 채워요.
Title
Body pf-m-no-fill
Body pf-m-no-fill
Body
Footer
Selectable
선택형 카드는 카드 안 아무 곳이나 클릭해 선택할 수 있어요. 선택 전용으로 사용할 `` 안에는 다른 상호작용 콘텐츠를 렌더링하지 않아야 해요. 선택도 되고 다른 상호작용·동작 콘텐츠도 필요한 카드가 있다면 actionable and selectable example을 참고하세요.
Secondary card styling
Hide checkbox
First card
This card is selectable.
Second card
This card is selectable.
Third card
This card is selectable but disabled.
Single selectable
관련된 단일 선택형 카드 그룹을 만들 때는 각 카드의 selectableActions 속성에 동일한 name 속성을 전달해야 해요. 숨겨진 입력이 있는 선택형 카드에 대한 더 자세한 안내는 cards as tiles examples을 참고하세요.
Hide radio button
First card
This card is single selectable.
Second card
This card is single selectable.
Third card
This card is single selectable but disabled.
Actionable
동작형 카드는 카드 안 아무 곳이나 클릭해 동작을 수행하거나 링크로 이동할 수 있어요. 링크를 새 탭이나 새 창에서 열려면 selectableActions에 isExternalLink 속성을 전달해요.
카드를 클릭했을 때 primary-detail view가 열리는 경우처럼, 현재 클릭된 카드임을 나타내려면 에 `isClicked` 속성을 전달할 수 있어요. 이는 단순히 카드를 "선택"하기 위한 용도로 사용하면 안 되고, 그런 경우에는 [selectable card](#selectable)나 [single selectable card](#single-selectable)를 사용해야 해요. 카드가 동작 전용일 때는 선택형 카드와 마찬가지로 안에 다른 상호작용 콘텐츠를 렌더링하지 않아야 해요.
secondary styling
First card in the actionable example
This card performs an action on click.
Second card in the actionable example
This card can navigate to a link on click.
Third card in the actionable example
This card is clickable but disabled.
Actionable and selectable
``에 isClickable과 isSelectable 속성을 모두 전달하면 카드를 선택 가능하게 하면서 추가 상호작용 콘텐츠를 가질 수 있어요. 아래 예시는 동작 기능을 선택형 카드 안 어디서든 렌더링할 수 있다는 것을 보여줘요.
비활성화된 동작·선택형 카드에 상호작용 콘텐츠를 전달할 때는, 해당되는 경우 그 상호작용 콘텐츠도 함께 비활성화해야 해요.
secondary styling
This card performs an action upon clicking the card title and is selectable.
Second Card
This card is selectable and has a link in the card body that navigates to Patternfly .
This card is clickable and selectable, but disabled.
Expandable cards
isExpanded 속성을 사용하면 카드를 확장 가능하게 만들 수 있어요. 접힌 상태에서는 카드 헤더만 표시되고, 사용자가 캐럿을 클릭하면 나머지 카드 내용을 볼 수 있어요.
숨기고 싶은 콘텐츠는 `` 컴포넌트 안에 배치하세요.
isToggleRightAligned
Title
Expandable with icon
확장 캐럿 옆에 아이콘을 보여주기 위해 카드 헤더에 이미지를 배치할 수 있어요.
Card with dividers
카드 섹션 사이에 구분선을 배치할 수 있어요.
Title
Body
Body
Footer
Cards as tiles
선택 가능한 카드 집합을 타일로 사용할 수 있는데, 이는 사용자가 선택할 수 있는 정적 옵션이에요.
selectableActions 객체에 variant 속성을 전달하면 단일 선택 또는 다중 선택이 가능해져요. isHidden 속성을 selectableActions 객체에 전달하면 라디오나 체크박스의 표시 여부도 전환할 수 있어요.
Single selectable tiles
집합에서 사용자가 1개 이상의 타일을 선택하지 못하게 하려면 ``의 selectableActions 객체 안에서 variant를 "single"로 설정하세요.
Tile header
Tile content and description
Tile header
Tile content and description
Tile header (disabled)
Tile content and description
Multi selectable tiles
집합에서 사용자가 1개 이상의 타일을 선택하도록 하려면 ``의 selectableActions 객체 안에 variant를 설정하지 마세요.
Tile header
Tile content and description
Tile header
Tile content and description
Tile header (disabled)
Tile content and description
Props
Card
*required | | Name | Type | Default | Description | children | React.ReactNode | | Content rendered inside the Card | | className | string | | Additional classes added to the Card | | component | React.JSX.IntrinsicElements | | Sets the base component to render. defaults to div | | id | string | | ID of the Card. Also passed back in the CardHeader onExpand callback. | | isClickable | boolean | | Flag indicating that the card is clickable and contains some action that triggers on click. | | isClicked | boolean | | Flag indicating whether a card that is either only clickable or that is both clickable and selectable is currently clicked and has clicked styling. | | isCompact | boolean | | Modifies the card to include compact styling. Should not be used with isLarge. | | isDisabled | boolean | | Flag indicating that a clickable or selectable card is disabled. | | isExpanded | boolean | | Flag indicating if a card is expanded. Modifies the card to be expandable. | | isFullHeight | boolean | | Cause component to consume the available height of its container | | isGlass | boolean | | Modifies the card to include glass styling when glass theme is enabled | | isLarge | boolean | | Modifies the card to be large. Should not be used with isCompact. | | isPlain | boolean | | Modifies the card to include plain styling; this removes border and background | | isSelectable | boolean | | Flag indicating that the card is selectable. | | isSelected | boolean | | Flag indicating whether a card that is either selectable only or both clickable and selectable is currently selected and has selected styling. | | ouiaId | number | string | | Value to overwrite the randomly generated data-ouia-component-id. | | ouiaSafe | boolean | | Set the value of data-ouia-safe. Only set to true when the component is in a static state, i.e. no animations are occurring. At all other times, this value must be false. | | variant | 'default' | 'secondary' | | Card background color variant |
CardHeader
*required | | Name | Type | Default | Description | actions | CardHeaderActionsObject | | Actions of the card header | | children | React.ReactNode | | Content rendered inside the card header | | className | string | | Additional classes added to the card header | | hasWrap | boolean | | Flag indicating that header wrapping is enabled | | id | string | | ID of the card header. | | isToggleRightAligned | boolean | | Whether to right-align expandable toggle button | | onExpand | (event: React.MouseEvent, id: string) => void | | Callback expandable card | | selectableActions | CardHeaderSelectableActionsObject | | Selectable actions of the card header | | toggleButtonProps | any | | Additional props for expandable toggle button |
CardHeaderActionsObject
required | | Name | Type | Default | Description | actionsrequired | React.ReactNode | | Actions of the card header | | className | string | | Additional classes added to the actions wrapper | | hasNoOffset | boolean | | Flag indicating that the actions have no offset |
CardHeaderSelectableActionsObject
*required | | Name | Type | Default | Description | className | string | | Additional classes added to the selectable actions wrapper | | hasNoOffset | boolean | | Flag indicating that the actions have no offset | | isChecked | boolean | | | isExternalLink | boolean | | Flag to indicate whether a clickable-only card's link should open in a new tab/window. | | isHidden | boolean | | Flag indicating the action is hidden | | name | string | | Name for the input element of a selectable card. | | onChange | (event: React.FormEvent, checked: boolean) => void | | Callback for when a selectable card input changes | | onClickAction | (event: React.MouseEvent) => void | | Action to call when a clickable-only card is clicked. This cannot be combined with the to prop. | | selectableActionAriaLabel | string | | Adds an accessible name to the input of a selectable card or clickable button/anchor of a clickable-only card. This or selectableActionAriaLabelledby is required for clickable-only cards. | | selectableActionAriaLabelledby | string | | A single or list of space-delimited ID's that provide an accessible name to the input of a selectable card or clickable button/anchor of a clickable-only card. This or selectableActionAriaLabelledby is required for clickable-only cards. | | selectableActionId | string | | Custom ID passed to the selectable card's input or a clickable-only card's button/anchor. If omitted, a random unique ID will be assigned to a selectable card's input. | | selectableActionProps | any | | Additional props spread to a selectable card input or clickable-only card's button/anchor. | | to | string | | Link to navigate to when a clickable-only card is clicked. This cannot be combined with the onClickAction prop. | | variant | 'single' | 'multiple' | | Determines the type of input to be used for a selectable card. |
CardTitle
*required | | Name | Type | Default | Description | children | React.ReactNode | | Content rendered inside the CardTitle | | className | string | | Additional classes added to the CardTitle | | component | React.JSX.IntrinsicElements | 'div' | Sets the base component to render. defaults to div | | subtitle Beta | React.ReactNode | | Subtitle of the card title |
CardBody
*required | | Name | Type | Default | Description | children | React.ReactNode | | Content rendered inside the Card Body | | className | string | | Additional classes added to the Card Body | | component | JSX.IntrinsicElements | 'div' | Sets the base component to render. defaults to div | | isFilled | boolean | true | Enables the body Content to fill the height of the card |
CardFooter
*required | | Name | Type | Default | Description | children | React.ReactNode | | Content rendered inside the Card Footer | | className | string | | Additional classes added to the Footer | | component | JSX.IntrinsicElements | 'div' | Sets the base component to render. defaults to div |
CardExpandableContent
*required | | Name | Type | Default | Description | children | React.ReactNode | | Content rendered inside the Card Body | | className | string | | Additional classes added to the Card Body |