Card
Groups related content and actions in a consistent visual container.
On this page
This docs is LLM-friendly and available as clean Markdown.
Supported browser agents can also use WebMCP to search, read, and open these docs. Learn more
Usage
import {
GlCard,
GlCardContent,
GlCardFooter,
GlCardHeader,
} from "gitlab-ui-react/card";<GlCard>
<GlCardHeader><h3>Card title</h3></GlCardHeader>
<GlCardContent>Lorem ipsum dolor sit amet.</GlCardContent>
<GlCardFooter>Footer content</GlCardFooter>
</GlCard>Default
Compose a card from an optional header, required primary content, and optional footer. Use it for a self-contained topic that benefits from visual separation and a repeatable structure.
Example Card
import { GlButton } from "gitlab-ui-react/button";
import {
GlCard,
GlCardContent,
GlCardFooter,
GlCardHeader,
} from "gitlab-ui-react/card";
export default function CardExample() {
return (
<GlCard>
<GlCardHeader>
<h3>Example Card</h3>
</GlCardHeader>
<GlCardContent>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua.
</GlCardContent>
<GlCardFooter>
<GlButton size="small" href="#opanel">View more</GlButton>
</GlCardFooter>
</GlCard>
);
}
Content only
Render only GlCardContent when a topic needs the card treatment but has no distinct header or footer. For simple visual separation without a meaningful content group, prefer ordinary HTML and spacing or border utilities.
import {
GlCard,
GlCardContent,
} from "gitlab-ui-react/card";
export default function CardContentExample() {
return (
<GlCard>
<GlCardContent>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua.
</GlCardContent>
</GlCard>
);
}
Accessibility
- A card is a visually styled
div, not a landmark. Add semantic structure only when the card’s role in the page requires it. - Put an appropriately leveled heading in
GlCardHeader; keep heading levels consistent with the surrounding page hierarchy. - Use semantic links and buttons for actions. Do not make a container behave like one large control when it also contains nested interactive elements.
- When displaying a collection of related cards, use a parent
uland place each card in anli. - Keep the internal structure consistent across comparable cards so the collection remains easy to scan.
API
Each card part renders a div, forwards its ref, and accepts children plus supported div attributes. None has additional component-specific props.
GlCard
Provides the outer card container.
GlCardHeader
Provides the optional header region.
GlCardContent
Provides the card’s primary content region.
GlCardFooter
Provides the optional footer region.