Layout Components
[05] Layout Components
Card
Card is a container that groups related content with consistent styling. It can contain text, images, and other components.
Use a Card for one self-contained unit of content, such as a product, a profile or a group of settings, that should read as its own panel. A set of cards usually goes in a Grid, so each card gets the same column width. When the content needs padding and spacing but no border, use Stack; for a full-width band with its own background, use Section.
Basic usage
A card container with default styling. md, primary, outline, rounded, border, padding, gap, flex, and column are all defaults: no need to specify them.
Compose interfaces with ready-to-use components.
<Card> <Title>Welcome to VaneUI</Title> <Text>Compose interfaces with ready-to-use components.</Text></Card>Sizes
Cards come in different sizes: xs, sm, md (default), lg, xl. Size also scales padding, gap, and border-radius.
Tight content
Compact content
Default size
More spacious
Maximum room
<Row flexWrap itemsStart> <Card xs> <Title xs>Extra Small</Title> <Text xs>Tight content</Text> </Card> <Card sm> <Title sm>Small Card</Title> <Text sm>Compact content</Text> </Card> <Card> <Title>Medium Card</Title> <Text>Default size</Text> </Card> <Card lg> <Title lg>Large Card</Title> <Text lg>More spacious</Text> </Card> <Card xl> <Title xl>Extra Large</Title> <Text xl>Maximum room</Text> </Card></Row>Type sizes inside a Card
A card reads one step smaller than the page. A Title placed in the Card, in one of its parts or in a Col, Stack or Row there runs 14, 16, 18, 20 and 24px from xs to xl, 18px by default, at every screen width. An unsized Text, List or Blockquote there is 14px, the size of <Text sm>. One with xs, sm, lg or xl keeps its size, so give a figure that should stand out a larger size (<Title xl> for a 24px stat). Text placed straight in the Card, without a Text, keeps the page size. Before @vaneui/ui 1.8.3 a Title in a Card was 24px and a Text 16px, the sizes of page headings and page copy.
| Element in a Card | xs | sm | md (default) | lg | xl |
|---|---|---|---|---|---|
Title | 14px | 16px | 18px | 20px | 24px |
Text, List, Blockquote | 12px | 14px | 14px | 18px | 20px |
Appearances
Cards support color appearances: primary (default), accent, secondary, tertiary, success, danger, warning, info.
Default
Highlight
Subtle styling
Quiet emphasis
Positive status
Error or alert
Caution
Informational
<Row flexWrap> <Card> <Title>Primary</Title> <Text>Default</Text> </Card> <Card accent> <Title>Accent</Title> <Text>Highlight</Text> </Card> <Card secondary> <Title>Secondary</Title> <Text>Subtle styling</Text> </Card> <Card tertiary> <Title>Tertiary</Title> <Text>Quiet emphasis</Text> </Card> <Card success> <Title>Success</Title> <Text>Positive status</Text> </Card> <Card danger> <Title>Danger</Title> <Text>Error or alert</Text> </Card> <Card warning> <Title>Warning</Title> <Text>Caution</Text> </Card> <Card info> <Title>Info</Title> <Text>Informational</Text> </Card></Row>Variants
outline is the default. Use filled for solid backgrounds. Add shadow for elevation.
Default: border only
Solid background
Elevated appearance
<Row flexWrap> <Card> <Title>Outline</Title> <Text>Default: border only</Text> </Card> <Card filled> <Title filled>Filled</Title> <Text filled>Solid background</Text> </Card> <Card shadow> <Title>Shadow</Title> <Text>Elevated appearance</Text> </Card></Row>Strong border for a selected card
strongBorder paints the border in the appearance's strong color, the one its focus ring uses, instead of the soft border tint. Use it to mark a selected option or a highlighted plan in a set of cards. A filled Card, whose border is otherwise transparent, shows the strong border too.
Default border
strongBorder
accent strongBorder
info filled strongBorder
<Grid2> <Card> <Title>Starter</Title> <Text secondary>Default border</Text> </Card> <Card strongBorder> <Title>Team</Title> <Text secondary>strongBorder</Text> </Card> <Card accent strongBorder> <Title>Business</Title> <Text secondary>accent strongBorder</Text> </Card> <Card info filled strongBorder> <Title filled>Enterprise</Title> <Text filled>info filled strongBorder</Text> </Card></Grid2>strongBorder changes the color only, so it shows wherever the component already draws a border. The same prop works on Row, Col, Stack, Grid2 to Grid6, Container and Section, which draw no border until you add border or a side prop such as borderB. It needs @vaneui/ui 1.4.5 or later.
Shadow sizes
shadow follows the card's size, so an lg Card casts a larger shadow than an sm one. shadowXs, shadowSm, shadowMd, shadowLg and shadowXl fix the shadow size whatever the card's size. Card uses the deeper layout shadow ramp; UI components such as Button take the same props on their compact ramp.
shadowXs
shadowSm
shadowMd
shadowLg
shadowXl
<Row flexWrap> <Card sm shadowXs><Text sm>shadowXs</Text></Card> <Card sm shadowSm><Text sm>shadowSm</Text></Card> <Card sm shadowMd><Text sm>shadowMd</Text></Card> <Card sm shadowLg><Text sm>shadowLg</Text></Card> <Card sm shadowXl><Text sm>shadowXl</Text></Card></Row>The shadow props share one category with shadow and noShadow, so set one of them at a time. The fixed sizes need @vaneui/ui 1.4.5 or later.
Shapes
rounded is the default. Use pill for fully rounded corners or sharp for none.
Default style
Fully rounded
No radius
<Row flexWrap> <Card> <Title>Rounded</Title> <Text>Default style</Text> </Card> <Card pill> <Title>Pill</Title> <Text>Fully rounded</Text> </Card> <Card sharp> <Title>Sharp</Title> <Text>No radius</Text> </Card></Row>Card with sub-components
Use CardHeader, CardBody, and CardFooter to give a card explicit structural regions. When any sub-component is present the parent Card switches to compound mode and the sub-components own padding. The parts meet one inset apart: the body keeps its padding, the header drops its bottom padding, the footer drops its top padding, and the Card puts no gap between them. For a divider, add borderB to the header or borderT to the footer. A part with a line, and a filled part, keeps its padding on that side.
Configure your preferences below. The body grows to fill available space.
<Card> <CardHeader> <Title>Settings</Title> <Badge success filled>Active</Badge> </CardHeader> <CardBody> <Text>Configure your preferences below. The body grows to fill available space.</Text> </CardBody> <CardFooter> <Button secondary>Cancel</Button> <Button filled>Save</Button> </CardFooter></Card>A part counts when it renders as the Card's direct child: written in the Card's JSX, inside a fragment, behind memo(), returned by your own component or rendered from a Server Component. A part nested inside another element does not count, and the Card keeps its own padding. An explicit padding, paddingX or paddingY on the Card keeps its inset next to the parts. Before @vaneui/ui 1.6.0, only a part written directly in the Card's JSX switched the Card to compound mode.
Responsive layout
Use row for horizontal layout and mobileStack or tabletStack to switch to column on smaller screens.
Visual content area
This layout switches to column on tablets and below. Resize to see the effect.
<Card row tabletStack> <Col> <Title>Product Image</Title> <Text secondary>Visual content area</Text> </Col> <Col> <Title>Product Details</Title> <Text>This layout switches to column on tablets and below. Resize to see the effect.</Text> </Col></Card>Nested cards
Cards can be nested. Pair a secondary or tertiary inner card with the default primary outer card to create clear visual hierarchy.
Manage the resources tied to your workspace.
4.2GB of 10GB used
3 active collaborators
<Card> <Title>Account</Title> <Text>Manage the resources tied to your workspace.</Text> <Card secondary> <Title sm>Storage</Title> <Text sm>4.2GB of 10GB used</Text> </Card> <Card secondary> <Title sm>Members</Title> <Text sm>3 active collaborators</Text> </Card></Card>As Link
Add href to make the card a clickable link. The card automatically renders as an <a> tag when href is provided, ensuring valid HTML. When href is set, the card gains a keyboard focus-visible outline in its appearance's focus color and tints on hover. Opt out of the outline with noFocusVisible.
The whole card becomes one link, so don't put a Button, Link or field inside it: one click would trigger both, and the link's accessible name would swallow the card's text (a development build warns). For a card with its own actions, render the card without href, put a Link in its title, and keep the Button beside it.
<Row flexWrap> <Card href="#as-link" filled> <Title filled>Services</Title> <Text filled>Click to navigate</Text> </Card> <Card href="#as-link" secondary filled> <Title secondary filled>Pricing</Title> <Text secondary filled>View our plans</Text> </Card> <Card href="https://github.com" target="_blank" rel="noopener noreferrer"> <Title>External Link</Title> <Text>Opens in new tab</Text> </Card></Row>Next.js Link integration
Use the tag prop to render the card as a Next.js Link for client-side navigation.
import Link from 'next/link';import { Card, Title, Text } from '@vaneui/ui';
<Card href="/docs" tag={Link}> <Title>Documentation</Title> <Text>Browse component guides and API reference.</Text></Card>Customizing
Set app-wide Card defaults with ThemeProvider's themeDefaults:
<ThemeProvider themeDefaults={{ card: { main: { shadow: true } },}}> <Card>Content</Card></ThemeProvider>Frequently asked questions
Why are the cards in my Row different heights?
A Row centers its children on the cross axis (itemsCenter is a default), so each Card is as tall as its own content. Put the cards in a Grid such as Grid3, whose cells stretch to the height of the tallest one in their row, or add itemsStretch to the Row. A Grid also gives every card the same width.
How do I line up the footers of cards with different content?
Build each card from CardBody and CardFooter, and put the cards in a Grid. The Grid stretches every card in a row to the same height, and CardBody grows to fill the height the card has left, so each CardFooter sits at the bottom edge whatever the length of the text above it. The parts are described under Card with sub-components.
Why does a Button in a filled Card keep its own colors?
Button paints its own colors: its default primary outline palette stays the same on any surface, while Text and Title take the colors of the Card. Give the Button an appearance and variant that read on the fill, for example <Button secondary filled> on a filled primary Card. Which components set vs. inherit lists both groups.
Card Props
| Prop | Category | Default | Description |
|---|---|---|---|
accent | Appearance | Accent color appearance (rose) | |
danger | Appearance | Danger color appearance (red) | |
info | Appearance | Info color appearance (cyan) | |
inheritAppearance | Appearance | Inherit appearance from parent — suppresses own data-appearance/data-variant, uses parent's CSS variables | |
primary | Appearance | ✓ | Primary color appearance (gray) |
secondary | Appearance | Secondary color appearance (gray) | |
success | Appearance | Success color appearance (green) | |
tertiary | Appearance | Tertiary color appearance | |
warning | Appearance | Warning color appearance (amber) | |
aspectAuto | Aspect | The content's own ratio (aspect-ratio: auto) | |
aspectSquare | Aspect | Square box (aspect-ratio: 1 / 1) | |
aspectVideo | Aspect | Video box (aspect-ratio: 16 / 9) | |
desktopStack | Breakpoint | Stack into a column at desktop width and below (max-desktop: 80rem) | |
mobileStack | Breakpoint | Stack into a column at mobile width and below (max-mobile: 48rem) | |
tabletStack | Breakpoint | Stack into a column at tablet width and below (max-tablet: 64rem) | |
flex1 | Flex | Take up remaining space (= | |
flexAuto | Flex | Grow but respect intrinsic size (= | |
flexNone | Flex | Don't grow and don't shrink (= | |
margin | Margin | Enable margin on all sides | |
marginB | Margin | Enable only bottom margin | |
marginT | Margin | Enable only top margin | |
marginX | Margin | Enable only horizontal (inline) margin | |
marginY | Margin | Enable only vertical (block) margin | |
noMargin | Margin | Disable margin (reset to 0) | |
noPadding | Padding | Disable internal padding | |
padding | Padding | ✓ | Enable internal padding |
paddingX | Padding | Enable only horizontal padding | |
paddingY | Padding | Enable only vertical padding | |
pill | Shape | Fully rounded corners (circular) | |
rounded | Shape | ✓ | Medium rounded corners (default) |
sharp | Shape | No rounded corners (square) | |
noShrink | Shrink | Prevent the flex item from shrinking below its content size (= | |
lg | Size | Large size | |
md | Size | ✓ | Medium size (default) |
sm | Size | Small size | |
xl | Size | Extra large size | |
xs | Size | Extra small size | |
skeleton | Skeleton | Show the component as a loading placeholder in its own size and shape. On a container, every component inside it becomes a placeholder too | |
strongBorder | Strong Border | Paint the border in the appearance's strong color instead of its soft one | |
textCenter | Text Align | Align text to center | |
textEnd | Text Align | Align text to the reading-direction end (right in LTR, left in RTL) | |
textJustify | Text Align | Justify text | |
textLeft | Text Align | Align text to left (physical side, does not flip under RTL) | |
textRight | Text Align | Align text to right (physical side, does not flip under RTL) | |
textStart | Text Align | Align text to the reading-direction start (left in LTR, right in RTL) | |
filled | Variant | Filled variant - solid background with contrasting text color | |
ghost | Variant | Ghost variant - transparent background, no border, appearance-colored text, tinted hover background | |
outline | Variant | ✓ | Outline variant - transparent background with border and colored text (default) |
Layout & utility props (gap, padding, hide, items, justify, ...)
Documented on Common Props.
| Prop | Category | Default | Description |
|---|---|---|---|
border | Border | ✓ | Enable border on all sides |
borderB | Border | Enable border on bottom | |
borderEnd | Border | Enable border on the inline-end side (right in LTR, left in RTL) | |
borderL | Border | Enable border on left | |
borderR | Border | Enable border on right | |
borderStart | Border | Enable border on the inline-start side (left in LTR, right in RTL) | |
borderT | Border | Enable border on top | |
borderX | Border | Enable border on left and right | |
borderY | Border | Enable border on top and bottom | |
noBorder | Border | Disable all borders | |
cursorDefault | Cursor | Default cursor - standard arrow | |
cursorMove | Cursor | Move cursor - indicates draggable element | |
cursorNone | Cursor | No cursor - hides the cursor | |
cursorNotAllowed | Cursor | Not-allowed cursor - indicates disabled state | |
cursorPointer | Cursor | Pointer cursor - indicates clickable element | |
cursorText | Cursor | Text cursor - indicates selectable text | |
cursorWait | Cursor | Wait cursor - indicates loading/processing | |
block | Display | Block display - takes full width, new line | |
contents | Display | Contents display - element's box is removed, children display as if parent didn't exist | |
flex | Display | ✓ | Flex display - flexbox container |
grid | Display | Grid display - CSS grid container | |
hidden | Display | Hidden display - element is not visible | |
inline | Display | Inline display - flows with text | |
inlineBlock | Display | Inline-block display - inline but with block properties | |
inlineFlex | Display | Inline-flex display - inline flexbox container | |
inlineGrid | Display | Inline-grid display - inline grid container | |
table | Display | Table display - behaves like table element | |
tableCell | Display | Table-cell display - behaves like td element | |
column | Flex Direction | ✓ | Flex direction column (vertical) |
columnReverse | Flex Direction | Flex direction column-reverse | |
row | Flex Direction | Flex direction row (horizontal) | |
rowReverse | Flex Direction | Flex direction row-reverse | |
focusVisible | Focus Visible | Enable focus-visible outline | |
noFocusVisible | Focus Visible | Disable focus-visible outline | |
gap | Gap | ✓ | Enable gap spacing between children, at the component's size |
gapLg | Gap | Large gap, whatever the component's size | |
gapMd | Gap | Medium gap, whatever the component's size | |
gapSm | Gap | Small gap, whatever the component's size | |
gapXl | Gap | Extra-large gap, whatever the component's size | |
gapXs | Gap | Extra-small gap, whatever the component's size | |
noGap | Gap | Disable gap spacing | |
hAuto | Height | Set height to auto | |
hFit | Height | Set height to fit-content | |
hFull | Height | Set height to 100% | |
hScreen | Height | Set height to 100vh (viewport height), removes max-height constraint | |
desktopHide | Hide | Hide element on desktop devices and below (max-desktop: 80rem) | |
mobileHide | Hide | Hide element on mobile devices and below (max-mobile: 48rem) | |
tabletHide | Hide | Hide element on tablet devices and below (max-tablet: 64rem) | |
itemsBaseline | Items | Align items to baseline | |
itemsCenter | Items | Align items to center | |
itemsEnd | Items | Align items to end (bottom/right) | |
itemsStart | Items | Align items to start (top/left) | |
itemsStretch | Items | Stretch items to fill container | |
justifyAround | Justify | Distribute items with space around them | |
justifyBaseline | Justify | Align items along their baseline on main axis | |
justifyBetween | Justify | Distribute items with space between them | |
justifyCenter | Justify | Center items along the main axis | |
justifyEnd | Justify | Pack items toward the end of the main axis | |
justifyEvenly | Justify | Distribute items with equal space around them | |
justifyStart | Justify | Pack items toward the start of the main axis | |
justifyStretch | Justify | Stretch items to fill the main axis | |
overflowAuto | Overflow | Auto overflow - show scrollbars if needed | |
overflowClip | Overflow | Clip overflow - hard clip without scrollbars | |
overflowHidden | Overflow | Hidden overflow - clip content without scrollbars | |
overflowScroll | Overflow | Scroll overflow - always show scrollbars | |
overflowVisible | Overflow | Visible overflow - content extends beyond bounds | |
overflowXAuto | Overflow | Auto overflow on X-axis only | |
overflowXClip | Overflow | Clip overflow on X-axis only | |
overflowXHidden | Overflow | Hidden overflow on X-axis only | |
overflowXScroll | Overflow | Scroll overflow on X-axis only | |
overflowXVisible | Overflow | Visible overflow on X-axis only | |
overflowYAuto | Overflow | Auto overflow on Y-axis only | |
overflowYClip | Overflow | Clip overflow on Y-axis only | |
overflowYHidden | Overflow | Hidden overflow on Y-axis only | |
overflowYScroll | Overflow | Scroll overflow on Y-axis only | |
overflowYVisible | Overflow | Visible overflow on Y-axis only | |
pointerEventsAuto | Pointer Events | Enable pointer events (default browser behavior) | |
pointerEventsNone | Pointer Events | Disable pointer events - clicks pass through the element | |
absolute | Position | Absolute positioning | |
fixed | Position | Fixed positioning | |
relative | Position | Relative positioning | |
static | Position | Static positioning | |
sticky | Position | Sticky positioning at the top edge; set --sticky-top to stick below a fixed header | |
responsiveSizing | Responsive Sizing | ✓ | Enable responsive sizing - uses breakpoint-specific classes for font size, padding, and gap |
desktopWFull | Responsive Width | Set width to 100% on desktop and below, below 1280px (max-desktop: 80rem) | |
mobileWFull | Responsive Width | Set width to 100% on mobile, below 768px (max-mobile: 48rem) | |
tabletWFull | Responsive Width | Set width to 100% on tablet and below, below 1024px (max-tablet: 64rem) | |
insetRing | Ring | Enable the inset ring — emits ring-inset | |
noInsetRing | Ring | Disable the inset ring | |
noShadow | Shadow | Disable drop shadow | |
shadow | Shadow | Enable drop shadow at the component's size | |
shadowLg | Shadow | Large drop shadow, whatever the component's size | |
shadowMd | Shadow | Medium drop shadow, whatever the component's size | |
shadowSm | Shadow | Small drop shadow, whatever the component's size | |
shadowXl | Shadow | Extra-large drop shadow, whatever the component's size | |
shadowXs | Shadow | Extra-small drop shadow, whatever the component's size | |
desktopShow | Show | Show element only on desktop and below, below 1280px (hidden from 80rem up) | |
mobileShow | Show | Show element only on mobile, below 768px (hidden from 48rem up) | |
tabletShow | Show | Show element only on tablet and below, below 1024px (hidden from 64rem up) | |
transparent | Transparent | Disable background color - makes component background transparent | |
whitespaceBreakSpaces | Whitespace | Preserve whitespace incl. trailing spaces, wrap text (white-space: break-spaces) | |
whitespaceNormal | Whitespace | Normal wrapping - default browser behavior | |
whitespaceNowrap | Whitespace | No wrap - text stays on single line | |
whitespacePre | Whitespace | Preserve whitespace and line breaks | |
whitespacePreLine | Whitespace | Preserve line breaks, collapse spaces, wrap text | |
whitespacePreWrap | Whitespace | Preserve whitespace, wrap text | |
wAuto | Width | Set width to auto | |
wFit | Width | Set width to fit-content | |
wFull | Width | Set width to 100% | |
wScreen | Width | Set width to 100vw (viewport width), removes max-width constraint | |
flexNoWrap | Wrap | Force flex items to stay on single line (may overflow) | |
flexWrap | Wrap | Allow flex items to wrap to new lines when container is too narrow | |
flexWrapReverse | Wrap | Wrap flex items in reverse order (last items wrap first) |